[Ffmpeg-devel] seek with duration for cutting: broken or changed?

Cyrus A lists
Wed Nov 1 23:04:59 CET 2006


V?ctor Paesa wrote:
>> Michael Niedermayer wrote:
>>     
>>> Hi
>>>
>>> On Mon, Oct 30, 2006 at 05:37:25PM -0500, Cyrus A wrote:
>>>
>>>       
>>>> Michael Niedermayer wrote:
>>>>
>>>>         
>>>>> Hi
>>>>>
>>>>> On Mon, Oct 30, 2006 at 12:55:16PM -0500, Cyrus A wrote:
>>>>>
>>>>>
>>>>>           
>>>>>> The following command used to work to cut a specific segment out of a
>>>>>> video file on some FC3 machines I'm using with an old version of
>>>>>> ffmpeg
>>>>>> (still does work):
>>>>>>
>>>>>> ffmpeg -acodec copy -vcodec copy -i fullvideo.avi -ss 60 -t 120
>>>>>> choppedvideo.avi
>>>>>>
>>>>>> But it doesn't work anymore with Fedora Core 5 on a 64-bit machine
>>>>>> running today's SVN copy of ffmpeg. (Also doesn't work with freshrpms
>>>>>> latest ffmpeg rpm, either.) I believe what it's doing is seeking, but
>>>>>> the duration is completely ignored. It just returns the rest of the
>>>>>> file
>>>>>>
>>>>>>             
>>>>> >from where the seek took it. The resulting file is also a little
>>>>>
>>>>>           
>>>>>> "chirpy"  -- the audio video sync is messed up somehow.
>>>>>>
>>>>>>
>>>>>>             
>>>>> could you find out when this problem was introduced into svn (see
>>>>> binary search and svn up -r)
>>>>>
>>>>> [...]
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> Found it. The seek + duration option worked normally through revision
>>>> 4526 and then stopped working in 4527 and every other revision
>>>> thereafter. It was August 15th, 2005.
>>>>
>>>> The change notes read:
>>>>
>>>> parse pict_type for streams in avi
>>>> fix mpeg4 parser so it outputs te pict_type
>>>> support header only parseing without repacking
>>>>
>>>> That's interesting since I'm using mpeg4 for my vcodec and producing an
>>>> AVI file.
>>>>
>>>> Man, binary searching like that is not fun. Please let me know what you
>>>> think.
>>>>
>>>>         
>>> i think ive just fixed it ...
>>>
>>> [...]
>>>
>>>       
>> Ok, that helped. The "ffmpeg -i input.avi -acodec copy -vcodec copy -ss
>> 5 -t 10 output.avi" command no longer churns as before. The cut is very
>> quick and look as if it worked. But it doesn't. Here are the various
>> commands I used for some tests: ("old" means 0.4.8 ffmpeg-era on 32-bit
>> machines):
>>
>> 6849 rec: ffmpeg -i /dev/video0 -async 1 -y -vcodec mpeg4 -acodec mp3 -t
>> 30 -b 1750k -ab 192 -ar 44100 -s 480x384 test.avi
>> old rec: ffmpeg -r ntsc -vd /dev/video0 -ad /dev/audio -vcodec mpeg4
>> -acodec mp3 -y -s 480x384 -b 1750 -t 30 test.avi
>>
>> 6849 cut: ffmpeg -i test.avi -acodec copy -vcodec copy -y -ss 5 -t 20
>> test_cut.avi
>> old cut: ffmpeg -i test.avi -acodec copy -vcodec copy -y -ss 5 -t 20
>> test_cut.avi
>>
>> 6849 cut reenc: ffmpeg -i test.avi -acodec mp3 -vcodec mpeg4 -y -ss 5 -t
>> 20 test_cut.avi
>> old cut reenc: ffmpeg -i test.avi -acodec mp3 -vcodec mpeg4 -y -ss 5 -t
>> 20 test_cut.avi
>>
>> Here is the 2x3 results table:
>>                oldcopy            6849copy       6849reenc    <-- cut
>> with this version
>> old          OK                  aud b4 vid      no audio at all
>> 6849     aud b4 vid        *aud b4 vid*      OK
>> ^---- recorded with this version
>>
>> *= this is the one I need to work
>>
>> So if I record on the old version and copy-cut with the old version, it
>> works. Ditto the 6849 revision when reencode cut with -acodec mp3 and
>> vcodec mpeg4. Problem is, the old version won't compile on my 64 bit
>> machine under FC5 (common.h: incompat element type) and the new version
>> won't do a copy cut. A reencode cut doesn't help me because it takes
>> forever for big files. These cuts have to be quick for web application
>> use.
>>
>> An interesting note I found was that for those that have "audio before
>> video" the audio is exactly 5 seconds before the video. So, I tried -ss
>> 2 and, whammo, the audio was only 2 seconds before the video. Likewise,
>> -ss 8 made the audio 8 seconds before the video. Obviously, this is the
>> problem.
>>
>> If anyone can help me get syncd files from a "cut" process, I would
>> really really appreciate it.
>>
>>     
>
> Parameters in FFmpeg are applied in the order they appear,
> I believe you should set -ss 5 -t 20 before setting your input file:
>
> ffmpeg -ss 5 -t 20 -i test.avi \
>   -acodec copy -vcodec copy -y test_cut.avi
>
> Regards,
> V?ctor
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>   
You were right. That fixed it. Duh.

One more problem though. Usually I can use the command:

./ffmpeg -i test.avi -r 1 -f image2 test_stills%03d.jpg

to generate one still frame for every second of a video. It still works 
on newly recorded video. However, the command doesn't work when applied 
to a file "cut" with ffmpeg:

./ffmpeg -ss 5 -t 20 -i test.avi -acodec copy -vcodec copy -y  test_cut.avi
followed by
./ffmpeg -i test_cut.avi -r 1 -f image2 test_stills%03d.jpg

creates one still frame from the very beginning of the video but no 
others. The ffmpeg output says "time=1.0" whereas before it would say 
"time=x" where x was equal to the clip duration in seconds. It's as if 
ffmpeg crashes without actually crashing. It makes one image and then 
stops. The "file" output for each resulting AVI is identical.

What could be causing a "cut" file to crap out like that after making 
one still frame?

Cyrus






More information about the ffmpeg-devel mailing list