Merge Video and Audio
Sometimes the video and audio you need live in two separate files — for example, replacing a clip's original audio with a different track, or combining a silent screen recording with narration. ffmpeg-studio lets you pull a stream from each file and combine them into one output without hand-writing the FFmpeg mapping flags.
Example
example/merge_streams.py
"""
Example Quick Start to merge video and audio from two files
"""
from ffmpeg.inputs import VideoFile
from ffmpeg import export
# Grab video from File
video_stream = VideoFile("video1.mp4").video
# Grab audio from another File
audio_stream = VideoFile("video2.mp4").audio
# Combine them together and export as mp4
export(
video_stream,
audio_stream,
path="out.mp4",
).run()
This grabs the video stream from video1.mp4 and the audio stream from video2.mp4, then exports both into a single out.mp4.