Frame exact splitting with ffmpeg
When preparing videos for Apples HTTP streaming for iPad/iPhone you need to split your video into 10s chunks and provide a play list for Quicktime to process.
The problem lies with frame exact splitting of arbitrary video input material. Wether you split the file using ffmpeg or the Apple segmenter tool you often end up with
- asynchronous audio in some or all segments
- missing video frames at the start of each segment
- audio glitches between two segements
- missing audio+video between otherwise audio-synchronous consecutive segments
ffmpeg -i inputfile -vcodec mpeg2video -pix_fmt yuv422p -qscale 1 -qmin 1 -intra outputfile
The relevant piece is the "-intra" switch. For MPEG-4 TS something like the following should work:
ffmpeg -i inputfile -vcodec libx264 -vpre slow -vpre baseline -acodec libfaac -ab 128k -ar 44100 -intra -b 2000k -minrate 2000k -maxrate 2000k outputfile
Note: It is important to watch the resulting muxing overhead which might lower the effective bitrate a lot!
The resulting output files should be safe to be passed to the Apple segmenter.