Unable to cut out part of video with ffmpeg
2013-08
What I want to do
I'm trying to cut a video for a science project under Ubuntu 11.10 with latest ffmpeg, I also tried Kino and avidemux where the video failed to even open properly although it plays well in both VLC and mplayer.
The closest I have come so far is with these parameters:
ffmpeg -ss 01:58 -t 21 -i row.avi -vcodec copy row_cut.avi
Also tried
ffmpeg -ss 1 -i row.avi -vcodec copy -t 3 row_cut.avi
and still have the same error :(
Where I get at least a 21s video as output and no apparent errors but the video won't play in VLC (ticker rolls but only displays VLC-logo) nor mplayer ("Internal data stream error").
FFmpeg output when encoding
ffmpeg version git-2012-02-02-c853124 Copyright (c) 2000-2012 the FFmpeg developers
built on Feb 2 2012 23:17:50 with gcc 4.6.1
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable --libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
libavutil 51. 37.100 / 51. 37.100
libavcodec 54. 0.102 / 54. 0.102
libavformat 54. 0.100 / 54. 0.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, avi, from 'row.avi':
Duration: 00:03:13.93, start: 0.000000, bitrate: 46210 kb/s
Stream #0:0: Video: rawvideo, pal8, 640x300, 30 tbr, 30 tbn, 30 tbc
File 'row_cut.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'row_cut.avi':
Metadata:
ISFT : Lavf54.0.100
Stream #0:0: Video: rawvideo, pal8, 640x300, q=2-31, 30 tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 631 fps=125 q=-1.0 Lsize= 118334kB time=00:00:21.03 bitrate=46088.4kbits/s
video:118312kB audio:0kB global headers:0kB muxing overhead 0.018043%
FFmpeg output when loading the videos
My guess is that the video has some type of weird format, misunderstood the ffmpeg's parameters or perhaps the Metada:encoder:Lavf53.3.0 part in the output?
user@computer:/somewhere$ ffmpeg -i row.avi
Input #0, avi, from 'row.avi':
Duration: 00:03:13.93, start: 0.000000, bitrate: 46210 kb/s
Stream #0.0: Video: rawvideo, pal8, 640x300, 30 tbr, 30 tbn, 30 tbc
and
user@computer:/somewhere$ ffmpeg -i row_cut.avi
Input #0, avi, from 'row_cut.avi':
Metadata:
encoder : Lavf54.0.100
Duration: 00:00:21.03, start: 0.000000, bitrate: 46088 kb/s
Stream #0.0: Video: rawvideo, bgr24, 640x300, 30 tbr, 30 tbn, 30 tbc
Mediainfo output
General
Complete name : row.avi
Format : AVI
Format/Info : Audio Video Interleave
Format profile : OpenDML
File size : 1.04 GiB
Duration : 3mn 13s
Overall bit rate : 46.2 Mbps
Video
ID : 0
Format : RGB
Codec ID : 0x00000000
Codec ID/Info : Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain raw RGB samples
Duration : 3mn 13s
Bit rate : 46.1 Mbps
Width : 640 pixels
Height : 300 pixels
Display aspect ratio : 2.2:1
Frame rate : 30.000 fps
Bit depth : 8 bits
Bits/(Pixel*Frame) : 8.000
Stream size : 1.04 GiB (100%)
and
General
Complete name : row_cut.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 116 MiB
Duration : 21s 33ms
Overall bit rate : 46.1 Mbps
Writing application : Lavf54.0.100
Video
ID : 0
Format : RGB
Codec ID : 0x00000000
Codec ID/Info : Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain raw RGB samples
Duration : 21s 33ms
Bit rate : 46.1 Mbps
Width : 640 pixels
Height : 4294966 996 pixels
Display aspect ratio : 0.000
Frame rate : 30.000 fps
Bit depth : 8 bits
Stream size : 116 MiB (100%)
Answer from the ffmpeg mailing list:
You cannot use -vcodec copy on pal8 rawvideo (this may be a bug), but you can use -vcodec rawvideo as a work-around.
It kinda works plays in VLC but not mplayer so it will do for now. The final working command would be
ffmpeg -ss 1 -i row.avi -vcodec rawvideo -t 3 row_cut.avi
I've tried
ffmpeg -t in_movie.avi -ss 00:26:20 -t 00:28:24 out_movie.avi
but that's giving me:
Invalid duration specification for t: in_movie.avi
Please advise.
UPDATE: Molly, that command gives:
FFmpeg version SVN-r19352-4:0.5+svn20090706-2ubuntu2, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --extra-version=4:0.5+svn20090706-2ubuntu2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --extra-cflags=-I/build/buildd/ffmpeg-0.5+svn20090706/debian/include --enable-shared --disable-static
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Oct 13 2009 22:15:16, gcc: 4.4.1
Input #0, avi, from 'extras.s01.e01.ws.dvdrip.xvid-m00tv.avi':
Duration: 00:29:04.04, start: 0.000000, bitrate: 1120 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 640x368 [PAR 1:1 DAR 40:23], 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 32 kb/s
Output #0, avi, to 'out_movie.avi':
Stream #0.0: Video: mpeg4, yuv420p, 640x368 [PAR 1:1 DAR 40:23], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream #0.1: Audio: mp2, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 0 fps= 0 q=0.0 size= 10kB time=10000000000.00 bitrate= 0.0kbitframe= 0 fps= 0 q=0.0 size= 10kB time=10000000000.00 bitrate= 0.0kbitframe= 0 fps= 0 q=0.0 size= 10kB time=10000000000.00 bitrate= 0.0kbit
And then it appears to freeze. I'd appreciate any help.
you were pretty close :)
the correct syntax would be ffmpeg -i InputFile -ss StartTime -t Duration Outputfile
so try:
ffmpeg -i in_movie.avi -ss 00:26:20 -t 00:28:24 out_movie.avi
Update
this episode is about 40:23 long. -t specifies the duration, not the end time. your command will start recording at 26:20 for 28 minutes and 24 seconds, that would be until 54:44. if you want to record from 26:20 to 28:24 use the switch -t 00:02:04 instead.
ffmpeg -i in_movie.avi -ss 00:26:20 -t 00:02:04 out_movie.avi
now this will give you an AVI clip 2 minutes and 4 seconds long, captured from 26:20 to 28:24