How to determine the transfer speed in .mp3 format without downloading it?

I have a list of .mp3 files over the Internet, and I would like to receive a file of the highest quality. The quality in multimedia files is equal to their bit rate.

The bit rate itself should be found in the file headers. If not, you can use the length of the audio track. (File size / Track length = Bit rate)

These things would be easy if I had these files locally, but I would like to receive this information via HTTP and determine which file is of the highest quality.

Can I get the length of an audio track from HTTP headers? If not, is it possible to get only bits that describe the length / bit rate instead of downloading the whole file?

I am writing code in python, but the question is pretty general, so I don't put it as a python question.

+3
source share
1 answer

Assuming the remote server is behaving well, you can send a HEAD request to a file and check the contents of the Content-Length header field. It does not give you the track length or transfer rate, but you can get the file size.

EDIT : MP3s consist of several frames, each of which may have a different bit rate (VBR). The length of the track is calculated by the bit rate of each of these frames, and not by the length itself. If you want the bit rate to be reliable, you need two to get the whole file and get the bit rate of each frame. It may be possible to capture the first few kilobytes of a file and read the bit rate from the first frame, but this is not always at the same point in the file (for example, due to the position of the ID3 tag, etc.).

+2
source

Source: https://habr.com/ru/post/1263032/


All Articles