I used a command like:
ffmpeg -i video.avi -i audio.mp3 -vcodec codec -acodec codec output_video.avi -newaudio
in latest version for adding new audio track to video (not mix).
But I updated the ffmpeg to the newest version (ffmpeg version git-2012-06-16-809d71d) and now in this version the parameter -newaudio
doesn't work.
Tell me please how I can add new audio to my video (not mix) using ffmpeg
.
ffmpeg -i video.mp4 -i audio.wav -map 0:v -map 1:a -c:v copy -shortest output.mp4
-map
option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info.-c:v copy
to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast.
-c:v copy
to -c copy
to stream copy both the video and audio.-c:v copy
/ -c copy
.-shortest
option will make the output the same duration as the shortest input.ffmpeg -i video.mkv -i audio.mp3 -map 0 -map 1:a -c:v copy -shortest output.mkv
-map
option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info.-c:v copy
to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast.
-c:v copy
to -c copy
to stream copy both the video and audio.-c:v copy
/ -c copy
.-shortest
option will make the output the same duration as the shortest input.Use video from video.mkv
. Mix audio from video.mkv
and audio.m4a
using the amerge filter:
ffmpeg -i video.mkv -i audio.m4a -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map 0:v -map "[a]" -c:v copy -ac 2 -shortest output.mkv
See FFmpeg Wiki: Audio Channels for more info.
You can use the anullsrc filter to make a silent audio stream. The filter allows you to choose the desired channel layout (mono, stereo, 5.1, etc) and the sample rate.
ffmpeg -i video.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \
-c:v copy -shortest output.mp4