ffmpeg 报错“无法找到编码参数”

问题描述 投票:0回答:1

使用 Process 在 C# 控制台应用程序中运行 ffmpeg -i,对于某些文件,该进程会卡住并永远运行

        var oInfo = new ProcessStartInfo("ffmpeg.exe", "-i 176d2819-f1da-44eb-b33b-94eb1448194b.mov");
        oInfo.UseShellExecute = false;
        oInfo.CreateNoWindow = true;
        oInfo.RedirectStandardOutput = true;
        oInfo.RedirectStandardError = true;

        string output = string.Empty;
        StreamReader srOutput = null;

            //run the process
            Process proc = Process.Start(oInfo);
            proc.WaitForExit();
            srOutput = proc.StandardError;
            output = srOutput.ReadToEnd();
            proc.Close();

从命令行运行

ffmpeg.exe -i 176d2819-f1da-44eb-b33b-94eb1448194b.mov,收到以下输出中包含的错误

找不到流 1 的编解码器参数(音频:无(apac / 0x63617061)、48000 Hz、4 通道、382 kb/s):未知编解码器 考虑增加“analyzeduration”(0) 和“probesize”(5000000) 选项的值 [aist#0:1/none @ 0000029b0e1b0040] 猜测的频道布局:4.0 输入 #0, mov,mp4,m4a,3gp,3g2,mj2, 来自 '176d2819-f1da-44eb-b33b-94eb1448194b.mov'

ffmpeg version N-117538-g9ce63e65d6-20241015 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14.2.0 (crosstool-NG 1.26.0.120_4d36f27)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-libxml2 --enable-lzma --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-libdvdread --enable-libdvdnav --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libaribcaption --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-libzmq --enable-lv2 --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libvvenc --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-libs=-lgomp --extra-ldflags=-pthread --extra-ldexeflags= --cc=x86_64-w64-mingw32-gcc --cxx=x86_64-w64-mingw32-g++ --ar=x86_64-w64-mingw32-gcc-ar --ranlib=x86_64-w64-mingw32-gcc-ranlib --nm=x86_64-w64-mingw32-gcc-nm --extra-version=20241015
  libavutil      59. 43.100 / 59. 43.100
  libavcodec     61. 22.100 / 61. 22.100
  libavformat    61.  9.100 / 61.  9.100
  libavdevice    61.  4.100 / 61.  4.100
  libavfilter    10.  6.100 / 10.  6.100
  libswscale      8.  6.100 /  8.  6.100
  libswresample   5.  4.100 /  5.  4.100
  libpostproc    58.  4.100 / 58.  4.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001b447c84e40] Could not find codec parameters for stream 1 (Audio: none (apac / 0x63617061), 48000 Hz, 4 channels, 382 kb/s): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[aist#0:1/none @ 000001b44a6bf880] Guessed Channel Layout: 4.0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '176d2819-f1da-44eb-b33b-94eb1448194b.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2024-10-14T07:34:17.000000Z
    com.apple.quicktime.full-frame-rate-playback-intent: 0
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iPhone 16 Pro Max
    com.apple.quicktime.software: 18.0.1
    com.apple.quicktime.creationdate: 2024-10-14T16:18:36+1100
    com.apple.photos.originating.signature: AQMNJRMQrKK7im+Kjhixx6TqQyYm
  Duration: 00:00:32.60, start: 0.000000, bitrate: 15064 kb/s
  Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 130 kb/s (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: none (apac / 0x63617061), 48000 Hz, 4.0, 382 kb/s
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 14464 kb/s, 30 fps, 30 tbr, 600 tbn (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : H.264
  Stream #0:3[0x4](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Metadata
  Stream #0:4[0x5](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Metadata
  Stream #0:5[0x6](und): Data: none (mebx / 0x7862656D), 21 kb/s (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Metadata
  Stream #0:6[0x7](und): Data: none (mebx / 0x7862656D), 48 kb/s (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Metadata
  Stream #0:7[0x8](und): Data: none (mebx / 0x7862656D), 2 kb/s (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Metadata
  Stream #0:8[0x9](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
      creation_time   : 2024-10-14T07:34:17.000000Z
      handler_name    : Core Media Metadata

此错误不会发生在所有文件上,而只会发生在少数文件上。

c# ffmpeg console-application
1个回答
0
投票

我通过在 WaitForExit 属性中输入时间来解决这个问题

 Process proc = Process.Start(oInfo);
        proc.WaitForExit(20000);
        srOutput = proc.StandardError;
        output = srOutput.ReadToEnd();
        proc.Close();

它在 20 秒后存在,这足以获取媒体信息,即使在有错误的文件上,它仍然具有媒体信息

© www.soinside.com 2019 - 2024. All rights reserved.