ffmpeg 过滤器,将输入过滤器移入输入过滤器

ffmpeg 过滤器,将输入过滤器移入输入过滤器

在过滤器开头写入是否合法[0:v]scale=-1:360,fps[0:v];?我试图了解为什么我的过滤器不起作用。实际上,它可以工作,但分辨率保持不变。

完整过滤器如下:

ffmpeg -i l.wmv -filter_complex "[0:v]scale=-1:360,fps[0:v];[0:v]trim=start=0:duration=1,setpts=PTS-STARTPTS[c0v];[0:a]atrim=start=0:duration=1,asetpts=PTS-STARTPTS[c0a];[0:v]trim=start=10:duration=1,setpts=PTS-STARTPTS[c1v];[0:a]atrim=start=10:duration=1,asetpts=PTS-STARTPTS[c1a];[c0v][c0a][c1v][c1a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v wmv2 -b:v 2M -c:a libopus jump.mkv

或者,更易读一些:

ffmpeg -i l.wmv -filter_complex

[0:v]scale=-1:360,fps[0:v];

[0:v]trim=start=0:duration=1,setpts=PTS-STARTPTS[c0v];
[0:a]atrim=start=0:duration=1,asetpts=PTS-STARTPTS[c0a];

[0:v]trim=start=10:duration=1,setpts=PTS-STARTPTS[c1v];
[0:a]atrim=start=10:duration=1,asetpts=PTS-STARTPTS[c1a];

[c0v][c0a][c1v][c1a]concat=n=2:v=1:a=1[v][a]

-map "[v]" -map "[a]"

 -c:v wmv2 -b:v 2M -c:a libopus jump.mkv

编辑1:更新命令,现在带有额外的流说明符[vid]:

ffmpeg -i l.wmv -filter_complex "[0:v]scale=-1:360,fps[vid];[vid]trim=start=0:duration=1,setpts=PTS-STARTPTS[c0v];[0:a]atrim=start=0:duration=1,asetpts=PTS-STARTPTS[c0a];[vid]trim=start=10:duration=1,setpts=PTS-STARTPTS[c1v];[0:a]atrim=start=10:duration=1,asetpts=PTS-STARTPTS[c1a];[c0v][c0a][c1v][c1a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v wmv2 -b:v 2M -c:a libopus jump.mkv

完整日志:

D:\_convert\jump>ffmpeg -i l.wmv -filter_complex "[0:v]scale=-1:360,fps[vid];[vid]trim=start=0:duration=1,setpts=PTS-STARTPTS[c0v];[0:a]atrim=start=0:duration=1,asetpts=PTS-STARTPTS[c0a];[vid]trim=start=10:duration=1,setpts=PTS-STARTPTS[c1v];[0:a]atrim=start=10:duration=1,asetpts=PTS-STARTPTS[c1a];[c0v][c0a][c1v][c1a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v wmv2 -b:v 2M -c:a libopus jump.mkv
ffmpeg version 3.3.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (Rev1, Built by MSYS2 project)
  configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-openal --enable-libwavpack --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-static --enable-swresample --enable-version3 --enable-zlib --disable-doc
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
[wmv3 @ 0000000000ff4340] Extra data: 8 bits left, value: 0
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, asf, from 'l.wmv':
  Metadata:
    WM/ToolName     : TMPGEnc Video Mastering Works 5 Version. 5.4.0.100
    WMFSDKVersion   : 12.0.7601.17514
    WMFSDKNeeded    : 0.0.0.0000
    VBR Peak        : 20000000
    Buffer Average  : 397799
    IsVBR           : 1
    DeviceConformanceTemplate: MP@HL
    encoder         : Lavf57.71.100
  Duration: 00:02:01.16, start: 0.312000, bitrate: 3901 kb/s
    Stream #0:0(jpn): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1280x720, 4000 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc
    Stream #0:1(jpn): Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, stereo, fltp, 128 kb/s
[wmv3 @ 0000000000ff67c0] Extra data: 8 bits left, value: 0
Stream mapping:
  Stream #0:0 (wmv3) -> scale
  Stream #0:0 (wmv3) -> trim
  Stream #0:1 (wmav2) -> atrim
  Stream #0:1 (wmav2) -> atrim
  concat:out:v0 -> Stream #0:0 (wmv2)
  concat:out:a0 -> Stream #0:1 (libopus)
Press [q] to stop, [?] for help
[Parsed_concat_10 @ 0000000003cfeec0] Input link in1:v0 parameters (size 1280x720, SAR 0:1) do not match the corresponding output link in0:v0 parameters (640x360, SAR 0:1)
[Parsed_concat_10 @ 0000000003cfeec0] Failed to configure output pad on Parsed_concat_10
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!

答案1

[0:v]是输入流说明符,指的是原始输入流。在 filtergraph 中创建的任意标签都可以重复使用,因此下面的代码可以正常工作。

[somelabel]scale=-1:360,fps[somelabel]

相关内容