[Ffmpeg-devel] cutting a file and getting still images
Cyrus A
lists
Sat Nov 4 02:28:53 CET 2006
V?ctor Paesa wrote:
> Hi,
>
>> Cyrus A wrote:
>>
>>> Cyrus A wrote:
>>>
>>>> V?ctor Paesa wrote:
>>>>
>>>>>> Hi,
>>>>>>
>>>>>>
>>>>>>> Cyrus A wrote:
>>>>>>>
>>>>>>>
>>>>>>>> I'm trying to crop a 30-minute or hour-long segment of video down
>>>>>>>> to 1
>>>>>>>> minute and then immediately generate 60 still frames (one for each
>>>>>>>> second) from the resulting chopped video.
>>>>>>>>
>>>>>>>> Here are the commands I used:
>>>>>>>>
>>>>>>>> long input file generated with:
>>>>>>>> ffmpeg -v 0 -i /dev/video0 -async 1 -y -vcodec mpeg4 -acodec mp3 -t
>>>>>>>> 1780 -b 1750k -ab 192 -s 480x384 -r ntsc -vtag DX50
>>>>>>>> 'long_input_file.avi'
>>>>>>>>
>>>>>>>> "cut" command:
>>>>>>>> ffmpeg -ss 180 -t 60 -y -vcodec copy -acodec copy -i
>>>>>>>> long_input_file.avi short_output_file.avi
>>>>>>>>
>>>>>>>> still frames generation:
>>>>>>>> ffmpeg -i short_output_file.avi -r 1 -f image2 frame%03d.jpg
>>>>>>>>
>>>>>>>>
>>>>>>>> Console output for second command:
>>>>>>>>
>>>>>>>> FFmpeg version SVN-r6849, Copyright (c) 2000-2006 Fabrice
>>>>>>>> Bellard, et
>>>>>>>> al.
>>>>>>>> configuration: --enable-mp3lame
>>>>>>>> libavutil version: 49.0.2
>>>>>>>> libavcodec version: 51.23.0
>>>>>>>> libavformat version: 50.6.0
>>>>>>>> built on Oct 31 2006 12:55:14, gcc: 4.1.1 20060525 (Red Hat
>>>>>>>> 4.1.1-1)
>>>>>>>>
>>>>>>>> Seems that stream 0 comes from film source: 30000.00 (30000/1) ->
>>>>>>>> 29.97 (30000/1001)
>>>>>>>> Input #0, avi, from 'short_output_file.avi':
>>>>>>>> Duration: 00:01:00.3, start: 0.000000, bitrate: 1972 kb/s
>>>>>>>> Stream #0.0: Video: mpeg4, yuv420p, 480x384, 29.97 fps(r)
>>>>>>>> Stream #0.1: Audio: mp3, 48000 Hz, stereo, 192 kb/s
>>>>>>>> Output #0, image2, to 'frame%03d.jpg':
>>>>>>>> Stream #0.0: Video: mjpeg, yuvj420p, 480x384, q=2-31, 200 kb/s,
>>>>>>>> 1.00
>>>>>>>> fps(c)
>>>>>>>> Stream mapping:
>>>>>>>> Stream #0.0 -> #0.0
>>>>>>>> Press [q] to stop encoding
>>>>>>>> frame= 1 q=5.9 Lsize= 0kB time=1.0 bitrate= 0.0kbits/s
>>>>>>>> video:22kB audio:0kB global headers:0kB muxing overhead
>>>>>>>> -100.000000%
>>>>>>>>
>>>>>>>> Result:
>>>>>>>>
>>>>>>>> Only the first image (frame001.jpg) is created.
>>>>>>>>
>>>>>>>> Observations:
>>>>>>>>
>>>>>>>> The ffmpeg long file generation command works well. The file
>>>>>>>> looks and
>>>>>>>> sounds good. Similarly,the "cutting" command above seems to work
>>>>>>>> well.
>>>>>>>> I can get any size video from any part of the longer video with
>>>>>>>> ease.
>>>>>>>> The videos play normally in mplayer as well as DivX and WMP on
>>>>>>>> windows. However, it's the stills frame generation that seems
>>>>>>>> broken.
>>>>>>>> Two caveats:
>>>>>>>>
>>>>>>>> First, if the stills generation command is run on a file that was
>>>>>>>> "cut" using "-ss 0 -t 60" (no seek), the stills are generated
>>>>>>>> correctly. Anything other than "-ss 0" causes problems.
>>>>>>>>
>>>>>>>> Second, videos recorded by an old version of ffmpeg (0.4.8 --
>>>>>>>> probably
>>>>>>>> early 2005 or late 2004) seem to be "cut" and "stills extracted"
>>>>>>>> correctly by the series of commands above.
>>>>>>>>
>>>>>>>> file command output for avi recorded with "old" ffmpeg and chopped
>>>>>>>> with rev6849: RIFF (little-endian) data, AVI, 480 x 384, ~30 fps,
>>>>>>>> video: DivX 4, audio: MPEG-1 Layer 3 (mono, 44100 Hz)
>>>>>>>>
>>>>>>>> file command output for avi recorded and chopped with rev6849: RIFF
>>>>>>>> (little-endian) data, AVI, 480 x 384, ~30 fps, video: DivX 5,
>>>>>>>> audio:
>>>>>>>> MPEG-1 Layer 3 (stereo, 48000 Hz)
>>>>>>>>
>>>>>>>> I don't think the recording rate nor the DivX 4 vs DivX5
>>>>>>>> differences
>>>>>>>> have anything to do with my problem, but I could be wrong.
>>>>>>>>
>>>>>>>> FILES:
>>>>>>>>
>>>>>>>> A file recorded with "old" ffmpeg and chopped on rev 6849 can be
>>>>>>>> found
>>>>>>>> here:
>>>>>>>>
>>>>>>>> http://wkyt.dynalias.com/rec_with_old_chopped_with_6849.avi
>>>>>>>>
>>>>>>>> A file recorded with rev 6849 and chopped with rev 6849 can be
>>>>>>>> found
>>>>>>>> here:
>>>>>>>>
>>>>>>>> http://wkyt.dynalias.com/rec_with_6849_and_chopped_with_6849.avi
>>>>>>>>
>>>>>>>> Please let me know what you think of this problem. It is the very
>>>>>>>> final step in a system I've been working on sporadically for about
>>>>>>>> 9
>>>>>>>> months. I might just take the rest of the week off if I can get
>>>>>>>> this
>>>>>>>> to work. Thanks again for your help.
>>>>>>>>
>>>>>>>> Cyrus
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> ffmpeg-devel mailing list
>>>>>>>> ffmpeg-devel at mplayerhq.hu
>>>>>>>> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>>>>>>>>
>>>>>>>>
>>>>>>> Ok, apparently my last message was too long because nobody has
>>>>>>> responded
>>>>>>> yet. Just do this:
>>>>>>>
>>>>>>> Download this file:
>>>>>>>
>>>>>>> http://wkyt.dynalias.com/rec_with_6849_and_chopped_with_6849.avi
>>>>>>>
>>>>>>> and run the following command to get 1 still frame for each second
>>>>>>> of
>>>>>>> video:
>>>>>>>
>>>>>>> fmpeg -i rec_with_6849_and_chopped_with_6849.avi -r 1 -f image2
>>>>>>> frame%03d.jpg
>>>>>>>
>>>>>>> Then tell me if it works.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> No, it's not long, it is a good description (and I appreciate it).
>>>>>>
>>>>>>
>>>>>>
>>>>> [snip]
>>>>>
>>>>>
>>>>>> I'll rebase to your SVN-6849, configure with --enable-mp3lame, and
>>>>>> I'll tell you how it goes.
>>>>>>
>>>>>>
>>>>>>
>>>>> Bad news, I'm not able to reproduce your problem, SVN-r6849 also
>>>>> generates 62 frames:
>>>>>
>>>>> $ ./ffmpeg -i /cygdrive/n/rec_with_6849_and_chopped_with_6849.avi -r
>>>>> 1 -f
>>>>> image2 frame%03d.jpg
>>>>> FFmpeg version SVN-r6849, Copyright (c) 2000-2006 Fabrice Bellard,
>>>>> et al.
>>>>> configuration: --enable-mp3lame --disable-shared
>>>>> libavutil version: 49.0.2
>>>>> libavcodec version: 51.23.0
>>>>> libavformat version: 50.6.0
>>>>> built on Nov 3 2006 21:46:54, gcc: 3.4.4 (cygming special) (gdc
>>>>> 0.12,
>>>>> using dmd 0.125)
>>>>>
>>>>> Seems that stream 0 comes from film source: 30000.00 (30000/1) ->
>>>>> 29.97
>>>>> (30000/1001)
>>>>> Input #0, avi, from
>>>>> '/cygdrive/n/rec_with_6849_and_chopped_with_6849.avi':
>>>>> Duration: 00:01:00.0, start: 0.000000, bitrate: 1979 kb/s
>>>>> Stream #0.0: Video: mpeg4, yuv420p, 480x384, 29.97 fps(r)
>>>>> Stream #0.1: Audio: mp3, 48000 Hz, stereo, 192 kb/s
>>>>> Output #0, image2, to 'frame%03d.jpg':
>>>>> Stream #0.0: Video: mjpeg, yuvj420p, 480x384, q=2-31, 200 kb/s,
>>>>> 1.00
>>>>> fps(c)
>>>>> Stream mapping:
>>>>> Stream #0.0 -> #0.0
>>>>> Press [q] to stop encoding
>>>>> frame= 62 q=5.5 Lsize= 0kB time=62.0 bitrate= 0.0kbits/s
>>>>> video:1705kB audio:0kB global headers:0kB muxing overhead -100.000000%
>>>>>
>>>>>
>>>>> I'm afraid your problem is platform related. If you can, try to
>>>>> build on
>>>>> a different one (try "make distclean" before, just in case).
>>>>>
>>>>> Regards,
>>>>> V?ctor
>>>>> _______________________________________________
>>>>> ffmpeg-devel mailing list
>>>>> ffmpeg-devel at mplayerhq.hu
>>>>> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>>>>>
>>>>>
>>>> This experiement was on FC5 x86_64 Athlong X2 with the latest 2.6.17
>>>> RPM kernel. What kernel were you using?
>>>> _______________________________________________
>>>> ffmpeg-devel mailing list
>>>> ffmpeg-devel at mplayerhq.hu
>>>> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>>>>
>>> DOH! I must have made a mistake with the file I posted because it just
>>> worked for me on that file, too.
>>>
>>> Try this file instead:
>>>
>>> http://wkyt.dynalias.com/rec_with_6849_and_chopped_with_6849_2.avi
>>>
>>> That file - just this minute - failed for me. Hopefully it'll fail for
>>> you too.
>>>
>>> As I said in my long post, using -ss 0 to cut files seems to be ok. I
>>> must have done that with the first file. Sorry.
>>>
>>> Cyrus
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel at mplayerhq.hu
>>> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>>>
>> Here is the console output of the failure:
>>
>> [cyrus at wkyt ROOT]$ /home/cyrus/ffmpeg_6849/ffmpeg -i
>> rec_with_6849_and_chopped_with_6849_2.avi -r 1 -f image2 frame%03d.jpg
>> FFmpeg version SVN-r6849, Copyright (c) 2000-2006 Fabrice Bellard, et al.
>> configuration: --enable-mp3lame
>> libavutil version: 49.0.2
>> libavcodec version: 51.23.0
>> libavformat version: 50.6.0
>> built on Oct 31 2006 12:55:14, gcc: 4.1.1 20060525 (Red Hat 4.1.1-1)
>>
>> Seems that stream 0 comes from film source: 30000.00 (30000/1) -> 29.97
>> (30000/1001)
>> Input #0, avi, from 'rec_with_6849_and_chopped_with_6849_2.avi':
>> Duration: 00:01:00.2, start: 0.000000, bitrate: 1948 kb/s
>> Stream #0.0: Video: mpeg4, yuv420p, 480x384, 29.97 fps(r)
>> Stream #0.1: Audio: mp3, 44100 Hz, stereo, 192 kb/s
>> Output #0, image2, to 'frame%03d.jpg':
>> Stream #0.0: Video: mjpeg, yuvj420p, 480x384, q=2-31, 200 kb/s, 1.00
>> fps(c)
>> Stream mapping:
>> Stream #0.0 -> #0.0
>> Press [q] to stop encoding
>> frame= 1 q=5.4 Lsize= 0kB time=1.0 bitrate= 0.0kbits/s
>> video:22kB audio:0kB global headers:0kB muxing overhead -100.000000%
>>
>>
>
> Reproduced with your rec_with_6849_and_chopped_with_6849_2.avi,
> it must be a bug.
>
> I'm not a real developer, and I don't know how to fix it, but
> I have found that piping the file is a valid workaround, try it:
>
> $ cat rec_with_6849_and_chopped_with_6849_2.avi |./ffmpeg -i - -r 1 -f
> image2 frame%03d.jpg
> FFmpeg version SVN-r6849, Copyright (c) 2000-2006 Fabrice Bellard, et al.
> configuration: --enable-mp3lame --disable-shared
> libavutil version: 49.0.2
> libavcodec version: 51.23.0
> libavformat version: 50.6.0
> built on Nov 4 2006 00:08:02, gcc: 3.4.4 (cygming special) (gdc 0.12,
> using dmd 0.125)
>
> Seems that stream 0 comes from film source: 30000.00 (30000/1) -> 29.97
> (30000/1001)
> Input #0, avi, from 'pipe:':
> Duration: 00:01:00.2, start: 0.000000, bitrate: N/A
> Stream #0.0: Video: mpeg4, yuv420p, 480x384, 29.97 fps(r)
> Stream #0.1: Audio: mp3, 44100 Hz, stereo, 192 kb/s
> Output #0, image2, to 'frame%03d.jpg':
> Stream #0.0: Video: mjpeg, yuvj420p, 480x384, q=2-31, 200 kb/s, 1.00
> fps(c)
> Stream mapping:
> Stream #0.0 -> #0.0
> frame= 62 q=5.4 Lsize= 0kB time=62.0 bitrate= 0.0kbits/s
> video:1684kB audio:0kB global headers:0kB muxing overhead -100.000000%
>
>
> Regards,
> V?ctor
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>
You are my new hero.
Cyrus
More information about the ffmpeg-devel
mailing list