简体   繁体   English

使用ffmpeg从视频文件中提取音频流并输出到单个立体声WAV文件

[英]Using ffmpeg, extract audio streams from video file and output to single stereo wav file

I've been trying for a few hours to get the right arguments to do the below operation with ffmpeg, but i'm a bit out of my depth. 我已经尝试了几个小时,以获取正确的参数来对ffmpeg进行以下操作,但是我有点不尽如人意。 If anyone can give me some guidance, that would be very helpful. 如果有人可以给我一些指导,那将非常有帮助。

Input file is MXF with one video track and two separate 48k 24b PCM audio tracks. 输入文件是MXF,具有一个视频轨道和两个独立的48k 24b PCM音频轨道。 I want to extract just the audio, map first track to left, second track to right and output as a stereo wave file. 我只想提取音频,将第一个音轨映射到左侧,将第二个音轨映射到右侧,并输出为立体声波形文件。

I am trying variations on the below command, but it seems to be unhappy about the video stream, giving the error 我正在尝试以下命令的变体,但它似乎对视频流不满意,从而导致错误

"mapchan: stream #0.0 is not an audio stream." “ mapchan:流#0.0不是音频流。”

ffmpeg -i test2.mxf -vn -map_channel 0.0.1 output.wav_CH0 -map_channel 0.0.2 output.wav_CH1

Here is ffmpeg's analysis of the streams in case it is helpful: 如果有帮助,以下是ffmpeg对流的分析:

    Stream #1:0: Video: mpeg2video (4:2:2), yuv422p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], max. 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Stream #1:1: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #1:2: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #1:3: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #1:4: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #1:5: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #1:6: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #1:7: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #1:8: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s

The filtergraph function seems to do the trick. filtergraph函数似乎可以解决问题。

ffmpeg -i test2.mxf -filter_complex "[0:1:0][0:2:0]amerge=inputs=2[aout]" -map "[aout]" output.wav

The 0:1:0 seems to represent input1 (the -i option), stream1 (the track), channel (left/right if it were stereo). 0:1:0似乎代表输入1( -i选项),流1(轨道),通道(如果是立体声,则为左/右)。 --could be wrong with my interpretation here, but it works nonetheless. -我的解释可能有误,但仍然有效。

ffmpeg documentation and FFmpeg Wiki: Audio Channel Manipulation were very helpful. ffmpeg 文档FFmpeg Wiki:音频通道操作非常有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM