How do you splice out a part of an xvid encoded avi file, with ffmpeg? (no problems with other files)
2013-09
Im using the following command, which works for most files, except what seems to be xvid encoded ones
/usr/bin/ffmpeg -sameq -i file.avi -ss 00:01:00 -t 00:00:30 -ac 2 -r 25 -copyts output.avi
So this should basically splice out 30 seconds of video + audio, starting from 1 minute mark.
It does START encoding at the 00:01:00 mark but it goes all the way to the end of the file for some reason, ignoring that I want just 30 seconds.
The output looks like this.
FFmpeg version git-ecc4bdd, Copyright (c) 2000-2010 the FFmpeg developers
built on May 31 2010 04:52:24 with gcc 4.4.3 20100127 (Red Hat 4.4.3-4)
configuration: --enable-libx264 --enable-libxvid --enable-libmp3lame --enable-libopenjpeg --enable-libfaac --enable-libvorbis --enable-gpl --enable-nonfree --enable-libxvid --enable-pthreads --enable-libfaad --extra-cflags=-fPIC --enable-postproc --enable-libtheora --enable-libvorbis --enable-shared
libavutil 50.15. 2 / 50.15. 2
libavcodec 52.67. 0 / 52.67. 0
libavformat 52.62. 0 / 52.62. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.20. 0 / 1.20. 0
libswscale 0.10. 0 / 0.10. 0
libpostproc 51. 2. 0 / 51. 2. 0
[mpeg4 @ 0x17cf770]Invalid and inefficient vfw-avi packed B frames detected
Input #0, avi, from 'file.avi':
Metadata:
ISFT : VirtualDubMod 1.5.10.2 (build 2540/release)
Duration: 00:02:00.00, start: 0.000000, bitrate: 1587 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 672x368 [PAR 1:1 DAR 42:23], 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
File 'lol6.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'lol6.avi':
Metadata:
ISFT : Lavf52.62.0
Stream #0.0: Video: mpeg4, yuv420p, 672x368 [PAR 1:1 DAR 42:23], q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream #0.1: Audio: mp2, 48000 Hz, 2 channels, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[mpeg4 @ 0x17cf770]Invalid and inefficient vfw-avi packed B frames detected
[buffer @ 0x184b610]Buffering several frames is not supported. Please consume all available frames before adding a new one.
frame= 1501 fps=104 q=0.0 Lsize= 15612kB time=30.02 bitrate=4259.7kbits/s ts/s
video:15303kB audio:235kB global headers:0kB muxing overhead 0.482620%
if I convert this file to mp4 for example, and then perform the same action, it works perfectly.
I presume your "convert to MP4" operation is just a container change, not a full re-encode of the A/V data streams. So perhaps FFmpeg is getting hung up on something broken in those AVI containers. This line in your output might support this:
[mpeg4 @ 0x17cf770]Invalid and inefficient vfw-avi packed B frames detected
You could try creating a new AVI container -- let FFmpeg copy the entire file, eg with:
ffmpeg -i input.avi -vcodec copy -acodec copy output.avi
This should create a new AVI container and copy the data streams. Then try your command again. If it works, you've got broken AVIs (or possibly an FFmpeg bug) -- either way, you can put all your videos into new AVI containers and get it done that way.
If that doesn't work, you might look further into the broken XviDs and see what they have in common.
I wonder if your problem is the same as in this article:
Convert any video file for an iPod or iPhone
You want to use your fancy new Apple iPod Video or Apple iPhone, but you don't know how to convert video so it will play.
Ubuntu 9.10 (Karmic Koala) ships with a version of ffmpeg without libfaac support because of licensing issues. This means you will need to compile ffmpeg yourself. This guide explains how.
The article explains, step-by-step, how to compile ffmpeg by hand or create a modified ffmpeg package, that includes libfaac to support Advanced Audio Coding (AAC).
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