0

I'm trying to use FFMPEG to overlay one video on another. I'm using the following:

ffmpeg \
-i avi1.mp4 -i avi2.mp4 \
-filter_complex " \
    [0:v]setpts=PTS-STARTPTS, scale=480x360[top]; \
    [1:v]setpts=PTS-STARTPTS, scale=480x360, \
         format=yuva420p,colorchannelmixer=aa=0.5[bottom]; \
    [top][bottom]overlay=shortest=1" \
-acodec libvo_aacenc -vcodec libx264 out.mp4

The resulting video seem to have the colours of the original videos washed out.

Here is an image of the two videos before the merge: enter image description here

enter image description here

And here is an image of the output after merging them together:

enter image description here

I'm wondering why the resulting video has the colours altered in this way and how I can merge the two videos together without the colours being altered in this way.

5
  • 1
    The input videos do not have transparency/alpha. When you overlay one on top of another, the white background goes on top with 50% opacity and hides the bottom one 50%.
    – Rajib
    Oct 18, 2021 at 6:48
  • Can I overcome this by having the videos exported with transparency/alpha before layering them together?
    – Kurt
    Oct 18, 2021 at 14:57
  • Absolutely. If this is coming from a 3D application export the frames in 32 bits at least- that is 8 bits per RGB and 8 bits for alpha. Compositing will then be possible. Note that this is the minimum expected. You can increase bit depth etc.
    – Rajib
    Oct 18, 2021 at 15:08
  • I tried again using the same command as above after exporting the videos from Apple ProRes 4444. I can see the backgrounds of each video are transparent but the merged result looks the same as the image above.
    – Kurt
    Oct 18, 2021 at 16:12
  • The complete log is missing from the ffmpeg command, which is needed to answer, but I can see that your ffmpeg must be super old because you're using libvo_aacenc which was removed in 2016. See the FFmpeg Download page for links to compiled ffmpeg for Windows, Linux, and macOS. Upgrade before doing anything else.
    – llogan
    Oct 18, 2021 at 18:02

1 Answer 1

0

If your movies indeed have alpha, you do not need to use colorchannelmixer if you want full transparency. Simply use:

ffmpeg -i movie_for_bottom.mov -i movie_for_top.mov -filter_complex "[0:v]setpts=PTS-STARTPTS, scale=480x360[bottom];[1:v]setpts=PTS-STARTPTS, scale=480x360[top];[bottom][top]overlay=shortest=1" -vcodec libx264 out.mp4

If alpha is present in the movie ffmpeg will use it in overlay filter.

The resultant movie will NOT have alpha(transparency).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .