Dniel97 / orpheusdl-beatport

An OrpheusDL Beatport module
36 stars 12 forks source link

Unable to convert directly from FLAC to ALAC using Beatport module #11

Open zhordon opened 1 month ago

zhordon commented 1 month ago

Since Beatport added Lossless support and with the updated module, I'm no longer able to auto convert FLAC to ALAC directly with the Beatport module only.

I'm not sure if it's an OrpheusDL related issue or Beatport module related issue.

It functions correctly to auto convert with FFMPEG for Tidal, Qobuz and Deezer, but it's the Beatport module giving the issue that I have 2 different configurations setup and then have to manually batch convert and re-tag the missing data from the download.

In my settings.json I have for my auto conversion is the following:

        "advanced": {
            "advanced_login_system": false,
            "codec_conversions": {
                "flac": "alac",
                "wav": "alac"
            },

Which will give the following error:

User@User-Mac-Studio OrpheusDL %  python3 orpheus.py https://www.beatport.com/track/the-right-way/19234567

   ____             _                    _____  _      
  / __ \           | |                  |  __ \| |     
 | |  | |_ __ _ __ | |__   ___ _   _ ___| |  | | |     
 | |  | | '__| '_ \| '_ \ / _ \ | | / __| |  | | |     
 | |__| | |  | |_) | | | |  __/ |_| \__ \ |__| | |____ 
  \____/|_|  | .__/|_| |_|\___|\__,_|___/_____/|______|
             | |                                       
             |_|                                       

=== Downloading track The Right Way (Mark Maxwell Extended Remix) (19234567) ===
        Album: The Right Way (Mark Maxwell Extended Remix) (4639133)
        Artists: Jason Herd, Amanda Wilson, St. Croix (22936)
        Release year: 2024
        Service: Beatport
        Codec: FLAC, bitrate: 1411kbps, bit depth: 16bit, sample rate: 44.1kHz

        Downloading track file
        100%|██████████████████████████████| 41.9M/41.9M [00:01<00:00, 28.3MB/s]
        Downloading artwork
        Converting to ALAC
Traceback (most recent call last):
  File "/Users/Music/OrpheusDL/orpheus/music_downloader.py", line 581, in download_track
    ).run(capture_stdout=True, capture_stderr=True)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/ffmpeg/_run.py", line 325, in run
    raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/Music/OrpheusDL/orpheus.py", line 225, in <module>
    main()
  File "/Users/Music/OrpheusDL/orpheus.py", line 220, in main
    orpheus_core_download(orpheus, media_to_download, tpm, sdm, path)
  File "/Users/Music/OrpheusDL/orpheus/core.py", line 399, in orpheus_core_download
    downloader.download_track(media_id, extra_kwargs=media.extra_kwargs)
  File "/Users/Music/OrpheusDL/orpheus/music_downloader.py", line 597, in download_track
    raise Exception(f'ffmpeg error converting to {new_codec.name.lower()}:\n{error_msg}')
Exception: ffmpeg error converting to alac:
[ipod @ 0x7fcbcf708040] Could not find tag for codec h264 in stream #0, codec not currently supported in container
[out#0/ipod @ 0x7fcbcf706e80] Could not write header (incorrect codec parameters ?): Invalid argument
[vf#0:0 @ 0x7fcbcf707c00] Error sending frames to consumers: Invalid argument
[vf#0:0 @ 0x7fcbcf707c00] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 0x7fcbcf707c00] Terminating thread with return code -22 (Invalid argument)
[out#0/ipod @ 0x7fcbcf706e80] Nothing was written into output file, because at least one of its streams received no packets.

Is there a possible code fix or suggestion for me to try to manually update the code myself?

Thanks for your time and work!

zhordon commented 6 days ago

So after conversing with a friend, and trying to troubleshoot why the above was happening. It it appears to be an issue with the Artwork.

It looks as if the .FLAC comes with all the metadata embedded to start, so when it goes to convert the .FLAC it spits out an error due to the way it's looking at the artwork.

When the artwork seems to be removed, the conversion proceeds as normal.

I know that OrpheusDL/module tags after conversion so it doesn't have a chance to do that simply because the artwork header is the issue.

Is there a way to fix this in code?