shaka-project / shaka-streamer

A simple config-file based approach to preparing streaming media, based on FFmpeg and Shaka Packager.
https://shaka-project.github.io/shaka-streamer/
Apache License 2.0
202 stars 64 forks source link

Add support for -filter_complex and/or logo overlay #26

Open Angels-group opened 5 years ago

Angels-group commented 5 years ago

Feature Request: ffmpeg supports source overlay. It would be very nice to add this feature to Shaka-streamer. This is very convenient for organizing branded broadcasting of a video stream (TV channel, presentation, broadcast of events, and so on)

Example:

ffmpeg -i video.mp4 -i logo.png \
-filter_complex "[0:v][1:v] overlay=64:64:enable='between(t,0,20)'" \
-pix_fmt yuv420p -c:a copy \
result.mp4

overlay=64:64 - means that we want to place the logo with a shift of 64px to the right and with a shift of 64px down, relative to the upper left corner (0:0)

enable='between(t,0,20)' - means we want to overlay the logo in the range from 0 to 20 seconds

[0:v][1:v] - means layer order. The first layer (0: v) is video.mp4, the next (1: v) is logo.png

I understand that this is not paramount. But it would be very good to have such an option in the future :)

joeyparrish commented 5 years ago

Thanks for the request!

We already have a feature where you can specify FFmpeg filters, but nothing yet that would allow -filter_complex with an image as input. We'll give some thought to how this would be specified in a config file. We didn't plan for -filter_complex in general.

Angels-group commented 5 years ago

but nothing yet that would allow -filter_complex with an image as input

I imagined that this could be done inside input_xxx_config.yaml In the inputs section.

Something like:

- name: logo.png
    media_type: overlay
    position_x: 64
    position_y: 64
    start_time: 00:00:00
    end_time: 00:20:00
    z_index: 1
joeyparrish commented 5 years ago

Yes, that could work. If we support overlays specifically, we could do something targeted like that.

If we don't find any other compelling use-cases for -filter_complex, then we might choose to support overlays directly as you suggested.

gdub01 commented 4 years ago

One more filter complex use case is burning in subtitles as an overlay on the video. ie. -filter_complex "[0:v][0:s]overlay[v]" -map "[v]" -filter_complex "[0:v][0:s]overlay" https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo