Getting extremely long video output when using ffmpeg

You need to include -fix_sub_duration before specifying the input file:

ffmpeg -fix_sub_duration -i input.mkv # ...etc., etc.

It seems that this causes ffmpeg to take stock of the loose approach to specifying subtitle durations with picture-based subtitles, and in doing so avoid extending a video unnecessarily, potentially for hundreds of hours.

See the official ffmpeg documentation .

5.10 Advanced Subtitle options

-fix_sub_duration

    Fix subtitles durations. For each subtitle, wait for the next packet in the  
    same stream and adjust the duration of the first to avoid overlap. This is   
    necessary with some subtitles codecs, especially DVB subtitles, because the  
    duration in the original packet is only a rough estimate and the end is  
    actually marked by an empty subtitle frame. Failing to use this option when   
    necessary can result in exaggerated durations or muxing failures due to   
    non-monotonic timestamps.

    Note that this option will delay the output of all data until the next 
    subtitle packet is decoded: it may increase memory consumption and latency a 
    lot.

Read more here: Source link