I have a online video editor. And i want fast strip and concat mp4 files. For this i use code like this:
For get keyframes:
exe_ffprobe("-select_streams v -skip_frame nokey -show_frames -show_entries frame=pkt_pts_time,pict_type $input_file");
Sample Result:
array (
0 => '0.083417',
1 => '2.085419',
2 => '4.170838',
...
12 => '24.149149',
13 => '26.234568',
14 => '27.569236', < Why ffmpeg missed this keyframe?
15 => '29.654655',
...
230 => '466.966967',
231 => '469.052386',
232 => '471.137804',
233 => '473.223223',
234 => '475.308642',
235 => '477.394061',
236 => '479.479479',
)
...
For split video:
exe_ffmpeg("-y -i $input_file -c copy -map 0 -segment_list segments.csv -f segment -reset_timestamps 1 path/to/%d.mp4");
Sample result:
0.mp4,0.000000
1.mp4,2.085419
2.mp4,4.170838
...
12.mp4,24.149149
13.mp4,26.234568
14.mp4,29.654655
15.mp4,31.740073
...
230.mp4,475.308642
231.mp4,477.394061
232.mp4,479.479479
end
But count of keyframes from ffprobe, and count splitted videos are different.
So how i can segment or get keyframes correctly, to match the count
Also, keyframes and segments.csv are differently too, but more of keyframes has correct timestamps