Wednesday, February 13, 2013

Placing logo on video

It's really great to be able to add logo on your video. Here's a simple guide how to do that with ffmpeg and set up nginx-rtmp to add logo automatically.

Here's a simple mychan.png logo with transparent background made in GIMP.
mychan

What we want is to add logo on video that goes through nginx-rtmp. That can be done with the following ffmpeg overlay filter.

movie=/var/pictures/mychan.png[logo];[0][logo]overlay=0:70


Let's create a new application addlogo and add ffmpeg exec line to it. The result is published to myapp.

application myapp {
live on;
}

application addlogo{
live on;
exec ffmpeg -i rtmp://localhost/addlogo/$name
-vf "movie=/var/pictures/mychan.png[logo];[0][logo]overlay=0:70"
-c:v flv -f flv rtmp://localhost/myapp/$name;
}


Now start streaming sintel.

ffmpeg -re -i /var/video/sintel.mp4 -c:v flv -s 800x600 -c:a libfaac -ar 44100 -ac 1
-f flv rtmp://localhost/addlogo/mystream


Here's the result.
logo_on_stream

7 comments:

  1. Am I right to think that the speed of processing in this case, to ffmpg will be approximately equal to the length of the video?

    ReplyDelete
  2. Speed completely depends on ffmpeg. Decoding & encoding is the slowest part of that.

    ReplyDelete
  3. Hi! thank you for your work.

    I've a question : the quality of the video with the logo is lower than without.
    I suppose it's because of the compression, but is there a solution ?

    ReplyDelete
  4. It will always be lower. The solution is to set better h264 encoding options.

    ReplyDelete
  5. LOGO PNG image format is the right choice. Good jpg to png image conversions at jpg4png.com help soft quality images. more optimized <here>

    ReplyDelete
  6. i can add realtime alert from twitch to rtmp app ?

    ReplyDelete