具有音频过滤功能的FFmpeg拆分过滤器会引发错误

时间:2018-12-15 16:46:45

标签: audio ffmpeg

在将FFmpeg的拆分过滤器用于视频轨道时,我也想过滤音频轨道。我测试了plit,但不确定在过滤器链中的哪里使用。

运行此命令时:
ffmpeg -y -probesize 100M -analyzeduration 5000000 -hide_banner -i $input -i $logo \ -filter_complex "[0:a]aformat=channel_layouts=stereo,aresample=async=1000[a1];[0:v]overlay=20:20,drawtext=fontfile=$font:text='some text':fontcolor=c1ff30:fontsize=50:x=250:y=100,split=3[v1][v2][v3];[v1]setpts=PTS-STARTPTS,yadif=0:-1:0,scale=w=640:h=360:force_original_aspect_ratio=decrease:sws_dither=ed:flags=lanczos,setdar=16/9[v1];[v2]setpts=PTS-STARTPTS,yadif=0:-1:0,scale=w=1024:h=576:force_original_aspect_ratio=decrease:sws_dither=ed:flags=lanczos,setdar=16/9[v2];[v3]setpts=PTS-STARTPTS,yadif=0:-1:0,scale=w=1600:h=900:force_original_aspect_ratio=decrease:sws_dither=ed:flags=lanczos,setdar=16/9[v3]" \ -map "[v1]" -map "[a1]" -c:a libfdk_aac -ac 2 -b:a 128k -ar 48000 -c:v libx264 -crf 23 -maxrate 550k -bufsize 1100k -bsf:v h264_mp4toannexb -forced-idr 1 -sc_threshold 0 -r 25 -g 50 -keyint_min 50 -preset medium -profile:v main -level 3.1 -coder 1 -pix_fmt yuv420p -flags +loop+mv4+cgop -flags2 +local_header -movflags faststart -cmp chroma -hls_time 6 -hls_playlist_type vod /dir/1.m3u8 \ -map "[v2]" -map "[a1]" -c:a libfdk_aac -ac 2 -b:a 128k -ar 48000 -c:v libx264 -crf 23 -maxrate 1400k -bufsize 2800k -bsf:v h264_mp4toannexb -forced-idr 1 -sc_threshold 0 -r 25 -g 50 -preset medium -profile:v main -level 4 -coder 1 -pix_fmt yuv420p -flags +loop+mv4+cgop -flags2 +local_header -movflags faststart -cmp chroma -keyint_min 50 -hls_time 6 -hls_playlist_type vod /dir/2.m3u8 \ -map "[v3]" -map "[a1]" -c:a libfdk_aac -ac 2 -b:a 128k -ar 48000 -c:v libx264 -crf 23 -maxrate 3100k -bufsize 6200k -bsf:v h264_mp4toannexb -forced-idr 1 -sc_threshold 0 -r 25 -g 50 -preset medium -profile:v high -level 3.1 -coder 1 -pix_fmt yuv420p -flags +loop+mv4+cgop -flags2 +local_header -movflags faststart -cmp chroma -keyint_min 50 -hls_time 6 -hls_playlist_type vod /dir/3.m3u8

FFmpeg引发此错误:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/aaa/bbb/file.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.20.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 117945 kb/s
    Stream #0:0(eng): Video: prores (apcn / 0x6E637061), yuv422p10le(tv, bt709, top coded first (swapped)), 1920x1080, 115636 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 10k tbn, 10k tbc (default)
    Metadata:
      handler_name    : Telestream, LLC Telestream Media Framework - Local 99.99.999999
      encoder         : Apple ProRes 422
      timecode        : 01:25:44:05
    Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default)
    Metadata:
      handler_name    : Telestream, LLC Telestream Media Framework - Local 99.99.999999
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    Metadata:
      handler_name    : Telestream, LLC Telestream Media Framework - Local 99.99.999999
      timecode        : 01:25:44:05
Input #1, png_pipe, from '/Volumes/aaa/bbb/logo.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 1920x1080 [SAR 2835:2835 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Output with label 'a1' does not exist in any defined filter graph, or was already used elsewhere.

在删除音频过滤([0:a]aformat=channel_layouts=stereo,aresample=async=1000[a1])并将0:a映射为音频时,该命令运行良好。

我想念什么?

1 个答案:

答案 0 :(得分:1)

Filtergraph输出只能使用一次。您必须克隆音频输出以供多种使用。

首先

[0:a]aformat=channel_layouts=stereo,aresample=async=1000,asplit=3[a1][a2][a3]

,然后根据需要映射a1a2a3