flieks
flieks

Reputation: 191

ffmpeg combine 2 filters (with lavfi, -vf and -complex_filter)

I have 2 working code's but can't combine them (they both work separately).

ffmpeg -i video.mp4 -i audio.mp3 -shortest -t 8 -vf "lutrgb=r=1.5, crop:500:500" output.mp4

ffmpeg -i video.mp4 -f lavfi -i "color=Red:s=1280x720" 
-filter_complex "[0:v]setsar=sar=1/1[s];
[s][1:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]" 
-map [out] -map 0:a output.mp4

the lutrgb will be replaced but the color overlay so we can remove that. endresult will take video, audio, color overlay, crop it to 1:1 and duration length of video.

Thanks Felix

Upvotes: 0

Views: 3692

Answers (1)

aergistal
aergistal

Reputation: 31209

ffmpeg -i video.mp4 -i audio.mp3 -f lavfi -i "color=Red:s=500x500" \
-filter_complex "[0:v]lutrgb=r=1.5,crop=500:500,setsar=sar=1/1[crop];\
[crop][2:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]" \
-map [out] -map 1:a -shortest output.mp4

Use three inputs:

  • video.mp4 --> 0
  • audio.mp3 --> 1
  • lavfi --> 2

Chain the filters:

  • crop, setsar etc. the video stream in the first input and name it [crop]

    [0:v]lutrgb=r=1.5,crop=320:240,setsar=sar=1/1[crop]

  • blend the video stream of the third input with the crop as [out]

    [crop][2:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]

  • finally map the outputs using out as the video stream and the mp3 track as audio

    -map [out] -map 1:a

Upvotes: 4

Related Questions