sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
414 stars 94 forks source link

IsMp4FastStartEnabled option doesn't work when IsFragmentedMp4Enabled option is also used #234

Closed ranwer-dev closed 1 month ago

ranwer-dev commented 1 year ago

If we use both IsMp4FastStartEnabled & IsFragmentedMp4Enabled options, video doesn't faststart. Is there any way to fix this?

sskodje commented 1 year ago

Fast start is unfortunately quite broken, because Microsoft Media Foundation is broken in this regard. I've been working on a fix, but it requires editing the headers manually, so it's a bit complicated.

ranwer-dev commented 1 year ago

Any progress on that @sskodje?

sskodje commented 1 year ago

Fast start is unfortunately still fundamentally broken in Media Foundation. Fragmented mp4 should work though, even though fast start does not. The two flags are mutually exclusive as far as i know.

ranwer-dev commented 1 year ago

IsMp4FastStartEnabled and IsFragmentedMp4Enabled don't work together. IsMp4FastStartEnabled works perfectly if the Fragmented option is off.

sskodje commented 1 year ago

That's good fast start works for you, but I'm a bit confused what your issue is then.

Fast start is only meaningful when streaming non-fragmented mpegs. What it does is to write the headers at the start of the video instead of at the end, so you don't have to download the entire video to start streaming. Fragmented mpegs already fully support streaming due to their fragmented nature, and thus the flag does nothing by design. The headers in a fragmented mpeg are written periodically every few seconds.

Do you have a specific issue with streaming videos recorded with any of the flags?

ranwer-dev commented 1 year ago

Right now the only reason I want to use FramgmentedMp4 option is to avoid corrupted video if the recording breaks in the middle. Sometimes, while doing long recordings, the recorder crashed for memory or some other unknown reason. This is very rare, but even if there's very little chance, this option can preserve the completed part of the recording.