ffmpeg -vn -acodec pcm_s16le -ar 44100 -ac 2 TMP.wav -i OLD.mov
# Use lame to determine the volume adjustment for that WAV:
lame -f TMP.wav /dev/null | grep ReplayGain
# Convert dB to a ratio: r=10^(db/20)
# Convert ratio to ffmpeg's -vol arg: r*256
# Use ffmpeg to re-encode the audio at the new volume, while leaving video alone:
ffmpeg -i OLD.mov -vcodec copy -vol VOL -acodec libfaac -ab 160k -map_meta_data 0:0 NEW.mov
My worry, of course, is that doing this without actually listening to each file afterward might be a crazy thing to do, since it's a lossy process, and the files are huge, so I'm not going to want to keep both copies around for long. And also because I don't trust ffmpeg to not just go off and do something completely insane every now and then.
I'd be really, really worried about losing A/V sync on some files and not noticing it until later. Is this a way in which ffmpeg is likely to fuck up?
I am only even considering this, of course, since Apple broke the "Volume Adjustment" option on video files in iTunes 10, and I have no reason to expect that they'll ever fix that bug.
Update: Two things:
- Apple fixed the bug! They obey Volume Adjustment again as of iTunes 10.5 beta!
That doesn't help with videos that require more than +6dB, though, so I wrote this: video-replaygain.pl.