Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: --ignore-chunk-size and non-zero 'data' chunk size (Read 4760 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

--ignore-chunk-size and non-zero 'data' chunk size

Hi everyone! I use Recforge II to record my university's lectures (it records to WAV), then I convert to FLAC and quality 0 Mp3 to upload the files to my cloud.

Having to do this everyday as my phone space always gets low, I autmated it via a script, which is as follows:

Quote
#!/bin/bash
for f in *.wav; do
flac -8 --ignore-chunk-size "$f"
lame -V 0 "$f"
rm "$f"
done


I need this script not only because it's annoying to repeat manually for each folder (every exam has a separate folder) and both formats, but also because I need to save space on my PC: after converting each WAV to both formats, I delete it before converting the next one.

So, I appended --ignore-chunk-size to avoid the file being deleted without being converted, as sometimes Recforge II screws up and I find myself with a WAV having a 'data' chunk size of 0. I don't have much time to learn how to add a control sequence.

Long story short: every time, flac appends this warning:

Quote
WARNING: 'data' chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea


My question is: how is it a bad idea? What happens, and why flac advices me not to use that option on a regular file?

Thanks, have a great day!
The Dude minds.

--ignore-chunk-size and non-zero 'data' chunk size

Reply #1
WAV files (and other RIFF formats) are divided into chunks, each with a length to tell the program reading it where one chunk ends and the next begins.

If you tell flac to ignore the length, it will assume everything following the start of the data chunk is audio, even if it's not.

It sounds like it's not a problem, because all of the WAV files you're using have nothing after the data chunk. However, WAV files with additional chunks after the data chunk do exist. If you encode one of those with --ignore-chunk-size, you'll get a bunch of noise after the audio ends.

 

--ignore-chunk-size and non-zero 'data' chunk size

Reply #2
So, I appended --ignore-chunk-size to avoid the file being deleted without being converted, as sometimes Recforge II screws up and I find myself with a WAV having a 'data' chunk size of 0. I don't have much time to learn how to add a control sequence.


You're using the BASH shell so you don't need to append --ignore-chunk-size to avoid the file being deleted.  In this instance you should use the ampersand.  A single ampersand allows commands to be executed concurrently, while double ampersand allows a command to be executed only where the previous command had been completed.

Your script currently has three sequential stages; first, it encodes to flac level 8, when this is finished (successfully or not) it encodes to lame mp3, then finally removes the wav file:
Code: [Select]
#!/bin/bash
for f in *.wav; do
flac -8 --ignore-chunk-size "$f"
lame -V 0 "$f"
rm "$f"
done

Using ampersands would make it more efficient, as well as preventing deletion when Recforge has screwed up.  The following has two stages; it encodes to flac and mp3 concurrently then deletes the wav ONLY IF the encodes have been completed succesfully:
Code: [Select]
#!/bin/bash
for f in *.wav; do
flac -8 "$f" & lame -V 0 "$f" && rm "$f";
done