我使用了如下命令:
ffmpeg -i video.avi -i audio.mp3 -vcodec codec -acodec codec output_video.avi -newaudio
在最新版本添加新的音轨到视频(不混合)。
但是我更新了ffmpeg到最新版本(ffmpeg版本git-2012-06-16-809d71d),现在在这个版本中参数-newaudio不起作用。
请告诉我如何添加新的音频到我的视频(不混合)使用ffmpeg。
我使用了如下命令:
ffmpeg -i video.avi -i audio.mp3 -vcodec codec -acodec codec output_video.avi -newaudio
在最新版本添加新的音轨到视频(不混合)。
但是我更新了ffmpeg到最新版本(ffmpeg版本git-2012-06-16-809d71d),现在在这个版本中参数-newaudio不起作用。
请告诉我如何添加新的音频到我的视频(不混合)使用ffmpeg。
当前回答
如果输入视频有多个音轨,你需要再添加一个,然后使用以下命令:
ffmpeg -i input_video_with_audio.avi -i new_audio.ac3 -map 0 -map 1 -codec copy output_video.avi
-map 0表示从第一个输入文件(input_video_with_audio.avi)复制(包括)所有流,-map 1表示从第二个输入文件(new_audio.ac3)复制(包括)所有流(在本例中是一个流)。
其他回答
没有什么对我很有效(我想这是因为我输入的。mp4视频没有任何音频),所以我发现这对我很有效:
Ffmpeg -i input_video.mp4 -i balipraavid .wav -map 0:v:0 -map 1:a:0 output.mp4
取代音频
ffmpeg -i video.mp4 -i audio.wav -map 0:v -map 1:a -c:v copy -shortest output.mp4
The -map option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info. This example uses -c:v copy to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast. If your input audio format is compatible with the output format then change -c:v copy to -c copy to stream copy both the video and audio. If you want to re-encode video and audio then remove -c:v copy / -c copy. The -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
The -map option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info. This example uses -c:v copy to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast. If your input audio format is compatible with the output format then change -c:v copy to -c copy to stream copy both the video and audio. If you want to re-encode video and audio then remove -c:v copy / -c copy. The -shortest option will make the output the same duration as the shortest input.
混合/组合两个音频输入为一个
使用video.mkv中的视频。混合音频和视频。MKV和音频。M4a使用合并滤波器:
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
更多信息请参见FFmpeg Wiki:音频通道。
生成无声音频
你可以使用anullsrc过滤器来制作一个无声的音频流。过滤器允许您选择所需的频道布局(单声道,立体声,5.1等)和采样率。
ffmpeg -i video.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \
-c:v copy -shortest output.mp4
也看到
将两个音频流合并为一个 FFmpeg Wiki:音频通道操作 FFmpeg mux视频和音频从另一个视频
这展示了如何用ffmpeg将所有音轨合并到一个完整的目录:
ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a -c:v copy -shortest output.mp4
Mp3音乐wav
ffmpeg -i music.mp3 music.wav
截断适合视频
ffmpeg -i music.wav -ss 0 -t 37 musicshort.wav
音乐和视频混合
ffmpeg -i musicshort.wav -i movie.avi final_video.avi
如果你正在使用旧版本的FFMPEG,你不能升级,你可以做以下:
ffmpeg -i PATH/VIDEO_FILE_NAME.mp4 -i PATH/AUDIO_FILE_NAME.mp3 -vcodec copy -shortest DESTINATION_PATH/NEW_VIDEO_FILE_NAME.mp4
注意,我使用了-vcodec