Merge two videos with transparency in ffmpeg

I have two videos merged into one file using below command. Unfortunately second video covers first video and it is not visible. How to make second video transparent (eg. 50%)?

ffmpeg
    -i in1.mp4 -i in2.mp4
    -filter_complex "nullsrc=size=480x360 [base];
        [0:v] setpts=PTS-STARTPTS, scale=480x360 [top];
        [1:v] setpts=PTS-STARTPTS, scale=480x360 [bottom];
        [base][top] overlay=shortest=1 [temp];
        [temp][bottom] overlay=shortest=1"
    -acodec libvo_aacenc -vcodec libx264 out.pm4

Solution 1:

Use

ffmpeg \
    -i in1.mp4 -i in2.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

Set aa to the opacity value needed.