Hi,
I’m working with a fragmented MP4 (fMP4) video that is delivered through a single URL, not HLS or DASH.
The server supports HTTP byte-range requests, and browsers seem to download and process the file in chunks instead of downloading it fully.
I already have the decryption keys for the video.
What I’m trying to understand is how to decrypt the video chunk-by-chunk, similar to how a browser does it, rather than downloading the entire file first.
Specifically:
- How to handle fMP4 fragments (moof/mdat) when fetched via byte ranges
- How the init segment data is used to decrypt the remaining fragments
- How browsers process and decrypt these chunks incrementally
- Any tools or libraries that can help parse/decrypt fMP4 in this way
Any pointers or explanations would be appreciated.
Thanks.
+ Reply to Thread
Results 1 to 3 of 3
-
Last edited by root; 7th Jan 2026 at 12:05. Reason: better title
-
I know that N_m3u8DL-RE has support for fMP4 and real time decryption for live streams, so you could look into that:
- https://github.com/nilaoda/N_m3u8DL-RE/blob/main/src/N_m3u8DL-RE/Util/PipeUtil.cs#L45
And also this comment ("Shaka/ffmpeg real-time decryption does not require an init file for merging, while mp4decrpyt does."):
- https://github.com/nilaoda/N_m3u8DL-RE/blob/main/src/N_m3u8DL-RE/DownloadManager/Simpl...nager2.cs#L566
I don't know much about mp4 containers, only MPEG-TS, so maybe look into the source code of ShakaPackager and Mp4Decrypt:
- https://github.com/shaka-project/shaka-packager/blob/main/packager/media/base/decrypto..._source.cc#L36
- https://github.com/axiomatic-systems/Bento4/blob/master/Source/C%2B%2B/Core/Ap4CommonE...tion.cpp#L1917
Or Firefox's ClearKey CDM:
- https://github.com/mozilla-firefox/firefox/blob/main/dom/media/eme/clearkey/ClearKeyDe...nager.cpp#L167
Or OpenWV:
- https://github.com/tchebb/openwv/blob/main/src%2Fdecrypt.rs#L22
But I'd like to know why? Are you trying to re-stream?Last edited by larley; 7th Jan 2026 at 17:54.
Bypass HMACs, One-time-tokens and Lic.Wrapping: https://github.com/DevLARLEY/WidevineProxy2 -
Hi larley,
Thank you for the references; I really appreciate it.
Just to clarify, my goal isn’t re-streaming. I’m trying to do something similar to N_m3u8DL-RE’s --mp4-real-time-decryption, but for content delivered as a single fMP4 URL instead of HLS/DASH. The server supports HTTP byte-range requests, so the idea is to fetch ranges incrementally and decrypt each fMP4 fragment as it’s downloaded, rather than downloading the full file first.
That’s why I’m interested in how browsers and tools like Shaka handle incremental fMP4 parsing and decryption, and how the init segment fits into that flow.
Thanks again for the pointers. I’ll look into those codebases.
Similar Threads
-
Help downloading video (too many requests on N_m3u8DL-RE)
By Asdfgf in forum Video Streaming DownloadingReplies: 1Last Post: 6th Apr 2025, 15:17 -
Decrypting MPD videos without license url
By Sagnik in forum Video Streaming DownloadingReplies: 9Last Post: 19th May 2024, 07:55 -
Decrypting protected license url
By Mrachan in forum Video Streaming DownloadingReplies: 3Last Post: 17th Nov 2023, 13:42 -
need help decrypting a video
By swappyison in forum Video Streaming DownloadingReplies: 12Last Post: 3rd Aug 2023, 10:04 -
How to merge video m3u8 url and audio m3u8 url live channel
By sairaj in forum DVB / IPTVReplies: 2Last Post: 3rd Jul 2023, 07:29


Quote