dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

ffmpeg split video

Tue Apr 01, 2014 4:35 pm

I want to split a 50 seconds video from the camera and save second 10 till 40. I use the following ffmpeg command:

ffmpeg -i test1.h264 -acodec copy -vcodec copy -ss 00:00:10 -t 00:00:30 splittedvid.mp4

I get more than 2 seconds of black frames in the beginning, which is weird. When I use -ss 00:00:00 everything works just fine.
Any ideas?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26995
Joined: Sat Jul 30, 2011 7:41 pm

Re: ffmpeg split video

Tue Apr 01, 2014 4:45 pm

I'm guessing, but it may be the time from the point you specified to the first I-frame (the first complete frame). You generally cannot just start anywhere when splitting. (unless the code back tracks to the last I-frame, then scans forward to the start point).

You can increase the number of I-frames inserted using raspivid -g I think, but check the docs. So the more you have, the less delay before the next one.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

Re: ffmpeg split video

Tue Apr 01, 2014 4:54 pm

Thank you for that!

For reference of others with the same question, here the part from the documentation:

--intra, -g Specify the intra refresh period (key frame rate/GoP)
Sets the intra refresh period (GoP) rate for the recorded video. H264 video uses a complete frame (I-frame) every intra refresh period from which subsequent frames are based. This options specifies the numbers of frames between each I-frame. Larger numbers here will reduce the size of the resulting video, smaller numbers make the stream more robust to error.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26995
Joined: Sat Jul 30, 2011 7:41 pm

Re: ffmpeg split video

Tue Apr 01, 2014 8:14 pm

Was that actually the problem?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

Re: ffmpeg split video

Sat Apr 05, 2014 5:16 pm

yes:)

Return to “Camera board”