Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:39:40+00:00 2026-06-01T23:39:40+00:00

I’m designing a server application that stores a live H.264 video stream as MP4

  • 0

I’m designing a server application that stores a live H.264 video stream as MP4 for later consumption by browsers. Since a server will need to handle as many simultaneous streams as possible, I believe I/O will be the natural bottleneck and I’d like to keep I/O to a minimum. I’m running into the classic MP4 moov/mdat ordering problem: MP4 generators prefer to write the mdat box (containing the actual media frames) first, then write the moov box (containing file offsets and other structural information) later, after it actually knows what the mdat file offsets are. MP4 consumers prefer the opposite for progressive streaming — reading the moov box first, so the mdat structure is known and the video can start playing quickly without needing to download the whole file.

The usual solution is to post-process MP4 files to move the moov box ahead of the mdat box, and rewriting file offsets accordingly. However, for a high-volume application, I’d like to avoid the I/O penalty of writing the incoming video data to disk, reading it all back in, and writing it again with a new arrangement.

Several approaches come to mind:

  1. Post-process the MP4 as usual, incurring the I/O penalty and potentially delaying the video’s availability. (not good.)
  2. Use fragmented MP4 and small fragment sizes that are reasonable to fit in memory. (This could have negative effects on whole-file seekability, I’d think.)
  3. It would be awesome if filesystems provided a fast “prepend” option to add new blocks to the beginning of a file’s block chain. (I don’t think this has been invented yet.)
  4. Generate the MP4 as two files — an “mdat” file (containing the actual media frames) and a “moov” file (containing the ftyp header and moov data). These two files, if concatenated, would produce a valid moov-first MP4 file. A simple web server module could present a virtual .mp4 file to the user, but read the .moov and .mdat files behind the scenes.

I’m leaning towards #4 for now. Is there any more practical way to solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:39:42+00:00Added an answer on June 1, 2026 at 11:39 pm

    If the size of the moov data is estimable, preallocate space at the beginning of the file. Some of it might be wasted, but you won’t have to recalculate any offsets, and it will avoid the I/O costs in some percentage of cases. Just make sure you have a fallback when the moov data gets bigger than your estimate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.