mania icon indicating copy to clipboard operation
mania copied to clipboard

Couldn't fetch DOLBY ATMOS track.

Open shahzoorali opened this issue 5 years ago • 45 comments

TIDAL has some new content with DOLBY ATMOS processed tracks. I tried to fetch that but always gets the LOSSLESS file.

Test URL - https://tidal.com/browse/track/125155092 OR Search for Blinding Lights and select the 3rd one.

shahzoorali avatar Jan 19 '20 14:01 shahzoorali

Good catch, thanks for the report! Should be fixed in 3b321e1fbe78bce08a4247a8986e12df113c7b4d. TIDAL is full of these annoying edge cases unfortunately.

evan-goode avatar Jan 19 '20 23:01 evan-goode

That means, we cant download the DOLBY ATMOS file? As I see, you are redirecting to LOSSLESS quality if DOBLY_ATMOS. Am I right?

shahzoorali avatar Jan 20 '20 06:01 shahzoorali

Ah I totally misunderstood the issue. I'm having a little trouble getting the official client to stream/download a DOLBY_ATMOS track, but once I can see what the API call looks like, this shouldn't be hard to do.

evan-goode avatar Jan 24 '20 03:01 evan-goode

Its only playable from Dolby supported device, my Android is. How can I "fiddler" my device?

shahzoorali avatar Jan 24 '20 03:01 shahzoorali

I use mitmproxy: https://mitmproxy.org/

evan-goode avatar Jan 24 '20 04:01 evan-goode

I tried capturing the network, but instead of browser, it cannot capture any app traffic. It seems I need to download the TIDAL apk, decompile, make some changes that it accepts USER installed certificats into its build and compile. I dont think I can do all that.

If I get TIDAL modified apk, I can help with further traffic report to fetch DOLBY ATMOS stream.

shahzoorali avatar Jan 26 '20 17:01 shahzoorali

Just got MQA support working, and I'd like to figure out Dolby audio as well. Still willing to help out?

Yes, you can patch the APK manually to disable cert pinning, but this Xposed module works great with TIDAL: https://github.com/ViRb3/TrustMeAlready. If you're on Android 9 or 10, you can use https://github.com/ElderDrivers/EdXposed instead of the original Xposed.

evan-goode avatar May 02 '20 00:05 evan-goode

Either MITM it being weird or the Dolby Atmos tracks are tiny. Are you telling me that a track with 3d audio is <7MB ?. + I don't think there is a file format for Atmos is there?

112RG avatar May 16 '20 09:05 112RG

Just got MQA support working, and I'd like to figure out Dolby audio as well. Still willing to help out?

Yes, you can patch the APK manually to disable cert pinning, but this Xposed module works great with TIDAL: https://github.com/ViRb3/TrustMeAlready. If you're on Android 9 or 10, you can use https://github.com/ElderDrivers/EdXposed instead of the original Xposed.

Oh yes.

shahzoorali avatar May 16 '20 09:05 shahzoorali

It looks like the only difference in getting a Atmos track is "audioMode": "DOLBY_ATMOS" Which does result in a different flac file then without it

Track with DOLBY_ATMOS in the request is 16.3mb (But seems to just be an MQA file) Track without it is 16.5mb

112RG avatar May 16 '20 09:05 112RG

@Dniel97 said:

"Tidal uses according to a German website https://www.heise.de/newsticker/meldung/3D-Musikformat-Dolby-aeussert-sich-zur-Zukunft-von-Dolby-Atmos-Music-4630101.html Dolby AC-4 which is a proprietary format from Dolby Laboratories. Even when you can download the Dolby AC-4 file, there is (currently) no way to playback these files, read more here: https://en.wikipedia.org/wiki/Dolby_AC-4. Here is an example ac-4 file: https://github.com/google/ExoPlayer/blob/release-v2/library/core/src/test/assets/ts/sample.ac4 where you can try playing this file."

What I think, the 16MB request could be the audio file without the AC-4 filter and it requests AC-4 filter file separately and process while streaming.

shahzoorali avatar May 16 '20 09:05 shahzoorali

