whatvn / ngx_http_estreaming_module

An adaptive hls streaming module for nginx
GNU General Public License v2.0
90 stars 20 forks source link

Adaptive behaviour is limited to MP4 encoded by mp42 codec #22

Open soufrk opened 8 years ago

soufrk commented 8 years ago

In continuation to my posts on the following issue, https://github.com/whatvn/ngx_http_estreaming_module/issues/19 I have decided to spawn this as a new thread.

The adaptive behaviour expected, is only possible if the file is encoded by mp42 (MPEG4 Version 2) encoder, shown by mediainfo as

Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42

Well at this point all I have come to know is that it is a codec by Microsoft, extending the standard MP4 definition.

What I am testing with is, encoded with x264, ffmpeg encoder.You would come across such files more often. Such files do not result in adaptive behaviour.

Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom

What's the reason, well I am not sure about that. If you have any information with this regard, kindly share.

whatvn commented 8 years ago

Mpegts uses mpeg2. In estreaming module, what I do is simply give libavcodec ts extension and let it decide which codec can be used to decode and encode, in this case maybe libavcodec find out that your media file is not mpeg2 and it stops.

Estreaming module will not stop and give you error when it cannot decode/encode media segment. if I cannot transcode video, it will response the original ts file to client.

What I am testing with is, encoded with isom encoder.You would come across such files more often. 

No, if you just have one standard encoding setting, you will never get that error.

soufrk commented 8 years ago

No, my friend perhaps you did not understand the point I tried to make. I understand and agree with whatever you have said.

  1. But, the problem is with the source MP4 files.
  2. MP4 files encoded using mp42/msmpeg4v2 encoder, show adaptive behaviour. On the other hand MP4 files encoded using other codecs do not show adaptive behaviour.
  3. There is no error, in any case.

I hope you understood the problem now. If you do not, let me know I will explain it again.

whatvn commented 8 years ago

1. But, the problem is with the source MP4 files. I understand. The problem is that you encoded your video with mpeg-v1 and not mpeg-v2, but HLS which uses mpegts use mpegv2, not mpegv1 (https://en.wikipedia.org/wiki/MPEG_transport_stream) 2. MP4 files encoded using mp42/msmpeg4v2 encoder, show adaptive behaviour. On the other hand MP4 files encoded using other codecs do not show adaptive behaviour. As I said in previous comment, this module use libavcodec (which is shipped with ffmpeg) to transcode ts segment file. This module has two phases:

  1. it reads mp4 metadata to split mp4 file into segment based on request uri.
  2. it transcodes ts into other resolution based on request uri. The transcoding process happens on ts file, not mp4. That's why you dont understand what I've said. 3. There is no error, in any case. if transcoding process fail, it will just do step 1, and step 2 will be ignored. That's why there's no error.
soufrk commented 8 years ago

Yes got your point , but my doubt is how using the same mpegV1 (MP4 Base media) file HLS is being served by the VOD module ?. Which is Muxed (all ts chunks)
If i understand your point 1.your doing segmentation first and 2. trans-code it here trans-coding if failing -- correct ?

Here is the issue. We already have peta-bytes of files trans-coded in (MPEG-4 Base Media) and we will not be able to migrate to the MP4(Base Media Version 2). Is there any other option to make it work, such as -- if FFMPEG can trans-code these files, can we find and fix the code that will work for MP4s in Base media.

whatvn commented 8 years ago

I think it's possible by manually specify input format for libavcodec, but at this time I am busy doing another project, lets see if I can make it in next few days.