iMath
iMath

Reputation: 2478

figure out the file size of a m3u8 url referenced video

If a m3u8 url references to a streming, there is no video size, however , If the m3u8 url references to a video, any way to figure out the video file size ?

I don' t want adding up all the http content-length header of each video segment because it is a bit tedious.

I provide this m3u8 url as an example usage.

Upvotes: 1

Views: 5545

Answers (1)

Mick
Mick

Reputation: 25471

The duration of a particular video stream within a M3U8 manifest file is not mandatory, but if a given video stream will typically have this information in the header of its own container.

For example, if the stream is a MP4 stream then you can get the duration from the header 'Moov" atom once it is read in at the start, rather than having to read each segment and add up its content length.

Its worth noting that for MP4 in particular you need to have the Moov atom at the start of the file - most MP4 videos that have been prepared for streaming will have had this done.

Looking at the file size: an m3u8 file, assuming you are using HLS video, is actually an index into, usually, multiple chunked versions of the video. These different versions are different resolutions and bit rates. The purpose is to allow the player choose the best bit rate/resolution for the device and current network conditions. This is referred to as Adaptive Bitrate Streaming - see here for more info:https://stackoverflow.com/a/42365034/334402

So, there is not actually a single file size for an ABR M3U8 video. You could calculate the file size of the maximum bitrate stream, for example, by multiplying the duration by the bit rate, but you need to be aware that your player may switch between bit rates, unless you have it set to only use one.

Upvotes: 3

Related Questions