mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-28 10:13:45 -05:00
1.8 KiB
1.8 KiB
title | date | draft | tags | |
---|---|---|---|---|
Replace Audio in Video | 2020-04-20T20:32:26-04:00 | false |
|
I recorded a video and wanted to touch up my audio in audacity. Here's how I used ffmpeg
to extract the audio, and then replace it with a modified version.
Extract Audio
If you know the format of the audio (mp3, ogg, aac) then it's possible to do a byte copy of the audio track into a file:
ffmpeg -i input_video.mkv -vn -acodec copy output.aac
Argument | Description |
---|---|
-i |
Input |
-vn |
No Video |
-acodec copy |
Copy audio stream directly |
If you don't know the audio codec and have mediainfo
installed, then run
mediainfo --Inform="Audio;%Format%" input_video.mkv
If you gave up, then you can transcode the audio (will take longer than direct copy)
ffmpeg -i input_video.mkv -vn output.aac
Replacing Audio
Once you're done touching up the audio (touchup.mp3
), you'll want to replace the existing audio with it.
ffmpeg -i input_video.mkv \
-i touchup.mp3 \
-c:v copy \
-map 0:v:0 \
-map 1:a:0 \
output_video.mp4
Argument | Description |
---|---|
-i |
Inputs |
-c:v copy |
Make this a copy operation |
-c:v copy -map 0:v:0 |
Map the video from the first input to the first video output |
-map 1:a:0 |
Map the audio from the second input to the first video output |