在python上使用ffmpeg将mkv转换为mp3时出现“不支持的输入采样率设置"错误 [英] 'unsupported input sample rate set' error while converting mkv to mp3 with ffmpeg on python
问题描述
我在尝试通过python将某些mkv文件转换为mp3时遇到此错误.几乎所有文件都已转换,但是有些文件正面临此问题.
https://cdn.discordapp.com/attachments/663255565451001001866/788424224661569596/错误.txt
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
请帮助我解决此问题.
ffmpeg输出:
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 ED\Original\045 '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!
推荐答案
您正在使用MediaFoundation MP3编码器 mp3_mf .好像是一个挑剔的,麻烦的编码器.即使添加 -ar 48000
,它仍然可能会失败,并显示错误 nb_samples(1024)!= frame_size(0)
.
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)
.
要修复此问题,请使用其他MP3编码器.使用输出选项 -c:a libmp3lame
(而不是 -c:a mp3_mf
(如果使用的话).
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 将自动选择适当的采样率,因此无需添加 -ar
.
libmp3lame will automatically choose the appropriate sample rate, so no need to add -ar
.
这篇关于在python上使用ffmpeg将mkv转换为mp3时出现“不支持的输入采样率设置"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!