0

I'm trying to create an MP4 video from two images and two mp3 audio files, this is my command:

ffmpeg -hide_banner -loop 1 -i incoming/img0.jpeg -loop 1 -i incoming/img1.jpeg -i incoming/aud0.mp3 -i incoming/aud1.mp3 -i incoming/watermark.png -filter_complex "[0:v]scale=960:540[v0];[1:v]scale=960:540[v1];[v0]pad=1920:540:(ow-iw)/2:0:0x1E1622[hstack0];[v1]pad=1920:540:(ow-iw)/2:0:0x1E1622[hstack1];[hstack0][hstack1]vstack=inputs=2[out];[out]pad=1920:1080:(ow-iw)/2:(oh-ih)/2:0x1E1622[outw];[outw][4:v]overlay=W-w-32:H-h-32[outv];[2:a]volume=0.5[a0];[3:a]volume=0.8[a1];[a0][a1]amix=inputs=2[outa]" -map "[outv]" -map "[outa]" -shortest -ac 2 -vsync 0 -y outgoing/output.mp4

It's simply take two images, change the resolution, stack them together and mix the audio files together, makes an output called output.mp4

I have two problems:

  1. the process never ends, it goes on even after the two audio files are done playing, even if i use -shortest flag

  2. in my situation i can have two audio files with different length and i want the output to be the length of longest audio files and not the shortest

1 Answer 1

1

what i did eventually is to itterate over all my audio files and check with ffprobe what's the longest audio file that i have and use that to determine the duration of my output video.

this is the ffprobe command to check the duration of a given file:

ffprobe -i <YOUR_FILE_NAME> -show_entries format=duration -v quiet -of csv="p=0"

to set a specific duration for an output file in ffmpeg you can use the -t flag like that:

ffmpeg -i <INPUT_FILE> -t <DURATION_IN_SECONDS> <OUTPUT_FILE_NAME>

You must log in to answer this question.

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