[FFmpeg-user] copy h264 segment

Wirth, Andreas (SRF) andreas.wirth at srf.ch
Wed Jun 15 16:04:07 CEST 2016


Hi
I try to copy the video and audio stream of a h264/aac encoded file exactly between 2 h264 key frames. My strategy is to first look for the starting key frame using ffprobe. In my case the first frame of

ffprobe -read_intervals 00:19:08%00:19:19 -select_streams v -show_frames file.mp4

gives me the starting key frame at pkt_pts_time=1148.040000 .

Then I try to copy exactly from that key frame to the next one:

ffmpeg -y -ss 1148.040000 -i file.mp4 -t 0 -c copy -avoid_negative_ts 1 out.mp4

What actually happens is that the segment before 1148.040000 is copied to out.mp4.

Am I doing something wrong? I also tried to extract a different segment using the same strategy - that worked correctly.

I’ve tried that with ffmpeg 3.0.2, installed from as a binary on OSX and Debian 8. Same behavior.

Thanks


More information about the ffmpeg-user mailing list