Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
195 views
in Technique[技术] by (71.8m points)

'unsupported input sample rate set' error while converting mkv to mp3 with ffmpeg on python

I'm getting this error on trying to convert some mkv files to mp3 via python. Nearly all files got converted, but some are facing this issue.
https://cdn.discordapp.com/attachments/663255565451001866/788424224661569596/Error.txt

Please help me fix this issue.

ffmpeg output extracted from the discord link above:

ffmpeg version git-2020-06-04-7f81785 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 49.100 / 56. 49.100
  libavcodec     58. 90.100 / 58. 90.100
  libavformat    58. 44.100 / 58. 44.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 84.100 /  7. 84.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from 'J:DC EDOriginal45 'Kimi no Egao ga Nani Yori mo Suki Datta' by 'Chicago Poodle'.mkv':
  Metadata:
    title           : 045 'Kimi no Egao ga Nani Yori mo Suki Datta' by 'Chicago Poodle'.mkv
    COPYRIGHT       : ? 2013 APTX4869 Fansub
    creation_time   : 2020-11-18T05:03:06.000000Z
    COMPOSER        : Chicago Poodle
    ENCODER         : Lavf58.44.100
  Duration: 00:01:20.04, start: 0.000000, bitrate: 2023 kb/s
    Stream #0:0(jpn): Video: hevc (Main), yuv420p(tv), 1440x1080 [SAR 4:3 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      title           : VIDEO[AVC]
      ENCODER         : Lavc58.90.100 libx265
      BPS-eng         : 1831510
      DURATION-eng    : 00:01:20.039000000
      NUMBER_OF_FRAMES-eng: 1919
      NUMBER_OF_BYTES-eng: 18324032
      _STATISTICS_WRITING_APP-eng: mkvmerge v49.0.0 ('Sick Of Losing Soulmates') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-11-18 05:03:06
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(jpn): Audio: aac (LC), 96000 Hz, stereo, fltp (default)
    Metadata:
      title           : AUDIO[AAC]
      BPS-eng         : 188626
      DURATION-eng    : 00:01:19.999000000
      NUMBER_OF_FRAMES-eng: 3750
      NUMBER_OF_BYTES-eng: 1886246
      _STATISTICS_WRITING_APP-eng: mkvmerge v49.0.0 ('Sick Of Losing Soulmates') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-11-18 05:03:06
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
  Stream #0:1 -> #0:0 (aac (native) -> mp3 (mp3_mf))
Press [q] to stop, [?] for help
[mp3_mf @ 000002142f4a5fc0] MFT name: 'MP3 Encoder ACM Wrapper MFT'
[mp3_mf @ 000002142f4a5fc0] unsupported input sample rate set
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are using the encoder mp3_mf which is the MediaFoundation MP3 encoder. Seems like a picky, troublesome encoder. Even if you add -ar 48000 it may still fail with the error nb_samples (1024) != frame_size (0).

To fix it use a different MP3 encoder. Use the output option -c:a libmp3lame (instead of -c:a mp3_mf if you used that).

ffmpeg -i input.mkv -c:a libmp3lame output.mp3

libmp3lame will automatically choose the appropriate sample rate, so no need to add -ar.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...