Search code examples
pythonvideoffmpegconcatenationframes

ffmpeg video length is 0 when concatenating pictures


I'm trying to concatenate individual frames, but the video length is 0 and all frames seemingly play at once. Iv'e tried increasing the video length in ffmpeg and changing the frame rate.

os.system('ffmpeg -f concat -i List_tb.txt -c copy output.mp4')
os.system("ffmpeg -i output.mp4 -filter:v fps=fps=120 output_temp.mp4")
os.system("ffmpeg -i output_temp.mp4 -filter:v setpts=8.0*PTS final.mp4")

also the frame rate is the amount of frames


Solution

  • Since images don't have inherent timestamps, the concat demuxer is failing to generate a smooth monotonic sequence of timestamps for the packets it generates. You can work around this by specifying a duration directive for each file, within the list i.e.

    file '-1.1257558476894771_10_1_0j.png'
    duration 0.04
    file '-0.8103308013367797_10_1_0j.png'
    duration 0.04
    file '1.0805993584315776_10_1_0j.png'
    duration 0.04
    ...
    

    where 0.04 is the duration in seconds for one frame at 25 fps.