why every video- and musicplayer seems to have difficulties loading videos or audio from any point but the very start?



why every video- and musicplayer seems to have difficulties loading videos or audio from any point but the very start?

In: Technology

Same way you are fast to find the first word in a book, but you are slow to find word number 300.
Its easy to find the start of the video. But when you ask the program to find minute 23 is harder.

Now. You might say, since a video is timed and a computer only need to go to frame with the searched time. Should be easy right?
Well, to save space videos are compressed. There are formats that allow fast junping to any time.

If you are viewing online videos… Well then you are adding aditional layer of complexity to the mix.

* Most videos use inter-frame compression. To save space, only some frames (called I-frames) are properly stored. For frames in-between (P-frames and B-frames), there is only description on how to move and change chunks of I-frames. So if person who encoded the video wanted to save a lot of space, maybe even half-second or more goes without proper I-frame. If you want to seek to random place, you might have to load I-frame and all the changes that happened since, then apply all those motions and changes. Bonus points if you use mechanical hard drive which makes loading even slower. You can see how this type of compression works when in TV or live-stream some frames get lost. I’ve seen some players to deal with missing I-frames by assuming they are completely colored middle gray, then you see ghosting for few moments. Some players do similar things when you do seeking, you just get glitchy video for few moments. But most players just wait a second while everything needed is loaded.
* If you are watching online video or music, the beginning usually gets loaded immediately when you open page. When you seek to point that’s not loaded, you’ll have to wait while your computer sends request to the web server and receives response. For example, YouTube doesn’t load whole video if it’s long, it loads only next few seconds. Even bigger problem is if the video (or audio) you watch is not split into nice small chunks, but published as a whole and played by built-in player into your browser. What happens when you play such file is that browser starts to download it as any other file (from the beginning) and play it at the same time. When you want to seek into middle, you need to wait, while everything before that gets downloaded, you can’t download file from middle.
* Variable bitrate in videos and especially sound might cause problems. In modern audio or video compression, different amount of data is used to compress different parts. For example, when there is lot’s of motion in the video, you might want to use more data to properly capture it. This poses some challenge. When you want to skip 50s forward, how should the player know where is this part located. It can’t just skip 50MB forward if your average bitrate is 1MB/s, because that’s only average. There has to be some index that say how the time relates to data. But you probably don’t want to store index of each frame. So, as an example, if you have index every 10s and you want jump to 59s, you need to jump to frame at the beginning of the 50th second and read every frame to get to 59th second.

A way to think of it is if you have an encyclopaedia book.

You can open the book at any page, as each article is self contained. But if you try to start reading part way through an article, it will likely make little sense, although you may be able to guess bits. Reading from the start will tell you what the article is about.

Video compression works very similarly. There are some full frames that contain all the information, but most frames simply detail the changes from the reference frame.

The start of the video is a full frame,, and in any case is often preloaded when visiting a site. However, if you pick a random position your computer has to load back to the last full frame, then work out all the changes needed to get to your frame.

There is a balance here. Compression saves bandwidth and enables videos to play on slower connections. But too greater compression, among other issues, results in user frustration, especially on websites (ahem) where users often skip back and forth. Some compensation can be made by preloading content if you know user habits. Sites indicating “hotspots” in videos can often take advantage of greater predictability in where users jump to.