quodlibet / mutagen

Python module for handling audio metadata
https://mutagen.readthedocs.io
GNU General Public License v2.0
1.56k stars 158 forks source link

dash mp4: bitrate 0 #366

Open razaqq opened 5 years ago

razaqq commented 5 years ago
import mutagen

f = mutagen.File("filename.m4a")
print("Length: {}s; Bitrate: {}; Sample Rate: {}; Bits per Sample: {}".format(f.info.length, f.info.bitrate, f.info.sample_rate, f.info.bits_per_sample))

output:

Length: 342.12281179138324s; Bitrate: 0; Sample Rate: 44100; Bits per Sample: 16

I tried on a lot of different files, always getting bitrate 0

lazka commented 5 years ago

Can you provide an example file somehow (or send it to me reiter.christoph@gmail.com) ?

razaqq commented 5 years ago

sure ill send you a couple via mail

razaqq commented 5 years ago

sent!

btw they were created via https://github.com/ritiek/spotify-downloader, which also uses mutagen

lazka commented 5 years ago

Thanks.

Hm, it's a DASH file, and the bitrate in the file is set to 0 (unknown).

I see there is a sidx atom which contains a list of segment sizes and in the tkhd atom there is a track ID to match that. Maybe we can calculate the bitrate from there.

lazka commented 5 years ago

ok, sidx just has offsets. using tfhd+trun works though..., see ISO_IEC_14496-12_2012

lazka commented 5 years ago

ok, for reference, one can get these types of files through

youtube-dl --fixup never -f 140 "https://www.youtube.com/watch?v=j5oaCPCqN3Y"

youtube-dl will by default convert the dash files to normal mp4 files: https://github.com/rg3/youtube-dl/blob/d4a24f4091a622b808ff621e78b5cfd0db3c8c11/youtube_dl/postprocessor/ffmpeg.py#L520

You should report this to spotify-downloader as it likely will cause incompatibilities with various software.

razaqq commented 5 years ago

thanks for looking into it! Will report it to them.