[FFmpeg-user] Selecting/cutting small sections of videos with ffmpeg

Chris Racey c.racey1 at gmail.com
Wed Sep 5 22:35:02 CEST 2012


Hi,

Thanks very much for responding. I've actually managed to solve this now
thanks to the help of a guy on the #ffmpeg irc channel.

Basically I'm now re-encoding the video but preserving as much of the
quality as possible using the following...

ffmpeg -i full.mp4 -ss 3 -t 2 -vcodec libx264 -crf 0 -preset placebo
output.mp4

Based on what I've now learned I realise I should have done this cutting
step before we compressed the videos from uncompressed avi to mp4. Sadly
it's too late since they've been deleted.

Many thanks for all the help, it's great that there's such a friendly and
helpful community around ffmpeg.

Chris


On Wed, Sep 5, 2012 at 8:36 PM, Andy Civil <andycivil at gmail.com> wrote:

> The problem is that a MP4 file contains "I Frames" which are self
> contained, and other frames which are only differences, they're (usually)
> calculated from previous frames. A MP4 file may be entirely I frames, or at
> the extreme, may have only one I frame at the start, and then P frames
> (difference frames) from there on.
>
> If you want to copy a file without recoding it, then you can ONLY cut it
> to start at an I frame. (You can finish anywhere.)
>
> The behaviour of FFmpeg is that if you ask to cut at a certain time with
> -ss then it will scan through the file to that point, then continue to scan
> forward until it finds an I frame, and then copy from that point on. Unless
> you carefully calculate your start point to coincide with an I frame, then
> you will lose some video.
>
> Your clip is so short that I suspect that there isn't even a single I
> frame between your start point (3 seconds) and your end point (2 seconds
> later). In this case you will get no video at all, which is exactly what
> your error says.
>
> Thank you for posting your output, I guess the other respondant didn't
> notice the link.
>
> --
> Andy
>
>
> On 2012-09-05 6:46 AM, Chris Racey wrote:
>
>> I'm very much a novice user of ffmpeg, and I'm using it with the windows
>> command prompt. I have 7 second long, 25fps, mp4 videos and I'm tyring to
>> cut out small 2 second sections of them using ffmpeg.
>>
>> The problem I'm having is I cant get it to cut properly if I specify a
>> start point other than the beginning of the video.
>>
>> Originally I was running this command:-
>>
>> Code: ffmpeg -i full.mp4 -ss 3 -t 2 -vcodec copy -acodec copy cut.mp4
>>
>> This fails with errors saying I should (check -ss / -t / -frames
>> parameters
>> if used) (paste bin of the error: http://pastebin.com/RWJ6wFZ1).
>>
>> If i set -ss to 0 this cuts 2 seconds from the start and works fine.
>>
>> Following some advice from IRC I tried this:-
>>
>> Code: ffmpeg -i full.mp4 -vf select='gte(t\,3)*lte(t\,5)' -vcodec copy
>> -acodec copy test.mp4
>>
>> This ignores the specified window and copies over the whole 7 seconds.
>>
>> Could anyone tell me where I'm going wrong?
>>
>> Many thanks,
>> Chris
>> ______________________________**_________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> http://ffmpeg.org/mailman/**listinfo/ffmpeg-user<http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>>
>>
> ______________________________**_________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/**listinfo/ffmpeg-user<http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>


More information about the ffmpeg-user mailing list