shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.98k stars 507 forks source link

Packaging ffmpeg produced transport stream does not play with dash.js #166

Closed hariszukanovic closed 8 years ago

hariszukanovic commented 8 years ago

Hi everyone,

I am having trouble packaging an mpegdash live stream to be played with dash.js It does work with shaka player!

I see only 2 distinct warnings, one of which might be directly rellated to dash.js compatibility. "Video info does not contain frame duration required for calculating framerate. @frameRate is required for DASH IOP"

and the other one which I have confirmed is only about audio streams... Found a gap of size XX

Can anyone please comment if anything obvious is wrong or if the first warning in fact means that it will not work with dash.js?

My command is: bin/shaka-packager-v1-5-1 \ 'input=udp://238.0.0.1:6000,stream=video,stream_selector=0,init_segment=init-video0.m4s,segment_template=live-video0-$Number$.m4s,output_format=mp4' \ 'input=udp://238.0.0.1:6000,stream=video,stream_selector=1,init_segment=init-video1.m4s,segment_template=live-video1-$Number$.m4s,output_format=mp4' \ 'input=udp://238.0.0.1:6000,stream=video,stream_selector=2,init_segment=init-video2.m4s,segment_template=live-video2-$Number$.m4s,output_format=mp4' \ 'input=udp://238.0.0.1:6000,stream=audio,language=mkd,stream_selector=3,init_segment=init-audio-mkt.m4s,segment_template=live-audio-mkt-$Number$.m4s,bandwidth=64000,output_format=mp4' \ 'input=udp://238.0.0.1:6000,stream=audio,language=sqi,stream_selector=4,init_segment=init-audio-sqi.m4s,segment_template=live-audio-sqi-$Number$.m4s,bandwidth=64000,output_format=mp4' \ --generate_dash_if_iop_compliant_mpd=1\ --single_segment=0\ --profile live \ --mpd_output manifest.mpd

[1017/153845:INFO:demuxer.cc(60)] Initialize Demuxer for file 'udp://238.0.0.1:6000'. [1017/153845:INFO:demuxer.cc(176)] Demuxer::Run() on file 'udp://238.0.0.1:6000'. [1017/153845:WARNING:mpd_builder.cc(233)] Video info does not contain frame duration required for calculating framerate. @frameRate is required for DASH IOP. [1017/153845:WARNING:mpd_builder.cc(233)] Video info does not contain frame duration required for calculating framerate. @frameRate is required for DASH IOP. [1017/153846:WARNING:mpd_builder.cc(233)] Video info does not contain frame duration required for calculating framerate. @frameRate is required for DASH IOP. [1017/153905:WARNING:mpd_builder.cc(1265)] Found a gap of size 25 > kRoundingErrorGrace (5). The new segment starts at 231454009 but the previous segment ends at 231453984. [1017/153905:WARNING:mpd_builder.cc(1265)] Found a gap of size 24 > kRoundingErrorGrace (5). The new segment starts at 231454509 but the previous segment ends at 231454485. [1017/153915:WARNING:mpd_builder.cc(1265)] Found a gap of size 27 > kRoundingErrorGrace (5). The new segment starts at 232355212 but the previous segment ends at 232355185. [1017/153915:WARNING:mpd_builder.cc(1265)] Found a gap of size 25 > kRoundingErrorGrace (5). The new segment starts at 232354711 but the previous segment ends at 232354686. [1017/153925:WARNING:mpd_builder.cc(1265)] Found a gap of size 27 > kRoundingErrorGrace (5). The new segment starts at 233255413 but the previous segment ends at 233255386. [1017/153925:WARNING:mpd_builder.cc(1265)] Found a gap of size 26 > kRoundingErrorGrace (5). The new segment starts at 233255914 but the previous segment ends at 233255888.

I get this manifest and for me it does look ok... attached. manifest.txt

thank you in advance Haris

kqyang commented 8 years ago

The warnings at around 1017/153846 is a one-time warning, and it should not cause playback problem. The gap could lead to playback problem though.

Can you try if it works in dash-if player by packaging only a single stream, e.g.

bin/shaka-packager-v1-5-1 \
'input=udp://238.0.0.1:6000,stream=video,stream_selector=0,init_segment=init-video0.m4s,segment_template=live-video0-$Number$.m4s,output_format=mp4' \
--generate_dash_if_iop_compliant_mpd=1\
--single_segment=0\
--profile live \
--mpd_output manifest.mpd
shalinikr09 commented 8 years ago

