Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like to get the duration of the base video using ffprobe, then use -stream_loop -1 to loop the overlay video on top of it, while using -t with the duration before the output to ensure it will only be as long as the duration of the base video. Here's an example:

    DURATION="$(ffprobe -i input.mp4 -show_entries format=duration -v quiet -of csv='p=0')"

    ffmpeg -i input.mp4 -stream_loop -1 -i overlay.mp4 -filter_complex "
    [1]colorchannelmixer=aa=0.1[2];[2][0]scale2ref[2][1];[1] 
    [2]overlay" -t $DURATION output.mp4


ffprobe step nor -t needed.

    ffmpeg -i input.mp4 -stream_loop -1 -i overlay.mp4 -filter_complex "
    [1]colorchannelmixer=aa=0.1[2];[2][0]scale2ref[2][1];[1] 
    [2]overlay=shortest=1" -shortest -fflags +shortest -max_interleave_delta 100M output.mp4


Thanks, adding a duration to the CLI args works well.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: