I have a video file, say it's called video.mp4. The video has its own audio. I also have an audio file, say audio.aac, shorter in length than the video.
I want to use ffmpeg to overwrite the audio of video.mp4 with the audio from audio.aac. But since the audio.aac is shorter than video.mp4, after it ends I want the original audio the video had to continue (not from the beginning of course, I don't want to shift it).
Preferably without reencoding.
EDIT: video.mp4 and audio.aac are not files I have. I want to make a script that can work with any input files. Here are some scripts I currently have:
I can extract the audio from the video like this:
ffmpeg -i $1 -vn -acodec copy $2
I can replace the audio on a video with one from another file like this (keeping shortest length):
ffmpeg -i "$1" -i "$2" -vcodec copy -acodec copy -shortest -map 0:v -map 1:a "$3"
I can replace the audio on a video with one from another file like this (without keeping shortest length):
ffmpeg -i "$1" -i "$2" -vcodec copy -acodec copy -map 0:v -map 1:a "$3"
I can trim a video like this (I know it may not be very accurate without reencoding but works for me):
ffmpeg -ss "$1" -i "$2" -ss 0 -c copy -to "$3" -avoid_negative_ts make_zero "$4"
I want to do something like the third script but instead of silence after the audio ends, I want the original audio of the video.
ffmpeg -n -i video.mp4 -i audio.aac
. It will provide useful info about the inputs and yourffmpeg
version. This info is required to provide an answer that you can copy and paste. Copy the complete log from that command. Edit your question and paste the complete log into your question. Ignore theAt least one output file must be specified error
in the log.