VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. 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.
    Last edited by root; 7th Jan 2026 at 12:05. Reason: better title
    Quote Quote  
  2. 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
    Quote Quote  
  3. 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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!