[Ffmpeg-devel] cutting a file and getting still images

Cyrus A lists
Fri Nov 3 17:22:16 CET 2006


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.

Cyrus





More information about the ffmpeg-devel mailing list