<p><code>scale2ref</code> consumes two inputs and then emits them both.. In your command, the output of the reference input isn't provided a label, nor connected elsewhere, nor fed to NULL output, so ffmpeg automatically maps it as output.</p>

<p>Use</p>

<pre><code>ffmpeg -i LOGO.mp4 -i VIDEO.mp4 
       -filter_complex "[1][0]scale2ref=iw/2:-2[scaled][ref]; 
                        [ref][scaled]overlay=x=0:y=0[composite]" 
       -map [composite] 
       -y OUTPUT.mp4
</code></pre>

<p>The ref is now consumed by overlay and isn't left 'dangling' for ffmpeg to map.</p>

<p>As to your general query, just label the output of one overlay and feed it as the input to another, and you can combine them.</p>

CC BY-SA 3.0
2017-10-20T14:46:51.743Z
2017-10-20T14:46:51.743Z
Gyan
<p>I am using ffmpeg to create a composite video with multiple overlays onto a static background. I notice that ffmpeg creates a separate output stream in the output mp4 file for each overlay. Ideally, I would like these to be 'flattened' into a single stream. Is it possible to do this?</p>

<p>Here is simple example of what I mean - in this case I have a background 'logo' video onto which is being overlaid another video which is scaled to be a half the size of the background and is positioned in the top left corner of the output:</p>

<pre><code>ffmpeg -i LOGO.mp4 -i VIDEO.mp4 
       -filter_complex "[1][0]scale2ref=iw/2:-2[scaled]; 
                        [0][scaled]overlay=x=0:y=0[composite]" 
       -map [composite] 
       -y OUTPUT.mp4
</code></pre>

<p>The resulting video has two video streams as shown by the output from ffmpeg:</p>

<pre><code>Output #0, mp4, to 'OUTPUT.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.89.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.89.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
</code></pre>

<ffmpeg>
Can ffmpeg overlays be combined into a single output stream?
Philip Richards
# Can ffmpeg overlays be combined into a single output stream?

(Asked by: username_0 on 2017-10-20)

I am using ffmpeg to create a composite video with multiple overlays onto a static background. I notice that ffmpeg creates a separate output stream in the output mp4 file for each overlay. Ideally, I would like these to be 'flattened' into a single stream. Is it possible to do this?
Here is simple example of what I mean - in this case I have a background 'logo' video onto which is being overlaid another video which is scaled to be a half the size of the background and is positioned in the top left corner of the output:
ffmpeg -i LOGO.mp4 -i VIDEO.mp4 
       -filter_complex "[1][0]scale2ref=iw/2:-2[scaled]; 
                        [0][scaled]overlay=x=0:y=0[composite]" 
       -map [composite] 
       -y OUTPUT.mp4

The resulting video has two video streams as shown by the output from ffmpeg:
Output #0, mp4, to 'OUTPUT.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.89.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.89.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2017-10-20. Score: 1 | Accepted answer

scale2ref consumes two inputs and then emits them both.. In your command, the output of the reference input isn't provided a label, nor connected elsewhere, nor fed to NULL output, so ffmpeg automatically maps it as output.
Use
ffmpeg -i LOGO.mp4 -i VIDEO.mp4 
       -filter_complex "[1][0]scale2ref=iw/2:-2[scaled][ref]; 
                        [ref][scaled]overlay=x=0:y=0[composite]" 
       -map [composite] 
       -y OUTPUT.mp4

The ref is now consumed by overlay and isn't left 'dangling' for ffmpeg to map.
As to your general query, just label the output of one overlay and feed it as the input to another, and you can combine them.


---

