我正在尝试从一些Avi视频中提取音轨,并将其保存到自己的文件中,理想情况下无需重新编码。
我在这里https://www.ffmpeg.org/ffmpeg.html#Audio-Options和这里ffmpeg to extract audio from video浏览了一下,尽管无论尝试哪种方法都遇到错误。
我最新的命令字符串是:
ffmpeg -i /home/d/Pictures/Test/input-video.AVI -map 0:a -vn -acodec copy /home/d/Pictures/Test/output-audio.m4a
输出的关键部分是:
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from '/home/d/Pictures/Test/input-video.AVI':
Duration: 00:00:05.94, start: 0.000000, bitrate: 18131 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 17995 kb/s, 30.28 fps, 30.28 tbr, 30.28 tbn, 30.28 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, 1 channels, s16, 176 kb/s
File '/home/d/Pictures/Test/output-audio.m4a' already exists. Overwrite ? [y/N] y
[ipod @ 0x1d89520] Codec for stream 0 does not use global headers but container format requires global headers
[ipod @ 0x1d89520] Could not find tag for codec pcm_s16le in stream #0, codec not currently supported in container
Output #0, ipod, to '/home/d/Pictures/Test/output-audio.m4a':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, mono, 176 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
我相信我从此输出中获得了正确的音频流编号,因此假设“ -map 0:a”部分不是问题。
我正在Linux Mint 18.1上运行
答案 0 :(得分:1)
MP4系列格式不存储PCM音频,因此您必须重新编码或保存为其他格式,例如Matroska。
ffmpeg -i video.AVI -map 0:a -vn -acodec copy audio.mka