Will have to look into it. Currently when playing a Atmos track on mobile the request is for an mp4 file like this

    "assetPresentation": "FULL",
    "audioMode": "DOLBY_ATMOS",
    "audioQuality": "LOW",

I see no option in the app to change the audio quality to anything else

112RG avatar May 16 '20 09:05 112RG

So the mp4 from tidal seems to be a AC-4 file its just how to play it is the problem

Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/isom)
File size                                : 6.53 MiB
Duration                                 : 3 min 32 s
Overall bit rate                         : 257 kb/s
Encoded date                             : 
Tagged date                              : 

Audio
ID                                       : 1
Format                                   : AC-4
Format/Info                              : Audio Coding 4
Commercial name                          : Dolby AC-4
Format version                           : Version 2
Codec ID                                 : ac-4
Duration                                 : 3 min 32 s
Bit rate                                 : 256 kb/s
Sampling rate                            : 48.0 kHz
Frame rate                               : 23.438 FPS (2048 SPF)
Compression mode                         : Lossy
Stream size                              : 6.50 MiB (100%)
Default                                  : Yes
Alternate group                          : 2
Encoded date                             : UTC 2020-03-02 19:33:12
Tagged date                              : UTC 2020-03-02 19:33:12
I-Frame interval                         : 24 frames
Number of presentations                  : 1
Number of substreams                     : 1
Presentation #1                          : Immersive Stereo Main (English)
 Presentation ID                         : 0
 Dolby Atmos                             : Yes
 Dialogue normalization                  : -17.00
 Language                                : English
 Loudness                                : Yes
  Integrated loudness (speech gated)     : -26.0 LKFS
  Integrated loudness (level gated)      : -16.5 LKFS
  Audio Loudness Standard                : ATSC A/85
  Realtime loudness corrected            : No
  Dialogue corrected                     : No
 Dynamic Range Control                   : Yes
  E-AC-3 DRC profile                     : Music light
  Home theater AVR                       : Music light
  Flat panel TV                          : Music light
  Portable speakers                      : Music light
  Portable headphones                    : Music light
 Group #s                                : 1
Group #1                                 : Main
 Content classifier                      : Main
 Language                                : English
 Channel coded                           : Yes
 Immersive stereo                        : Dolby Atmos Content
 Number of substreams                    : 1
 Substream #s                            : 1
Substream #1                             : Stereo
 Channel mode                            : Stereo
 Immersive stereo                        : Dolby Atmos Content
 Channel layout                          : L R

112RG avatar May 16 '20 09:05 112RG

I would like to see support for getting atmos files. I have been playing around and I can't seem to figure out how or why a "audioMode": "DOLBY_ATMOS" is returning for the stream. I just keep getting flac files

The request for atmos files to tidal is

https://api.tidal.com/v1/tracks/125155092/playbackinfopostpaywall?playbackmode=STREAM&assetpresentation=FULL&audioquality=HI_RES&streamingsessionid=xxx&playlistuuid=xxx&prefetch=false&countryCode=US

Response is

    "assetPresentation": "FULL",
    "audioMode": "DOLBY_ATMOS",
    "audioQuality": "LOW",
    "manifest": "xxx",
    "manifestMimeType": "application/vnd.tidal.bts",
    "streamingSessionId": "xxx",
    "trackId": 125155092
}

The manifest for me at least always returns with a .flac and not the .mp4 file

I also suspect that files ending in 2101.mp4 are atmost files since every I have seen ending in that is an atmos file

112RG avatar May 16 '20 12:05 112RG

Amazing find! If someone could teach me a little, I can spare time on this.

shahzoorali avatar May 16 '20 13:05 shahzoorali

@112madgamer try HIGH instead of HIGH_RES that is, don't use HIGH_RES, just use HIGH

fabriguzden avatar May 16 '20 23:05 fabriguzden

Thanks. But I have managed to to download them. I have rigged RedSea to pull them. You need the authorization header to be set. While still having audioquality as HI_RES. Suspect you also need to mimic the newer client as I have changed my header versions to 2.25.1 as well as User-Agent to TIDAL_ANDROID/992 okhttp/3.13.1. I don't see any support for any windows app to decode ac4 even ffmpeg has closed all the stuff with ac4

