I have a few videos in AVI format of some TV content that appears sourced in PAL format. Importantly, the video plays at 25fps and the audio is 4% faster. Some of this is music video, so it's quite annoying to have this speed alteration. I figured it would be easy to correct it in software and then encode the result into "iOS compliant" format (H264/AAC) for playback on my iPhone/iPod/iPad/etc.
So basically, my need is to slow down the frame rate of the video and lower the pitch and speed of the audio appropriately.
I am doing all of this on Mac OS X 10.7 Lion, in the Terminal.
So far, my script does this:
1. use ffmpeg to extract the audio (in MP3 format) from the original AVI
2. convert the MP3 to uncompressed WAV (I could probably combine steps 1 and 2, but I am being verbose for now.) - I can do this using either lame or afconvert.
3. use SoX to adjust the playback speed of the uncompressed wave to account for the 4% speedup - I use the speed parameter and a WAV is produced with audio at the correct speed.
Now I want to mix this uncompressed WAV back with the original AVI file - AND - set the FPS on the video to 24. Obviously I don't want any re-encoding just to change the framerate of the AVI - HandBrakeCLI is going to be encoding. Since I have slowed down the audio, I need only to change the frame rate so that the video will play its frames slower to match the corrected audio.
ffmpeg's -r option doesn't do what I need - it doesn't appear it can work if you use -vcodec copy, and nonetheless the docs seem to say it uses frame dropping or duping to achieve the specified rate, rather than simply altering the specified frame rate (and thus the duration) of the video stream.
HandBrakeCLI's frame rate option seems to do the same thing - the video says it's running at 24fps, but it still is running too fast as the video track ends up ahead of the audio as playback progresses.
I thought about extracting the video from the AVI into a raw MPEG4 stream and then somehow altering its frame rate there, but I'm not sure what command line tools would be able to do this. Also I considered using the MKV container as an interim step, which seems to have more command line tools available for Mac (mkvmerge etc) but still am not sure how to actually accomplish this step.
After remuxing the adjusted audio and the original source frames with their FPS adjusted, I'd then pass the resulting AVI or MKV file into HandBrakeCLI to perform the actual final encode.
To summarize: I need to simply CHANGE the frame rate of the AVI file's MPEG4 video stream - so that the frames play slower to match the audio which has been slowed down appropriately. I do NOT want any re-encoding at this stage as HandBrake will do that later.
Remember, this is being scripted so things that can be executed from the command line in OS X are essential.
Any advice would be greatly appreciated!
+ Reply to Thread
Results 1 to 2 of 2
just wondering why handbrake is doing the encoding?
if you could live with ffmpeg doing the encoding then the -vf "setpts=some_rate_here" would probably do the trick for you,but sadly the -vcodec copy option doesn't work for that either so you'd need to encode the mp4 from ffmpeg.
info about filters (set pts is one for setting time stamps) is here
settb might be worth a look too....
all this is of course moot if you are dead set on handbrake doing the encoding, but i thought this may spark a train of thought at least...
PS I work in broadcast video so the only real chance i've had to do this was with ProRes/uncompressed files and apple's Cinema Tools which has a conform option-
this does exactly what you want but is NOT command line and doesn't like long gop stuff.
all my very best and do post if you find something good.