2

I'm busting my head against the wall trying to add a splash screen. Here's what I'm doing:

  1. Convert the still image to "ts" file with silenced audio stream

ffmpeg -loop 1 -i image.png -c:v libx264 -t 10 -c:a libvo_aacenc -b:a 160k -bsf:v h264_mp4toannexb -f mpegts -crf 32 image.ts

  1. Now, take the original video and convert it to "ts" file too

ffmpeg -i video.mp4 -c:v libx264 -c:a aac -b:a 160k -bsf:v h264_mp4toannexb -f mpegts -crf 32 video.ts

  1. Now, combine the 2 "ts" files

ffmpeg -i "concat:image.ts|video.ts" -c:v libx264 -c:a aac -b:a 160k -bsf:v -y output.mp4

Problems:

  1. The output file is generated just fine, but audio is totally missing. The "output.mp4" video generated in step # 3 actually has an audio track, but splash screen video has silenced audio.

  2. I'm also not able to add a transition. I have researched much on that but unable to add it, please help in that.

I would really appreciate your thoughts! Thank you

Solat Ali
  • 39
  • 1
  • 6
  • Correction: "video.ts" actually has audio track, I mistakenly wrote Step # 3 generated video had audio track, I meant to say Step # 2. But still, main problem remains. The final "output.mp4" should not be completely silent – Solat Ali Aug 19 '20 at 07:22

1 Answers1

2

When using concat protocol or demuxer, all files must contain corresponding streams. In this case, your splash file has no audio. Let's add one.

ffmpeg -loop 1 -i image.png -f lavfi -i anullsrc -t 10 -pix_fmt yuv420p -c:v libx264 -crf 32 -ac 2 -ar 48000 -c:a aac -b:a 160k -f mpegts image.ts

ffmpeg -i video.mp4 -pix_fmt yuv420p -c:v libx264 -crf 32 -ac 2 -ar 48000 -c:a aac -b:a 160k -f mpegts video.ts

ffmpeg -i "concat:image.ts|video.ts" -c copy output.mp4

(If libvo_aacenc worked for you, then your ffmpeg is too old. Support for it was removed a few years ago. Upgrade to v4.3)


If you want the splash image to fade out, change to

ffmpeg -loop 1 -i image.png -f lavfi -i anullsrc -t 10 -vf "fade=out:st=9:d=1" -c:v libx264 -pix_fmt yuv420p -crf 32 -ac 2 -ar 48000 -c:a aac -b:a 160k -f mpegts image.ts

This will fade out the splash image from time range 9 to 10 seconds.

(ote: I've added the pix_fmt option to make sure the output is widely compatible)

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Thank you, works! 1 more quick question. How do I add a "fade" animation on the splash screen? I want it to stay for "x" amount of seconds and then fade out.. Any help in that please? – Solat Ali Aug 20 '20 at 11:16
  • 1 more thing sir. I have added another "ffmpeg" question, please check, maybe you can help out in that one too? Thank you so much! https://stackoverflow.com/questions/63504566/ffmpeg-does-not-produce-result-with-c-sharp-process – Solat Ali Aug 20 '20 at 11:59