用 ffmpeg -vn 从视频中提取音轨
用 ffmpeg 的流拷贝功能,瞬间无损地把视频里的声音单独存成音频文件。
运行 ffmpeg -i movie.mp4 -vn -c:a copy audio.m4a,即可把视频中的音频无损提取为独立的 .m4a 文件。
01命令
命令
$ ffmpeg -i movie.mp4 -vn -c:a copy audio.m4a02作用说明
-vn 让 ffmpeg 完全丢弃视频流,-c:a copy 则把原有音轨逐字节复制到新文件中,因此提取速度接近拷贝文件,音质零损失。扩展名要与源音频匹配:手机或相机视频多为 AAC 音频,用 .m4a;如确实需要 MP3,可加 -c:a libmp3lame 并输出 .mp3。如果拷贝时报容器错误,说明编码与扩展名不匹配——改用 -c:a aac 重新编码即可。
03风险
!注意: 流拷贝虽然无损但不灵活——如果源音频是播放器不支持的编码,请重新编码(如 -c:a aac),而不是直接改文件扩展名。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- ffmpeg Documentation依据: The documentation states that '-vn / -an / -sn / -dn options can be used to skip inclusion of video, audio, subtitle and data streams respectively' and documents -c:a as the per-stream audio codec option, which with copy reuses the existing audio stream.
- FFmpeg FAQ依据: The FAQ mentions -vn as the option that drops video when producing an audio-only output file.
最后验证: 2026-09-19 · 分类: 媒体