jo1gi / audiobook-dl

Audiobook CLI downloader
GNU General Public License v3.0
248 stars 43 forks source link

`--output-format=mkv` does transcode instead of transmux #37

Open joonas-fi opened 1 year ago

joonas-fi commented 1 year ago

Installation method: pip

Version: audiobook-dl 0.5.0 (have also ffmpeg installed)

Describe the bug The Converting files step takes a very long time, which is an indication it's doing an expensive transcode.

mp4 -> mkv should be a transmux, i.e. ffmpeg just changes the containers instead of doing expensive process of decode -> encode with possibly different codec.

The options given to ffmpeg should probably be -vcodec copy and -acodec copy ask ffmpeg to do a transmux instead of a transcode: https://blog.programster.org/ffmpeg-losslessly-convert-mp4-to-mkv

Quick glance at source code looks like it's only giving input and output filenames to ffmpeg, maybe ffmpeg by default is then doing a transcode: https://github.com/jo1gi/audiobook-dl/blob/b8596e610a2172aee613c2e57e7a29a60a21e527/audiobookdl/output/output.py#L43

joonas-fi commented 1 year ago

Can confirm that running:

$ ffmpeg -i foobar.mp4 -vcodec copy -acodec copy foobar.mkv

(where foobar.mp4 was produced by audiobook-dl)

executes really fast

But when opening that .mkv in VLC it displays loading indicator for a long time, and seems to only start playing the file after it's read the entire file.

For the .mp4 it starts playing instantly.

So more investigation is needed to make the resulting .mkv file be of "best practices".

My best guess is that the cover as mjpeg stream is causing this, but am not sure.

jo1gi commented 1 year ago

It should copy the codecs now when outputting to mkv. Hope it works