112RG avatar May 17 '20 06:05 112RG

@112madgamer check this? https://github.com/google/ExoPlayer/pull/5303/files#diff-6ceea91e68efaca951f5ac10e33fd0df

fabriguzden avatar May 17 '20 07:05 fabriguzden

I have seen that but its only for android. Which I can listen to the songs with Google Music app. Still no support for the Sony 3D audio MPEG-h mha1

112RG avatar May 17 '20 08:05 112RG

Also according to ffmpeg irc thats ExoPlayer only implements demuxing, decoding is handed off to some external decoder component, so alone those changes dont mean much

112RG avatar May 17 '20 08:05 112RG

ffmpeg has a WIP for AC-4 it works but its a way off being implemented https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=451

The work is sponsored by VLC so maybe be the end of the year AC-4 decoding might be a thing

112RG avatar May 17 '20 10:05 112RG

Does this help in anyway?

https://developer.dolby.com/forms/dolby-atmos-conversion-tool/

shahzoorali avatar May 20 '20 13:05 shahzoorali

@112madgamer Mind sharing the payload that you used to fetch the Atmos MP4 file? It might still be worth adding support for it even if they can't be played back atm.

joseph39 avatar Jun 04 '20 06:06 joseph39

Can anyone explain to me how to download the Atmos or 360RA files or add support to the code? Thank you very much

frankkk1013 avatar Jun 04 '20 21:06 frankkk1013

I have seen that but its only for android. Which I can listen to the songs with Google Music app. Still no support for the Sony 3D audio MPEG-h mha1

@112madgamer wait a moment, I don't know if I misunderstood, can this file atmos be played on google play music or youtube music?

fabriguzden avatar Jun 05 '20 00:06 fabriguzden

The atmos tracks can be played with Google music app. So I guess the Youtube music app would work also haven't tested. @joseph39 All you need is the "authorization" header set. Which you can get your code by using the MITM proxy. Currently I have found no easy way to download them.

It might be possible if we worked on the logging in via oauth but thats alot of work

112RG avatar Jun 05 '20 08:06 112RG

I just followed what you said and made my own fork of RedSea to download Dolby Atmos here: https://github.com/zpoo32/RedSea Thanks for the help @112madgamer

zpoo32 avatar Jun 08 '20 06:06 zpoo32

Tidal uses according to a German website https://www.heise.de/newsticker/meldung/3D-Musikformat-Dolby-aeussert-sich-zur-Zukunft-von-Dolby-Atmos-Music-4630101.html Dolby AC-4 which is a proprietary format from Dolby Laboratories. Even when you can download the Dolby AC-4 file, there is (currently) no way to playback these files, read more here: https://en.wikipedia.org/wiki/Dolby_AC-4. Here is an example ac-4 file: https://github.com/google/ExoPlayer/blob/release-v2/library/core/src/test/assets/ts/sample.ac4 where you can try playing this file.

What I think, the 16MB request could be the audio file without the AC-4 filter and it requests AC-4 filter file separately and process while streaming.

Could you please tag me if you are copying my reply from https://github.com/yaronzz/Tidal-Media-Downloader/issues/252#issuecomment-627956926?

EDIT: Thanks!

Dniel97 avatar Jun 08 '20 17:06 Dniel97

I just followed what you said and made my own fork of RedSea to download Dolby Atmos here: https://github.com/zpoo32/RedSea Thanks for the help @112madgamer

Thank you @zpoo32 for the repo. I tried your RedSea version and manually added my TIDALSESSION and AUTHHEADER to settings.py. Then I executed python redsea.py -p best_available https://tidal.com/browse/album/XXXXXXX and python redsea.py https://tidal.com/browse/album/XXXXXXX without any success. It downloaded just a AAC 96 kbit/s .mp4 file instead of a AC-4 .mp4 file - The Album is obviously availbable in Dolby Atmos.

Dniel97 avatar Jun 08 '20 18:06 Dniel97

Are you certain you are using the exact same URLs that play Dolby Atmos on the Tidal app?

zpoo32 avatar Jun 08 '20 20:06 zpoo32