1

I started to learn FFmpeg syntax a couple of days ago.
I'm trying to read the official docs, it's not easy.

So I want to build up a video files which consists of different videos, and audios. Let's say I have files below.

Video files:

  • a.mp4

  • b.mkv

Audio files:

  • x.wma

  • y.mp3

  • z.mp3

I'd like to use specific parts of audio files.
Let's say,

  • 2s ~ 24 sec from x.wma
  • 1m 22s ~ 1m 41s from y.mp3
  • 29s ~ 2m 33s from z.mp3

Concatenate the selected audio streams into an audio stream.

I'll take the video stream of 2m ~ 2m 32s from a.mp4.

Then video stream is a lot shorter than audio.
(I don't know how much exactly, hopefully FFmpeg can do that for me)

Can FFmpeg do any of the below?

  1. Take the video streams from b.mkv and concatenate it with the video streams from a.mp4, so that resulted video stream is as long as the audio. After that mux the audio and video.
  2. Change the duration of the video stream from a.mp4 so that duration of the video and audio are equal.(by changing playback speed of video stream) then mux the audio and video.

  3. Just insert an image file after video streams ends while audio is being played.

P.S.: I tried to express things clearly, but I'm not so good at English. If there is anything you can't understand clearly, please tell me.

4
  • "Can FFmpeg do any of the below?" Yes. Which method do you prefer? I will give an example for one.
    – llogan
    Commented Jan 9, 2020 at 20:07
  • so, FFmpeg can do all of them? Wow that's great! I prefer first method.
    – helming
    Commented Jan 10, 2020 at 4:50
  • Show the complete output of ffmpeg -i a.mp4 -i b.mkv -i x.wma -i y.mp3 -i z.mp3
    – llogan
    Commented Jan 10, 2020 at 19:25
  • Uploaded the output at pastebin.com/ABF5nFJR
    – helming
    Commented Jan 11, 2020 at 1:55

1 Answer 1

0

Use the concat filter:

ffmpeg -y -i a.mp4 -ss 2 -t 22 -i x.wma -ss 00:01:22 -t 19 -i y.mp3 -ss 29 -t 124 -i z.mp3 -filter_complex "[1:a][2:a][3:a]concat=n=3:v=0:a=1[a]" -map 0:v -map "[a]" -shortest output.mp4

Alternatively, instead of -ss/-t you can use the atrim and asetpts filters.

3
  • Is this a command for the first method? It doesn't seem to use b.mkv at all. But I think i get what you were trying to explain. Thank you Ilogan!
    – helming
    Commented Jan 19, 2020 at 8:52
  • @helming b.mkv was not used because the sum of the audio durations was shorter than the duration of a.mp4.
    – llogan
    Commented Jan 21, 2020 at 22:43
  • @llogan, Any chance you have a look at video.stackexchange.com/questions/35053?
    – Royi
    Commented Mar 6, 2022 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.