axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
2k stars 482 forks source link

Issue with mp4-dash.py --no-media is failing when generating HLS #524

Open jimmymic opened 4 years ago

jimmymic commented 4 years ago

We have recently upgraded from an older version of Bento4 and are having trouble with the mp4-dash.py command when using the --no-media option.

1) if the directories do not already exist for the output manifests then it fails to run. 2) if you are trying to generate HLS manifests then the --no-media option no longer works - it throws a Divide by Zero error. The same command will work if you do not include the --no-media option

Example command:

python3 /usr/local/bento4/utils/mp4-dash.py --debug --verbose --profiles live --no-media --encryption-key 20CB603EB1004631995F10632886436E:E1D1720390175EC741C4ED64CEC4B91B:5406893dbf67e0e42ff42c21e1f72ad5 --encryption-cenc-scheme=cbcs --hls --hls-master-playlist-name 2514352DA3173658674E78FEFF499004_fmp4.m3u8 --fairplay-key-uri skd://randomkeyserver.com/FairPlay/?KID=20cb603e-b100-4631-995f-10632886436e --force --use-segment-timeline -o fairplay 2514352DA3173658674E78FEFF499004_1080p-clean.mp4-fragmented.mp4 2514352DA3173658674E78FEFF499004_720p-clean.mp4-fragmented.mp4 2514352DA3173658674E78FEFF499004_480p-clean.mp4-fragmented.mp4

Traceback (most recent call last): File "/usr/local/bento4/utils/mp4-dash.py", line 2142, in main() File "/usr/local/bento4/utils/mp4-dash.py", line 2124, in main OutputHls(options, set_attributes, audio_sets, video_sets, subtitles_sets, subtitles_files) File "/usr/local/bento4/utils/mp4-dash.py", line 940, in OutputHls iframe_average_segment_bitrate,iframe_max_bitrate = OutputHlsIframeIndex(options, video_track, all_audio_tracks + all_video_tracks, media_subdir, iframes_playlist_name, media_file_name) File "/usr/local/bento4/utils/mp4-dash.py", line 817, in OutputHlsIframeIndex iframe_average_segment_bitrate = 8.0*(iframe_total_segment_size/iframe_total_segment_duration) ZeroDivisionError: division by zero

barbibulle commented 4 years ago

I will have a fix for this shortly. But please note that the --no-media option is an advanced option that requires some planning: if you don't want mp4dash to output any processed media, you need to ensure that the media is already at its final destination (i.e where the tool would have put it if you had not used --no-media). If the media isn't there, some things won't work, like for instance the computation of the I-Frame playlist for HLS, which requires parsing the actual media segments in order to find the key frames.

jimmymic commented 4 years ago

Thanks @barbibulle. Just a clarification - previously the --no-media option appeared to use the source files for generating the manifest simply without outputting the media. From your comment it looks like the output files should be already generated and it will now utilize those for generating the manifest?

We had previously been using the --no-media option successfully without the output files in place.

barbibulle commented 4 years ago

If the output files are not present at the time when you invoke mp4dash, almost everything will work, because the details of the final segments are not needed, except for the generation of the I-Frame playlist for HLS (that is used for fast scrubbing of the video) in the case where individual segment files are used, because the location of I-frames in the segment cannot be inferred by just parsing the un-segmented input files. If you don't use HLS, or don't split the media into individual segment files, then you're fine.