Following up on this question: I have a relatively complex script that takes a video (mid.mov), overlays a set of images on top of it, and crossfades an intro (intro.mov) and outro (outro.mov) video to its endpoints:


ffmpeg -i "intro.mov" -i "mid.mov" -i "outro.mov" -loop 1 -i "animation/middle_%2d.png" -filter_complex \
"[0:v]trim=0:$introStartFade,setpts=PTS-STARTPTS[introvideo1]; \
[0:v]trim=$introStartFade,setpts=PTS-STARTPTS[introvideo2]; \
[1:v]trim=0:$crossfadeDuration,setpts=PTS-STARTPTS[midvideo1]; \
[1:v]trim=$crossfadeDuration:$midStartFade,setpts=PTS-STARTPTS[midvideo2]; \
[1:v]trim=$midStartFade:,setpts=PTS-STARTPTS[midvideo3]; \
[2:v]trim=0:$crossfadeDuration,setpts=PTS-STARTPTS[outrovideo1]; \
[2:v]trim=$crossfadeDuration:,setpts=PTS-STARTPTS[outrovideo2]; \
[3:v]setpts=1.0*PTS[midAnimation]; \

[introvideo2]format=pix_fmts=yuva420p,fade=t=out:st=0:d=$crossfadeDuration:alpha=1[fadeoutintrovideo]; \
[midvideo1]format=pix_fmts=yuva420p,fade=t=in:st=0:d=$crossfadeDuration:alpha=1[fadeinmidvideo]; \
[midvideo3]format=pix_fmts=yuva420p,fade=t=out:st=0:d=$crossfadeDuration:alpha=1[fadeoutmidvideo]; \
[outrovideo1]format=pix_fmts=yuva420p,fade=t=in:st=0:d=$crossfadeDuration:alpha=1[fadeinextrovideo]; \

[midvideo2][midAnimation]overlay=shortest=1[midvideo]; \

[fadeoutintrovideo][fadeinmidvideo]overlay[crossfadeintrovideo]; \
[fadeoutmidvideo][fadeinextrovideo]overlay[crossfadeoutrovideo]; \
[introvideo1][crossfadeintrovideo][midvideo][crossfadeoutrovideo][outrovideo2]concat=n=5[outputvideo]; \

[0:a][1:a] acrossfade=d=$crossfadeDuration:c1=ipar:c2=ipar [audiotemp]; \
[audiotemp][2:a] acrossfade=d=$crossfadeDuration:c1=ipar:c2=ipar [outputaudio]" \
-map [outputvideo] -map [outputaudio] "out.mov"

Using the latest build (FFmpeg 3.3.3 "Hilbert"), the script gets to a certain point, I get an "Error while filtering" message (in bright red), and then it hangs on the last frame (I need to "ctrl-c" a few times to exit).

If I remove this line it works fine:


I've tried a more recent build (ffmpeg-86877-g8e275a7), but it still hangs at the same point.

If I go back to earlier versions (I've tried up to FFmpeg 3.2.7 "Hypatia"), it works fine. Is there a script problem, or is it a bug introduced into FFmpeg?


It's not a script problem. There was a commit added in Dec 2016 that broke the operation of shortest=1 in some filters. That commit was reverted in June but that introduced side-effects, so the revert commit was reverted in July.

If you need shortest, then you'll need to use the old version for now. There is a fix in queue but no ETA on its application.

| improve this answer | |
  • Just for the record, I am facing the same problem with v3.3.5. Unfortunately I cannot go back before v3.3.3 because of features needed by my project. Feeling deadlocked. – Eric Platon Jan 10 '18 at 5:42
  • What's your command? (And have you tried the latest git?) – Gyan Jan 10 '18 at 5:46
  • The command is long. It includes shortest=1. I did not try any version beyond 3.3.5, as this is a requirement for the project (not free to change). The long command: ffmpeg -y -i original.mp4 -f lavfi -i color=c=black:s=960x540 -filter_complex "[0:v]scale=-1:540[scaled],[1:v][scaled]overlay=shortest=1:x=(main_w-w)/2:eof_action=endall,format=yuv420p[vid],[vid]drawtext=fix_bounds=true:text='This is a comment':font=bold:x=(w-text_w)/2:y=h-(text_h*1)-40:bordercolor=black@0.25:borderw=7[out],[0:a]anull[audio]" -map "[out]" -map "[audio]" test.mp4 – Eric Platon Jan 10 '18 at 5:49
  • 1
    You shouldn't need shortest in that. And there's an alternate way to achieve the end result. Hold on. – Gyan Jan 10 '18 at 5:54
  • Should this be a different question? – Eric Platon Jan 10 '18 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.