nickdesaulniers / netfix

Let's build a Netflix
http://nickdesaulniers.github.io/netfix
171 stars 128 forks source link

Question about mp4 fragmentation #3

Open giannoudak opened 8 years ago

giannoudak commented 8 years ago

Hello Nick! My name is John Giannoudakis, and i am a software engineer from Greece. I recently noticed the MediaSource API and thought that this would help me to manually buffer an mp4 video for a mobile ad format i am developing.

I read your article here https://hacks.mozilla.org/2015/07/streaming-media-on-demand-with-media-source-extensions/ and found it very intersting and well writen. Really Good job! Bravo :)

However i can't figure out how to covert my simple mp4 to a fragmented one to play with MSE. I don't want to do DASH so i don't want the MPD manifest file. i use ffmpeg to fragment the mp4 using

ffmpeg -i non_fragmented.mp4 -movflags frag_keyframe+empty_moov fragmented.mp4

but the mp4 file has no duration and when i used it with the code you have in your bunny demo it doesn't work.

Can you please me help me about the process i have to do to create a proper mp4 file for MSE?

Thanks in advance for your time and help John

kennylerma commented 6 years ago

I am also struggling with this. The frag_bunny.mp4 works great in IE and Chrome. However, despite my best efforts, I can't reproduce your file even after examining with mp4info and several attempts using a combination of mp4box and ffmpeg. I can can only generate files that will play in one or the other. Please share your encode settings.

Thanks, Kenny

cadesalaberry commented 6 years ago

Have you tried faststart ?

ffmpeg -i input.mp4 -movflags faststart -acodec copy -vcodec copy output.mp4
kennylerma commented 6 years ago

When fragmenting an MP4 for playback with MediaSource, faststart is negated when using frag_keyframe. The frag_bunny.mp4 is a fragmented video with a mp42 container. Currently, I'm making separate videos and using MP4 for IE and WebM for Chrome, but would love to use a single MP4 for both.

oscxc commented 6 years ago

How to convert a video to standard 'codecs="avc1.42E01E, mp4a.40.2' like frag_bunny.mp4. I have used a lot of different ways,all failed. Now,only your frag_bunny.mp4 works well.

jitender1991 commented 6 years ago

@giannoudak Have you found the solution to your problem? if yes, Please share the solution, I am also facing same problem.

IShinji commented 6 years ago

@giannoudak @jitender1991 Hi, I found a soft to slove this problem. Click here https://www.bento4.com/downloads/, download the soft. Then use ./bin/mp4fragment non_fragmented.mp4 fragmented.mp4

IShinji commented 6 years ago

@oscxc 看我上面的回答,不一样非要一样的codecs,转完之后,查一下codecs,设置上就可以了。

arjunkesava commented 5 years ago

Front End: https://github.com/bitmovin/mse-demo/blob/master/index.html Back End Idea: https://bitmovin.com/mp4box-dash-content-generation-x264/

I think, these links will help you.

YiguiDing commented 4 months ago

I've encountered the same problem before

Until I saw this article

https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API/Transcoding_assets_for_MSE#fragmenting

When googling how to convert mp4 to fmp4 using ffmpeg you usually see answers like this

ffmpeg -i non_fragmented.mp4 -movflags frag_keyframe+empty_moov fragmented.mp4

But this command doesn't work for me.

Chrome requires an extra movie flag that is :

-movflags frag_keyframe+empty_moov+default_base_moof
YiguiDing commented 4 months ago

Test if your file is a Fragmented MP4

https://nickdesaulniers.github.io/mp4info/