valekhz / m4b-converter

Simple python script to convert m4b audio books to a group of mp3 files split by chapter.
85 stars 39 forks source link

ffmpeg: Unknown decoder 'copy' #13

Open rejhgadellaa opened 7 years ago

rejhgadellaa commented 7 years ago

I'm getting an error when using the python script on Windows:

INFO: Splitting chapter 1/55 '001'... ERROR: An error occurred while splitting audio file. Command: ffmpeg -y -acodec copy -t 1347.221 -ss 0.0 -i babashes\temp\babashes.mp3 babashes_tmp_1.mp3 Return code: 1 Output: ----> ffmpeg version N-82876-gd8b9bef Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib libavutil 55. 43.100 / 55. 43.100 libavcodec 57. 68.100 / 57. 68.100 libavformat 57. 61.100 / 57. 61.100 libavdevice 57. 2.100 / 57. 2.100 libavfilter 6. 68.100 / 6. 68.100 libswscale 4. 3.101 / 4. 3.101 libswresample 2. 4.100 / 2. 4.100 libpostproc 54. 2.100 / 54. 2.100 Unknown decoder 'copy'

A bit of Googling got me this:

When you specify a codec option before "-i", you tell ffmpeg how to decode the input. "copy" cannot be used as a decoder. You can only use it as an encoder. So, this is okay:

ffmpeg -i input -c:v copy output

This is not okay:

ffmpeg -c:v copy -i input output

https://lists.ffmpeg.org/pipermail/ffmpeg-user/2013-September/017479.html

So then I opened m4b.py and changed:

split_cmd = '%(ffmpeg)s -y -acodec copy -t %(duration)s -ss %(start)s -i %(outfile)s %(infile)s'

to

split_cmd = %(ffmpeg)s -i %(outfile)s -y -acodec copy -t %(duration)s -ss %(start)s %(infile)s

and that seems to work.

Note: I effectively put all the arguments after the -i %(outfile)s

So.. the argument order changed for ffmpeg since the script was written? Or was the default order always wrong?

bobombolo commented 7 years ago

that works for me too. how would you do leading zeros in the track numbering?