0

I have an image named c.png First I convert it to webm with transparency, use command:

ffmpeg -framerate 1/9 -i c.png  -i c.mp3 -c:v libvpx-vp9 -pix_fmt yuva420p -lossless 1 out.webm

Then I want add fade in and fade out to out.webm, but I used many command like this still not working:

ffmpeg  -i out.webm -vf "fade=t=in:st=0:d=3:alpha=1" -c:v libvpx-vp9 -pix_fmt yuv420p -c:a copy out_ok.webm
ffmpeg -i out.webm -vf "fade=in:0:3:alpha=1" out3.webm

ffmpeg -c:v libvpx-vp9 -i out.webm -vf "fade=t=in:st=0:d=3:alpha=1" out_ok.webm

ffmpeg -c:v libvpx-vp9 -i out.webm -filter_complex "fade=t=in:st=0:d=3:alpha=1" -map "[v]" -lossless 1  -b 10M -r 30 all.web

How do I fix that?

Thank you.

Jesusaur
  • 594
  • 3
  • 22
Xiang Chen
  • 31
  • 12

1 Answers1

1

You can do it with 1 command. In this example audio.mp3 is 10 seconds long.

ffmpeg -loop 1 -framerate 15 -i input.png -i audio.mp3 -vf "fade=t=in:d=1:alpha=1,fade=t=out:d=1:st=9:alpha=1" -shortest -fflags +shortest -max_interleave_delta 100M output.webm
  • Your command made an output with only 1 frame of video. Add the -loop option to loop the image.
  • The -shortest -fflags +shortest -max_interleave_delta 100M options (see more info about these options) make the video match the audio duration.
llogan
  • 121,796
  • 28
  • 232
  • 243
  • Thank you for your code, the way you provide can achieve the effect. I made a mistake, I used IINA app to check the webm files, it will not display the fade effect , but the chrome will. – Xiang Chen Aug 10 '21 at 22:41
  • 1
    @XiangChen if this is the solution that works for you, please accept the answer. – Rajib Oct 18 '21 at 06:13