FFmpeg-两个文件mix重采样以那个为主

bash 复制代码
ffmpeg -i 2ch-44.1k.wav -i 2ch-16k.wav -filter_complex " \
[0:a][1:a]amix=inputs=2[aout]" \
-map [aout] -f null -
bash 复制代码
ffmpeg -i 2ch-44.1k.wav -i 2ch-16k.wav -filter_complex " \
[0:a][1:a]amix=inputs=2[aout]" \
-map [aout] -f null -

对比发现,这个和-i参数后面的次序有关,默认会选用第一个的samplerate作为输出的samplerate

使用astreamselect:

bash 复制代码
ffmpeg -i 2ch-44.1k.wav  -i 2ch-16k.wav -filter_complex " \
[0:a][1:a]astreamselect=inputs=2:map=0[aout]" \
-map [aout] -f null - -v 48

输出steamselect的log:

css 复制代码
[Parsed_astreamselect_0 @ 0x56243c0c0300] Setting 'inputs' to value '2'
[Parsed_astreamselect_0 @ 0x56243c0c0300] Setting 'map' to value '0'
[Parsed_astreamselect_0 @ 0x56243c0c0300] Add in pad input0
[Parsed_astreamselect_0 @ 0x56243c0c0300] Add in pad input1
[Parsed_astreamselect_0 @ 0x56243c0c0300] Add out pad output0
[Parsed_astreamselect_0 @ 0x56243c0c0300] Configured with 2 inpad and 1 outpad
bash 复制代码
ffmpeg -i 2ch-44.1k.wav  -i 2ch-16k.wav -filter_complex " \
[0:a][1:a]astreamselect=inputs=2:map=0 1[a1][a2], \
[a1][a2]amix=inputs=2[aout]" \
-map [aout] -f null -

TODO

Assertion parent->nb_outputs == 1 failed at src/libavfilter/framesync.c:89

这样用会报错,原因是astreamselect输出只有一路?

从log看,有两路输出:

css 复制代码
[Parsed_astreamselect_0 @ 0x5613513252c0] Setting 'inputs' to value '2'
[Parsed_astreamselect_0 @ 0x5613513252c0] Setting 'map' to value '0 1'
[Parsed_astreamselect_0 @ 0x5613513252c0] Add in pad input0
[Parsed_astreamselect_0 @ 0x5613513252c0] Add in pad input1
[Parsed_astreamselect_0 @ 0x5613513252c0] Add out pad output0
[Parsed_astreamselect_0 @ 0x5613513252c0] Add out pad output1
[Parsed_astreamselect_0 @ 0x5613513252c0] Configured with 2 inpad and 2 outpad
[Parsed_astreamselect_0 @ 0x5613513252c0] n=0 map=0x5613513298a0 p=0x5613513298a1
[Parsed_astreamselect_0 @ 0x5613513252c0] Map input stream 0 to output stream 0
[Parsed_astreamselect_0 @ 0x5613513252c0] n=1 map=0x5613513298a1 p=0x5613513298a3
[Parsed_astreamselect_0 @ 0x5613513252c0] Map input stream 1 to output stream 1
[Parsed_astreamselect_0 @ 0x5613513252c0] n=0 map=0x5613513298a3 p=0x5613513298a3

指定采样率,前面的amix前还是会插入auto_resampler做重采样:

bash 复制代码
ffmpeg -i 2ch-44.1k.wav -i 2ch-16k.wav -filter_complex " \
[0:a][1:a]amix=inputs=2[aout]" -map [aout] -ar 8000 -f null - -v 48

log:

css 复制代码
[auto_resampler_0 @ 0x55aed2e8c940] [SWR @ 0x55aed2e8ce00] Using s16p internally between filters
[auto_resampler_0 @ 0x55aed2e8c940] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:2 chl:stereo fmt:flt r:44100Hz
[auto_resampler_1 @ 0x55aed2e8a080] [SWR @ 0x55aed2ea2040] Using fltp internally between filters
[auto_resampler_1 @ 0x55aed2e8a080] ch:2 chl:stereo fmt:s16 r:16000Hz -> ch:2 chl:stereo fmt:flt r:44100Hz
[Parsed_amix_0 @ 0x55aed2e6f0c0] inputs:2 fmt:flt srate:44100 cl:stereo
[auto_resampler_2 @ 0x55aed2eb7240] [SWR @ 0x55aed2eb7580] Using fltp internally between filters
[auto_resampler_2 @ 0x55aed2eb7240] ch:2 chl:stereo fmt:flt r:44100Hz -> ch:2 chl:stereo fmt:s16 r:8000Hz

换成这样也一样报错:

bash 复制代码
ffmpeg -i 2ch-44.1k.wav -i 2ch-16k.wav -filter_complex " \
[0:a][1:a]astreamselect=inputs=2:map=0 1[a1][a2], \
[a1]amix=inputs=1[aout1], \
[a2]amix=inputs=1[aout2], \
[aout1][aout2]amix=inputs=2[aout]" \
-map [aout] -f null - -v 48
相关推荐
嘟嘟实验室6 小时前
微信小程序xr-frame透明视频实现
微信小程序·ffmpeg·音视频·xr
泰勒朗斯10 小时前
如何编译Opencv +ffmpeg linux 明明安装了ffmpeg但是opencv就是找不到
linux·opencv·ffmpeg
-Mr_X-16 小时前
windows下srs流媒体服务器使用ffmpeg推流
ffmpeg
dvlinker18 小时前
C++开源项目 VLC 源代码的交叉编译以及库的裁剪方法详解
ffmpeg·mingw-w64·msys2·cygwin·开源vlc·vlc编译·vlc裁剪
因我你好久不见1 天前
springboot java ffmpeg 视频压缩、提取视频帧图片、获取视频分辨率
java·spring boot·ffmpeg
cuijiecheng20182 天前
音视频入门基础:MPEG2-TS专题(21)——FFmpeg源码中,获取TS流的视频信息的实现
ffmpeg·音视频
cuijiecheng20182 天前
音视频入门基础:AAC专题(13)——FFmpeg源码中,获取ADTS格式的AAC裸流音频信息的实现
ffmpeg·音视频·aac
流氓也是种气质 _Cookie2 天前
uniapp blob格式转换为video .mp4文件使用ffmpeg工具
ffmpeg·uni-app
网络安全queen2 天前
网络安全-企业环境渗透2-wordpress任意文件读&&FFmpeg任意文件读
安全·web安全·ffmpeg
yerennuo2 天前
FFmpeg库之ffmpeg
qt·ffmpeg