Skip to content

Commit 1711872

Browse files
committed
til: ffmpeg: add 'Merge audio and video files'
Merging audio and video files can be done efficiently using the 'ffmpeg' tool. This TIL provides a clear and concise explanation for how to use the 'ffmpeg' tool to merge a video and an audio file into a single output file. It also contains an example for illustration purposes. Signed-off-by: Stefan Kühnel <[email protected]>
1 parent df97ded commit 1711872

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
+++
2+
title = "Merge audio and video files"
3+
date = 2024-11-23
4+
+++
5+
6+
Merging audio and video files can be done efficiently using the `ffmpeg` tool. This process is often used when video and audio streams are stored in separate files and need to be combined into a single file.
7+
8+
The following `ffmpeg` command demonstrates how to merge a video file with an audio file into a single output file:
9+
10+
```bash
11+
$ ffmpeg -i input_video.mp4 -i input_audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
12+
```
13+
14+
The command contains multiple options:
15+
16+
- `-i input_video.mp4`: Specifies the input video file.
17+
- `-i input_audio.mp3`: Specifies the input audio file.
18+
- `-c:v copy`: Copies the video codec without re-encoding.
19+
- `-c:a aac`: Encodes the audio to AAC format.
20+
- `-map 0:v:0`: Maps the video stream from the first input file.
21+
- `-map 1:a:0`: Maps the audio stream from the second input file.
22+
- `output.mp4`: Name of the output file.
23+
24+
## Bibliography
25+
26+
Bellard, F. (2000). _FFmpeg Documentation_. FFmpeg Project. [https://ffmpeg.org/documentation.html](https://ffmpeg.org/documentation.html)

0 commit comments

Comments
 (0)