-
Notifications
You must be signed in to change notification settings - Fork 155
Creation of Fragmented MP4 to support streaming #20
Comments
This is pretty interesting task but requires time and money investments which I don't currently have. |
Hi @MaMazav , |
Hi @MaMazav , |
This branch was only a try to make a Proof Of Concept of that. I stopped working on it when understood that until the following issue in Chrmium will not be solved the minimal latency will be the difference between key frames: |
Thanks. I see that the resolution of this issue of MSE has been moved to Chrome version 45. I guess we will return to it then. |
That's weird - never got more that 10% on my PC. |
When I wrote 90% CPU, I meant 90% of a single core. Could this be this high resolution casing the CPU to go up to 90% (and the screen become sluggish) |
Dunno, maybe due to high resolution. Also depends on CPU. How much are you getting with demo on Github Pages? |
You are right, I get the same high CPU with the demo page too (http://rreverser.github.io/mpegts/). Also tried it on a different compure (i7) in Chrome v43 on Linux Mint - the result is the same. A single core of the CPU is maxed out and the video is choppy, although less choppy than the Windows one (but this machine has a better CPU, so maybe that's why) |
That's really weird. Tried right now - getting 6% avg. in Firefox, 9% avg. in Chrome, both on Windows x64 machine with i7. "choppy" is a known issue (see README) ant completely unrelated to performance, it's just how browsers handle beginning of chunk (basically same problem as with MSE). |
I have checked it again. The "choppy"-nes I was referring to is not the one between the chunks, but the one caused by the CPU being maxed out (it is more frequent, every second or so). |
Conversion never stops - initially, yes, for bufferization purposes and making playback as smooth as possible, a lot of chunks is being scheduled for conversion (although obviously only one is always converted at a time, no multithreading here except as for splitting conversion process from UI). |
But in any case, I do agree that scheduling could be done more wisely and I'd be totally open to any improvements here via PR. |
I think the question more is whether we could limit the "speed" of conversion, so it is not taking up 100% of the CPU core. I would guess, that if it is only taking up 80%, then that slight "choppiness" wouldn't be visible. |
It's really not about speed of conversion itself but purely about scheduling - if it wouldn't try to download & schedule conversion of 20 chunks at once, but would limit count of them to, say, 3, then CPU wouldn't be highloaded that much. As I said above, I'll be happy to accept any PRs in this area. |
Wouldn't the CPU load be the same, except that it would last less long, eg. converting 3 chunks instead of 20. I think it would still max out the CPU core, just for 3/20th of the time of how it is now. |
Nope, it won't be. As I already said, pure conversion is exactly 5-10% that you're seeing after the initial buffering (see "Conversion never stops" comment above - it's still converting under this load; 80% is just due to worker being also busy with loading a lot of binary files besides the conversion itself). |
You should expect some choppiness / increased load every time a "moov" atom (beginning of an .mp4) is appended, as this causes the H.264 decoder to reinitialize. It's necessary if you are switching video resolutions, but avoidable if you are continuing at the same quality level. |
@modest Interesting thought. Do you mean comparing quality with previously saved, and if it matches, omit repeated |
@RReverser Yeah, that's usually how MPEG-DASH and Smooth Streaming are parsed. If you stream 2 segments at 720p then 2 segments at 1080p, the buffer looks like:
|
Sounds good. Willing to try & PR? |
I'm interested to use this library with a long mpegts streaming (rather than segmented one, as in HLS).
I guess I have to follow this spec:
https://w3c.github.io/media-source/isobmff-byte-stream-format.html
I guess the following stages should be taken:
The first stage seems simple, but I don't know how to do the other stages. I would be happy to contribute but I'm not very experienced with the internal structure of MP4, so any help is appreciated.
Thanks
MOTIVATION:
I would like to show live video with extra-low latency. I'm using WebSocket to send data to the client as soon as possible (I'm aware of other alternatives like MPEG-DASH, but it is out of scope now).
By pre-devision of the TS into chunks of full TS and PES packets, I succeeded to bypass the problem of jBinary streaming mentioned in this issue:
jDataView/jBinary#41
In addition I changed the mpegts library to support streaming context (index.js file), so future calls to mpegts can use previous segments passed to mpegts.
Now every TS segment is converted into MP4 complete file. The problem is that now the beginning of each segment missing some informations (e.g. first frames do not have key frames to refer).
By creating fragmented MP4 I will be able to feed MSE segment-by-segment.
The text was updated successfully, but these errors were encountered: