benfmiller / audalign

Package for aligning audio files through audio fingerprinting
MIT License
94 stars 2 forks source link

Requested output format 'mka' is not known. - audalign.target_align with destination_path #58

Open milahu opened 4 months ago

milahu commented 4 months ago

this error appears when i run audalign.target_align on mka files with destination_path != None

import audalign

# mka files in todo-align-files/*.mka
audalign.target_align(
    "target.mka",
    "todo-align-files",
    destination_path="audalign-result"
)

problem: audalign calls AudioSegment.export with format = "mka" but mka is the file extension, and the ffmpeg format is matroska

pydub/audio_segment.py

class AudioSegment(object):
    # ...
    def export(self, out_f=None, format='mp3', codec=None, bitrate=None, parameters=None, tags=None, id3v2_version='4',
               cover=None):

related upstream issue https://github.com/jiaaro/pydub/issues/755 same problem with m4a extension, the ffmpeg format is ipod

Requested output format 'm4a' is not a suitable output format

related upstream PR https://github.com/jiaaro/pydub/pull/793 this would allow us to pass out_f="out.mka" and let ffmpeg guess format from extension problem is, pydub is unmaintained https://github.com/jiaaro/pydub/issues/389 https://github.com/jiaaro/pydub/issues/444

so... we could use ffprobe to get the format name

$ ffprobe -loglevel error -show_entries format=format_name -of default=nw=1:nk=1 src.mka
matroska,webm
benfmiller commented 4 months ago

Thank you for this bug report as well!

It looks like something like https://github.com/PyAV-Org/PyAV could be used to get the mappings supported by ffmpeg? Trying not to bring in another dependency

Or would it be preferable to add a configuration setting to define preferred formats per file extension along with defaults?

milahu commented 4 months ago

preferred formats per file extension

mkv and mka containers can contain any codec...

by default, it should preserve container and codec of the input if that is ambiguous (different input files) then just pick the first, or let the user set a codec