3
votes

I'm trying to use ffmpeg to cut out part of an avi file. I know similar questions have been asked before, but i've trawled through loads of other posts and I can't see where I'm going wrong.

The command line args i'm using to test on a 7 second video is:

-ss 00:00:01 -t 00:00:01 -i "C:\recordings\2013-09-11\Camera 1\Camera 1_2013-09-11_22-23-43.avi" -vcodec copy -acodec copy "I:\clip2.avi"

The output is:

ffmpeg version N-56254-gb7bd688 Copyright (c) 2000-2013 the FFmpeg developers built on Sep 12 2013 21:00:14 with gcc 4.7.3 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 43.100 / 52. 43.100 libavcodec 55. 31.101 / 55. 31.101 libavformat 55. 16.102 / 55. 16.102 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 84.100 / 3. 84.100 libswscale 2. 5.100 / 2. 5.100 libswresample 0. 17.103 / 0. 17.103 libpostproc 52. 3.100 / 52. 3.100

Guessed Channel Layout for  Input Stream #0.1 : mono

Input #0, avi, from 'C:\recordings\2013-09-11\Camera 1\Camera 1_2013-09-11_22-23-43.avi':
  Duration: 00:00:07.03, start: 0.000000, bitrate: 787 kb/s
    Stream #0:0: Video: msmpeg4v3 (DIV3 / 0x33564944), yuv420p, 800x448, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: adpcm_ms ([2][0][0][0] / 0x0002), 44100 Hz, mono, s16, 176 kb/s
Output #0, avi, to 'I:\clip2.avi':
  Metadata:
    ISFT            : Lavf55.16.102
    Stream #0:0: Video: msmpeg4v3 (DIV3 / 0x33564944), yuv420p, 800x448, q=2-31, 30 fps, 30 tbn, 30 tbc
    Stream #0:1: Audio: adpcm_ms ([2][0][0][0] / 0x0002), 44100 Hz, mono, 176 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   88 fps=0.0 q=-1.0 Lsize=     226kB time=00:00:02.03 bitrate= 908.7kbits/s    

video:146kB audio:66kB subtitle:0 global headers:0kB muxing overhead 6.345259%

I end up with a clip which is 3 seconds long !!!?? In the output I can see that the -ss flag is completely ignored.

Can anyone see where I'm going wrong?

Thanks

3
So... Did you try my solution (-ss after -i)?SpliFF

3 Answers

0
votes

Some tips here: https://trac.ffmpeg.org/wiki/Seeking%20with%20FFmpeg

See "Fast Seeking" vs "Accurate Seeking". For accurate seeking:

  • -ss must come AFTER -i

I suspect your input frames fall outside any keyframes so "Fast Seeking" (-ss before -i) fails.

Also -t normally takes as its input a number of frames, I'm not sure if it accepts a timecode. Consider using -t 1 instead or -to 00:00:02 instead (note: -to, not -t). EDIT: slhck is right regarding -t versus -vframes, see comment.

0
votes

-i is for duration. for example if you want 5 seconds video, Should write

-ss 00:00:01 -t 00:00:05 -i "C:\recordings\2013-09-11\Camera 1\Camera 1_2013-09-11_22-23-43.avi" -vcodec copy -acodec copy "I:\clip2.avi"

-ss is the offset when you write -ss 00:00:01 that Leaves to you 6 seconds when write -t 00:00:01 that's make a video with 1 second not 3 seconds.

0
votes

Just don't use codec copy command. delete "-vcodec copy -acodec copy" and try you are will get exact copy times