<p>The overlay filter is set to end with the shortest input, which here is the intro. So, the video output stops generating after that, so a typical video player holds the visual on the last frame.</p>

<p>Also, if your intro already has transparency, you can skip the format and ccm filters. In the command you took them from, the inputs did not have transparency in the source. </p>

<p>(Unless you are resizing the videos, you can skip the scale as well.)</p>

<p>Use</p>

<pre><code>ffmpeg \
    -i main-video.mp4 -i intro.avi \
    -filter_complex " \
        [0:v]setpts=PTS-STARTPTS,scale=2550x1080[top]; \
        [1:v]setpts=PTS-STARTPTS,scale=1920x1080[bottom]; \
        [top][bottom]overlay=x=(W-w)/2:eof_action=pass" \
    -acodec aac -vcodec libx264 out.mp4
</code></pre>

CC BY-SA 3.0
2016-10-10T02:00:48.647Z
2016-10-10T02:00:48.647Z
Gyan
<p>I'm trying to add a video intro to my main video. I have the following:</p>

<pre><code>ffmpeg \
    -i main-video.mp4 -i intro.avi \
    -filter_complex " \
        [0:v]setpts=PTS-STARTPTS, scale=2550x1080[top]; \
        [1:v]setpts=PTS-STARTPTS, scale=1920x1080, \
             format=yuva420p,colorchannelmixer=aa=1[bottom]; \
        [top][bottom]overlay=shortest=1" \
    -acodec libvo_aacenc -vcodec libx264 out.mp4
</code></pre>

<p>main-video.mp4 -> 2250 x 1080</p>

<p>intro.avi -> 1920x1080</p>

<p>I have 2 problems with the above;</p>

<ol>
<li><p>After the intro overlay has finished the main video pauses, however the main video audio continues for the correct duration of the main video (with a paused video frame the entire time)</p></li>
<li><p>The intro video overlay is left aligned, ideally I'd like it to be centered, either through auto calculations based on the 2 resolutions, or by nudging the x/y manually </p></li>
</ol>

<video><ffmpeg>
Overlaying transparent video onto base video with custom positioning
Titan
# Overlaying transparent video onto base video with custom positioning

(Asked by: username_0 on 2016-10-09)

I'm trying to add a video intro to my main video. I have the following:
ffmpeg \
    -i main-video.mp4 -i intro.avi \
    -filter_complex " \
        [0:v]setpts=PTS-STARTPTS, scale=2550x1080[top]; \
        [1:v]setpts=PTS-STARTPTS, scale=1920x1080, \
             format=yuva420p,colorchannelmixer=aa=1[bottom]; \
        [top][bottom]overlay=shortest=1" \
    -acodec libvo_aacenc -vcodec libx264 out.mp4

main-video.mp4 -> 2250 x 1080
intro.avi -> 1920x1080
I have 2 problems with the above;

After the intro overlay has finished the main video pauses, however the main video audio continues for the correct duration of the main video (with a paused video frame the entire time)
The intro video overlay is left aligned, ideally I'd like it to be centered, either through auto calculations based on the 2 resolutions, or by nudging the x/y manually

**Tags:** video, ffmpeg


---

## 1 answers

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

The overlay filter is set to end with the shortest input, which here is the intro. So, the video output stops generating after that, so a typical video player holds the visual on the last frame.
Also, if your intro already has transparency, you can skip the format and ccm filters. In the command you took them from, the inputs did not have transparency in the source. 
(Unless you are resizing the videos, you can skip the scale as well.)
Use
ffmpeg \
    -i main-video.mp4 -i intro.avi \
    -filter_complex " \
        [0:v]setpts=PTS-STARTPTS,scale=2550x1080[top]; \
        [1:v]setpts=PTS-STARTPTS,scale=1920x1080[bottom]; \
        [top][bottom]overlay=x=(W-w)/2:eof_action=pass" \
    -acodec aac -vcodec libx264 out.mp4


---