Hi, the same is happening for ExoPlayer. I tried packaging a single stream. Even that did not work.

framerate commented 8 years ago

Funny how I always get tagged in these issues... :)

hariszukanovic commented 8 years ago

This is working now, but I in fact haven't done anything in particular.

It looks like I have had a problem of mixup between segments produced on different runs of the packager. If there is no solution for that and I should open another issue, please let me know.

For now I will comment just here: On our edge servers, we cache the segments produced by shaka packager. We do not cache the manifest.mpd itself. Our problem seems to be that, on any restart, shaka packager always produces segments that have exactly the same names as those produces on an earlier run. This is in fact expected as the segment template is the same and segment numbers always start from 0. segment_template=live-video1-$Number$.m4s produces segment_template=live-video1-0.m4s segment_template=live-video1-1.m4s segment_template=live-video1-2.m4s ... and so on..

For example in HLS (using ffmpeg), I have never had this problem since HLS chunklists allow for using the current timestamp in each chunk filename. In dash using segment_template, which AFAIK is mandatory for live streaming, this is not possibile to do.

Does shaka pacakger or dash prescribe any way of handing/escaping such situation?

thanx for comment and advice

kqyang commented 8 years ago

Sorry for the late reply.

Yes, Shaka packager and DASH support having timestamp in the segment template name with '$Time$' keyword, e.g. something like live-video1-$Time$.m4s as segment template.

A side question: if it is because of the residue files from the previous run, why not delete the files first before restarting the packager?

@shalinikr09 is your problem caused by packager restart as well?

shalinikr09 commented 8 years ago

I haven't restarted the packager. I'm trying to play content offline. It works for content which are less than 45 mins in length but doesn't work for a larger content. The exoplayer gives the following error:

FragmentedMp4Extractor not found.

kqyang commented 8 years ago

@shalinikr09 Emm.. It looks more like a exoplayer issue. You may want to report the problem to exoplayer instead.

shalinikr09 commented 8 years ago

yes, it was an issue with the player. Thank you :)

hariszukanovic commented 8 years ago

Deleting files before start does not help since they are cached on a proxy/cache server that stands before the packager.

The $Time$ is a PTS from the input stream? Normally, to make everything more stable, we regenerate the PTS at the transcoder, which after the transcoding process is restarted always resets to 0. That would make the packager generate the same filenames again.

In the mean time I believe to have solved this efficiently with a simple shell wrapper like this:

!/bin/bash

TS=$(date +%s)

exec shaka-packager \ "input=udp://239.100.100.1:6000,stream=video,stream_selector=0,init_segment=init-ts-${TS}-v0.m4s,segment_template=chunk-ts${TS}-v0-\$Number\$.m4s,output_format=mp4" \ "input=udp://239.100.100.1:6000,stream=audio,language=eng,stream_selector=1,init_segment=init-ts${TS}-a-eng.m4s,segment_template=chunk-ts${TS}-a-eng-\$Number\$.m4s,bandwidth=64000,output_format=mp4" \ --generate_dash_if_iop_compliant_mpd=1 \ --segment_duration 10 \ --profile live \ --mpd_output manifest.mpd \

kqyang commented 8 years ago

The $Time$ is a PTS from the input stream?

Yes.

exec shaka-packager \ "input=udp://239.100.100.1:6000,stream=video,stream_selector=0,init_segment=init-ts-${TS}-v0.m4s,segment_template=chunk-ts${TS}-v0-\$Number\$.m4s,output_format=mp4" \ "input=udp://239.100.100.1:6000,stream=audio,language=eng,stream_selector=1,init_segment=init-ts${TS}-a-eng.m4s,segment_template=chunk-ts${TS}-a-eng-\$Number\$.m4s,bandwidth=64000,output_format=mp4" \ --generate_dash_if_iop_compliant_mpd=1 \ --segment_duration 10 \ --profile live \ --mpd_output manifest.mpd \

Cool. That is a very clever solution!

We may add your solution to our Q&A list (to be worked). Thanks!

I am closing this bug. Feel free to re-open it if you have more questions.

hariszukanovic commented 7 years ago

Absolutely. Feel free to add this to the Q&A list.