我正在使用此代码通过ffmpeg
加入mp3文件和视频文件ffmpeg -i /file1.mp3 -ab 128k -i /file2.avi -vcodec copy -f avi /file3.avi
但是这段代码给出了错误
Option ab (audio bitrate (please use -b:a)) cannot be applied to input file /file1.mp3 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for input file /file1.mp3.
Error opening input files: Invalid argument
我该怎么做这个工作?
答案 0 :(得分:0)
尝试: ffmpeg -i file.mp3 -acodec copy -i file.avi -vcodec copy -f avi file2.avi
答案 1 :(得分:0)
ffmpeg -i input.avi -i audio.mp3 -map 0 -map 1:a -c copy -shortest out.avi
此示例将stream copy(重新多路复用),而不是进行任何编码。
-map 0
将映射来自输入" 0
"的所有流,包括任何音频和字幕流。 (input.avi
)到输出。
-map 1:a
将映射来自输入的所有音频流" 1
" (audio.mp3
)到输出。 ffmpeg
将专辑封面视为视频流,因此此选项仅会映射音频。
-shortest
将使输出持续时间与最短输入持续时间相同。
如果您要将input.avi
中的音频替换为audio.mp3
,则一种方法是明确选择所需的流:
ffmpeg -i input.avi -i audio.mp3 -map 0:v -map 1:a -c copy -shortest out.avi
有时您可能想要更改音频格式或降低比特率:
ffmpeg -i input.avi -i audio.flac -map 0 -map 1:a -c copy -c:a libmp3lame -b:a 192k -shortest out.avi