this post was submitted on 20 May 2025
31 points (97.0% liked)

Programming

20279 readers
631 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

I'm trying to wrap my head around how media player websites work.

This might not be fully programming, but idk where else to post this question

Some video sharing sites uses blob objects to send the video in chunks, instead of letting the browser download in full. Usually there's mpd or m3u8 files that we can use to download the whole video

But some sites don't use those files. They send mp4 chunks, but those mp4s can't be played and seem encrypted.

How is the webpage's video player able to play the video? Is there a decrypter or something in the webpage/video player? Am i able to download all mp4 chunks and run them through some decrypter in the webpage served to me and create the whole video from it?

top 12 comments
sorted by: hot top controversial new old
[–] Thorry84@feddit.nl 13 points 2 days ago (1 children)

Take a look at yt-dlp. Despite it's name, it can do a lot of web video and audio, not just YouTube.

https://github.com/yt-dlp/yt-dlp

[–] JiminaMann@lemmy.world 1 points 2 days ago (1 children)

So far, I've tried passing in my cookies and the website url but it states 403 error, i might be missing something (video requires sign in to watch)

[–] vildis@lemmy.dbzer0.com 3 points 2 days ago (1 children)

you most likely need to pass a cookies file to authenticate How do i pass cookies to yt-dlp

If the video is actually encrypted (like a streaming service) there are a lot more steps to do to strip Widevine

[–] JiminaMann@lemmy.world 2 points 2 days ago* (last edited 2 days ago)

Yea, seems like its playready by microsoft

What more steps do i need to do?

[–] Irelephant@lemm.ee 8 points 2 days ago (1 children)
[–] JiminaMann@lemmy.world 1 points 2 days ago* (last edited 2 days ago)

Seems like its playready 4.0.0.0? According to the hex of one of the encrypted mp4

Thanks, I'll read through

[–] fubarx@lemmy.world 7 points 2 days ago (1 children)

The exact format depends on the source file format, the platform of the player, the duration of the clip, encryption, and whether it's copyrighted material or not. Also, if it's older software or fairly recent (the current schemes stand on the carcasses of a lot of old formats).

If the source is a single file, it's likely MP4 or WebM (or MOV on Apple and AVI on Windows). The video player can start downloading the whole thing in a background thread. When it has enough material buffered, it can start decoding and playback. However, if there is a network glitch, the video may start pausing and stuttering. This is typically how unprocessed video is served from a cloud file storage site.

Many sites use HLS or MPEG-DASH (or their superset CMAF) to send the video in adaptive chunks. The user-experience is much better and has better server utilization. The manifest files describe which chunks to get depending on current bandwidth. Players can then up or downscale their next request based on network conditions to avoid stuttering. Overloaded servers can also downthrottle the chunk formats on-the-fly.

Apple device native video players only support HLS/CMAF, and inside native appstore apps, files over 10 minutes must be HLS formatted. Non-Apple devices may use either format.

Then there's encryption. If a decryption key (often AES-128) is provided, the player can download it over https, then decrypt the stream on the fly. This is so anyone sniffing the stream only sees encrypted content.

If the material is copyrighted, it may have DRM. On Apple devices this is likely FairPlay. On Windows it could be PlayReady, and on Android and for some browsers, it could be Widevine. Then there's CENC, which use a common encryption format so the same stream can have PlayReady or Widevine.

Most browsers support HLS, since it's delivered over HTTP, it's adaptive, and tools like ffmpeg or handbrake can generate all the files and chunks one time, once a video file is uploaded. The chunks can be hosted anywhere HTTP is served.

This is all for one-way, one file, one viewer mode. If the video stream is meant to be two-way or multicast to lots of viewers, you'll want to head into the world of WebRTC, RTMP, and RTSP.

[–] JiminaMann@lemmy.world 1 points 2 days ago (1 children)

Hmm, the hex of one of the mp4s says microsoft playready version 4.0.0.0, how can i proceed?

[–] fubarx@lemmy.world 2 points 2 days ago

Likely DRM content. Can't help you there.

[–] MalMen@monero.town 7 points 2 days ago

If whqt you really want is to learn: https://forum.videohelp.com/threads/407216-Decryption-The-Dungeon-of-Despair

And dont need to say thank you, you will be saying fuck you in no time after trying to understund all of this shit

[–] slazer2au@lemmy.world 3 points 2 days ago (1 children)

I use Video DownloadHelper and its companion app on Firefox.

[–] JiminaMann@lemmy.world 3 points 2 days ago

Unfortunately, downloadhelper says that the download has failed, and it can't download the video. It can find it tho