ffmpeg `-ss` with `-frame_pts true` give wrong pts for file name
when I put -ss in front of -i then the frame’s pts expand correct
ffmpeg -ss 674 -i input.ts -vf "select=not(mod(n\,1)),setpts=PTS+674/TB" -vsync vfr -frame_pts true -r 1000 -vframes 40 /tmp/out_frames/frame_%08d.png
the file name has some offset:
frame_00675000.png
frame_00675033.png
frame_00675067.png
frame_00675100.png
...
however, if I put -ss after -i I suppose it means it will keep decoding and ditch packets until the point that the start time reached, it will start to encode.
I guess in this case the packet’s PTS will not actually change, so in theory I do not need to add any offset by setpts:
ffmpeg -i input.ts -ss 674 -vf "select=not(mod(n\,1))" -vsync vfr -frame_pts true -r 1000 -vframes 40 /tmp/out_frames/frame_%08d.png
The resulting frame is actually correct, but the frame name start from 0, which is strange.
If I add the setpts the frame is completly wrong, because it think the first frame is already offset to 674.
ffmpeg -i input.ts -ss 674 -vf "select=not(mod(n\,1)),setpts=PTS+674/TB" -vsync vfr -frame_pts true -r 1000 -vframes 40 /tmp/out_frames/frame_%08d.png
I wonder what is the correct way to do this? the result confused me a lot:
- if -vf take effect before the
-sswaiting logic then the -ss should not really change the PTS - if the -vf take effect after the
-ssthe waiting logic should not be affect thesetpts
but apparently both command failed to get correct result.
Read more here: Source link
