[FFmpeg-user] Combining 2 video/audio webm files into 1 video using timestamps

Randy Johnson randy.johnson at hey.com
Tue Aug 4 14:41:08 EEST 2020

Hello Everyone,

My Goal: I need to take 2 to 4  single channel webm files (video/audio) and combine them into 1 video with audio. Think a zoom meeting with 4 people on the video call each feed being recorded separately and then I need to combine them after the meeting.

What I have so far:

I have used this project:  https://github.com/opentok/archiving-composer

to get started.  This works in that it combines both videos using the timestamps provided into 1 video.  The problem is it doesn't combine / merge both video file's audio tracks in the final generated video.  Only 1 of the video's audio track makes it to the end video.  Specifically the first video's audio.

Here are the ffmpeg commands generated by the above:

ffmpeg -y -threads 8 -loglevel info -ss 71.257 -t 1.959 -i /Users/randy/Downloads/archive23/a920ab58-a42d-49fe-a239-b27497b22bb1.webm -filter_complex "[0]scale=640:-1[b];[b]drawtext=fontsize=30:fontcolor=white:fontfile=/Library/Fonts/Tahoma.ttf:text='USER_ID=113,USER_NAME=Randy Mod,USER_TYPE=moderator,TIMESLOT_END=':x=w/2-text_w/2:y=h-line_h-5" -shortest temp-71257-73216.mp4

ffmpeg -y -threads 8 -loglevel quiet -ss 16.16 -t 55.097 -i /Users/randy/Downloads/archive23/a920ab58-a42d-49fe-a239-b27497b22bb1.webm -ss 0 -t 71.257 -i /Users/randy/Downloads/archive23/823ef68a-cb1c-4636-bdfb-ed3d9611a755.webm -filter_complex "[0]scale=320:-1,pad=2*iw:2*ih:0:120[left];[1]scale=320:-1[right];[left][right]overlay=main_w/2:120,scale=640:480,drawtext=fontsize=30:fontcolor=white:fontfile=/Library/Fonts/Tahoma.ttf:text='USER_ID=113,USER_NAME=Randy Mod,USER_TYPE=moderator,TIMESLOT_END=':x=w/4-text_w/2:y=3*h/4-line_h-5,drawtext=fontsize=30:fontcolor=white:fontfile=/Library/Fonts/Tahoma.ttf:text='USER_ID=173,USER_NAME=Part icipant,USER_TYPE=participant,TIMESLOT_END=':x=3*w/4-text_w/2:y=3*h/4-line_h-5" -shortest temp-16160-71257.mp4

ffmpeg -y -threads 8 -loglevel quiet -ss 71.257 -t 1.959 -i /Users/randy/Downloads/archive23/a920ab58-a42d-49fe-a239-b27497b22bb1.webm -filter_complex "[0]scale=640:-1[b];[b]drawtext=fontsize=30:fontcolor=white:fontfile=/Library/Fonts/Tahoma.ttf:text='USER_ID=113,USER_NAME=Randy Mod,USER_TYPE=moderator,TIMESLOT_END=':x=w/2-text_w/2:y=h-line_h-5" -shortest temp-71257-73216.mp4

ffmpeg -y -threads 8 -loglevel quiet -f concat -i 6cde2f22-5fcc-4227-ae9f-24af806af2d5-list.txt -r 24 6cde2f22-5fcc-4227-ae9f-24af806af2d5.mp4

I then went out and researched and came up with the following code.  This combines both videos and audio but totally ignores the timestamps.  So both videos play at once and the audio plays as well.  


ffmpeg -i /Users/randy/Downloads/archive23/a920ab58-a42d-49fe-a239-b27497b22bb1.mp4 -i /Users/randy/Downloads/archive23/823ef68a-cb1c-4636-bdfb-ed3d9611a755.mp4 -filter_complex \
"[0:v][1:v]hstack=inputs=2[v]; \
 [0:a][1:a]amerge[a]" \
-map "[v]" -map "[a]" -ac 2 -y /Users/randy/Downloads/archive23/output.mp4


My Issue:  I am not sure how to combine the merging of the audio of my second example with the code of the first example that puts the video in the timestamp order.

Any help or advice would be greatly appreciated.

Thank You,


More information about the ffmpeg-user mailing list