ffmpegcss-animations

ffmpeg invalid pts <= last "Error submitting frame to the encoder"


I'm using this command to extract keyframes from long videos (full movies).

ffmpeg -i data/full_videos/pleasantville_1998.mp4 -filter:v "select='gt(scene,0.1)',showinfo" -vsync 0 frames/%05d.jpg

For most videos this works fine, and it prints a line to stderr for each frame extracted, but sometimes it prints a couple of such lines and then errors with the output

[mjpeg @ 0x6492f1e8a3c0] Invalid pts (3883) <= last (3883)                               
[vost#0:0/mjpeg @ 0x6492f213e6c0] Error submitting video frame to the encoder                                                                                                                 
[vost#0:0/mjpeg @ 0x6492f213e6c0] Error encoding a frame: Operation not permitted                                                                                                             
[vost#0:0/mjpeg @ 0x6492f213e6c0] Task finished with error code: -1 (Operation not permitted)                                                                                                 
[vost#0:0/mjpeg @ 0x6492f213e6c0] Terminating thread with return code -1 (Operation not permitted)                                                                                            
[out#0/image2 @ 0x6492f1fc1340] video:1898KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown                                                        frame=   47 fps=9.7 q=24.8 Lsize=N/A time=00:02:41.99 bitrate=N/A speed=33.5x        
Conversion failed! 

I can't see anything wrong with the failed videos when I watch them manually. From searching online, I've gained some understanding of how the encoding/decoding process works in general, but haven't seen anything about this error.

If there's some part of the video that's corrupted, I'd like to just skip over the section around that part and take all possible keyframes from the other sections.


Solution

  • This can happen when the output time base is not as fine as the source TB and some frame timestamps are close enough that they get collapsed to the same output timestamp.

    Use the setpts filter to assign unique timestamps.

    -filter:v "select='gt(scene,0.1)',showinfo,setpts=N/FR/TB"