How can I avoid a few seconds of blank video when using -vcodec copy?
Posted
by
arlomedia
on Super User
See other posts from Super User
or by arlomedia
Published on 2011-11-16T17:05:13Z
Indexed on
2011/11/16
17:58 UTC
Read the original article
Hit count: 295
I'm processing user-uploaded videos on a CentOS web server with ffmpeg. I need to convert each video to a standard size and format, then extract a 30-second sample clip from each video. I want to use the "-vcodec copy" flag in the extraction command to avoid encoding a second time.
This command works for my initial conversion:
ffmpeg -i uploaded.mov -f mp4 -vcodec libx264 -vpre medium -acodec libfaac -r 15 -b 360k -ab 48k -ar 22050 -s 480x320 formatted.mp4
And this sometimes works for the extraction:
ffmpeg -i formatted.mp4 -vcodec copy -acodec copy -ss 0 -t 30 formatted_sample.mp4
However, when I run the extraction command on some videos, the extracted sample clip starts with several seconds of blank video. The audio starts right away but the video doesn't start for 3-6 seconds.
To demonstrate the problem, I've uploaded two video clips and run the above commands on them. I created the first clip in Final Cut Express and encoded it with Handbrake before uploading to the web server:
1a) uploaded clip
1b) converted with first command
1c) extracted with second command, missing first six seconds
By comparison, this second clip comes from Apple's website and does not show the problem:
2a) uploaded clip
2b) converted with first command
2c) extracted with second command, no problem
Can anyone see what's different about the two source clips? And if so, is there anything I can do in my conversion command so that when the extraction command runs, the clip is set up to avoid the missing video?
By the way, I initially had the problem with ffmpeg 0.6.1 installed from yum, but I upgraded to the latest git version and the problem remains.
© Super User or respective owner