0

I'm successfully streaming silent video with music added from my Raspberry Pi (Raspbian) to YouTube via ffmpeg, with the help of this GitHub gist and this post:

raspivid -o - -t 0 -vf -hf -w 1280 -h 720 -fps 25 -b 4000000 | \
ffmpeg -i music.wav \
-f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental \
-f flv rtmp://a.rtmp.youtube.com/live2/STREAMKEY

The last step of my project to add a transparent, full width/height png overlay to the video (1280x720 size in my case). I've seen a few related answers such as this one and this one.

With the added complexity of piping in a camera feed, mixing in an audio source and outputting to a video stream, I haven't succeeded in adding the image overlay. Where/how would I add a transparent image overlay in the example above?

Christopher Stevens
  • 1,214
  • 17
  • 32

1 Answers1

1

The ffmpeg part will be

ffmpeg -i music.wav \
-f h264 -i - -i overlay.png
-filter_complex "[1][2]overlay"
-vcodec libx264 -preset ultrafast -tune zerolatency -acodec aac -ab 128k -g 50 -strict experimental \
-f flv rtmp://a.rtmp.youtube.com/live2/STREAMKEY

Since you're altering the video contents, copy can't be used, and the video has to be re-encoded.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • 1
    @ChristopherStevens You won't need `-strict experimental` unless your ffmpeg is quite old, and for streaming I recommend [adding `-maxrate`, `-bufsize`, and optionally `-b:v`](https://trac.ffmpeg.org/wiki/EncodingForStreamingSites). – llogan Jan 05 '18 at 18:22
  • @LordNeckbeard Thank you for the additional thoughts. With those suggested edits, all is working well. Your link was very helpful. – Christopher Stevens Jan 06 '18 at 22:20