0

I am a DirectShow developer, I used to build multiplexers that take 2 video inputs and generate one output, I would then use a video encoder mux to feed it the output + anothrr audio stream to generate the final video output. The multiplexer (DirectShow framework) allows me to process the input video from two sources (for example, adding effects using the two frames). Does anyone know how this can be done using FFMPEG, or at least point me to the right resources? Thanks

Nader
  • 47
  • 1
  • 8
  • I don't understand what you are trying to do. What exactly do you want to do? – llogan Dec 03 '15 at 19:53
  • I want to process two video files, file1 and file2, to produce file3, then I want to add an audio stream to the new file, but, I would like also to have the opportunity to process the video frames coming from file 1 & 2...I can do this easily in DirectShow API, but how to do it using FFMPEG – Nader Dec 04 '15 at 02:23

1 Answers1

1

Since your question is very vague I will provide three "solutions".

Muxing

Muxing streams from various inputs is easy. This example will stream copy all video streams from input0.mkv, all video streams from input1.mp4, and all audio streams from input2.oga. The resulting output file will have at least 2 video streams and at least 1 audio stream. The exact number of streams in the output depends on the number of streams present in the inputs.

ffmpeg -i input0.mkv -i input1.mp4 -i input2.oga -map 0:v -map 1:v -map 2:a -c copy -shortest output.mkv

Also see:

Concatenating

If you want to concatenate the video streams and add an audio stream you can use the concat filter or the concat demuxer. Here's a basic example using the concat filter:

ffmpeg -i video0.webm -i video1.mp4 -i audio.wav -filter_complex \
"[0:v][1:v]concat=n=2:v=1:a=0[v]" -map "[v]" -map 2:a output.mkv

See FFmpeg Wiki: Concatenate for more examples.

Concatenating with additional filtering

ffmpeg -i video0.webm -i video1.mp4 -i audio.wav -filter_complex \
"[0:v]scale=1280:-2,vflip,setpts=PTS-STARTPTS[v0]; \
 [1:v]fps=25,curves=preset=increase_contrast,setpts=PTS-STARTPTS[v1]; \
 [v0][v1]concat=n=2:v=1:a=0[v]" \
-map "[v]" -map 2:a output.mkv
  • The first filterchain will scale, vertically flip, and set timestamp to 0 for the first video input.

  • The second filterchain will set the frame rate to 25, apply curves, and set timestamp to 0 for the second video input.

  • The third filterchain concatenates the filtered videos.

Community
  • 1
  • 1
llogan
  • 121,796
  • 28
  • 232
  • 243