Tuesday, October 18, 2011

Trimming FLV Videos

I wanted to trim some FLV videos without re-encoding.

flvtool2 is supposed to cut flv videos (in milliseconds!), but I always got errors.
flvtool2 -C -i 6000 -o 12000 input.flv output.flv
Avidemux opened the video and I could trim it (using keyframe arrows was necessary), but trying saving in FLV format had errors. Saving as an MP4 with copy/copy was successful, but sound was no longer synced. There is an option to shift the audio, but I didn't do any testing.

ffmpeg ended up being the easiest solution, but it didn't trim exactly where I specified. I'm guessing this has to do with keyframes. The following example trims approx first 15 seconds off the front of the video, and audio is synced.
ffmpeg -ss 15 -i input.flv -acodec copy -vcodec copy output.flv
According to the man pages, the value can be specified to millisecond: "hh:mm:ss[.xxx]", but I could never get this to work.

1 comment: