B
B
Bexruz Sayfiddinov2021-02-11 08:08:41
Python
Bexruz Sayfiddinov, 2021-02-11 08:08:41

When converting mp3 file gives an error! (I use ffmpeg), telebot. how to fix?

@bot.message_handler(content_types=['audio'])
def mp3(message: Message):
    fileID = message.audio.file_id
    file = bot.get_file(fileID)
    download = bot.download_file(file.file_path)
    title = message.audio.title
    perfor = message.audio.performer
    with open('audio1.mp3', 'wb') as f:
        f.write(download)
    
    process = subprocess.run(['ffmpeg', '-i', 'audio1.mp3', '-b:a 64k', '-c:a libmp3lame', 'output.mp3', '-y'])



    audioR = open('output.mp3', 'rb')

    bot.send_audio(message.chat.id, audioR, title=title, performer=perfor)


outpu:
PS C:\Users\User\Desktop\IT_Files\TeleBOT\First Project Bot> & C:/Users/User/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/User /Desktop/IT_Files/TeleBOT/First Project Bot/bot.py"
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
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 --enable-libgsm --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.51.100 / 56.51.100
Libavcodec 58. 91.100 / 58. 91.100 Libavformat
58. 45.100 / 58. 45.100
Libavdevice 58. 10.100 / 58. 10.100
Libavfilter 7. 85.100 / 7. 85.100
Libswskale 5. 7.100 / 5. 7.100 libswressample
/ 3
7.100 / 55. 7.100
Input #0, mp3, from 'audio1.mp3':
Metadata:
encoder : Lavf58.20.100
Duration: 00:03:15.40, start: 0.025057, bitrate: 320 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
Metadata:
encoder : Lavf
[mp3 @ 007cec00] Invalid stream specifier: a 64k.
Last message repeated 1 times

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Belokurov, 2021-02-11
@kyern

Here the problem is not in your script, but in the parameters passed to ffmpeg, your script works out and, apparently, correctly passes the parameters. Better ask this question in the ffmpeg section.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question