axiomatic-systems / Bento4

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

Subtitles (WebVTT) not added to HLS playlist when running mp4dash with --hls #659

Closed nilmic closed 2 years ago

nilmic commented 2 years ago

Got some errors when running mp4dash and the Subtitles (WebVTT) are missing in the master HLS playlist.

How to reproduce: Bento4-SDK-1-6-0-639.x86_64-unknown-linux/bin/mp4dash --profiles=live --hls --output-dir=/tmp/mp4dash-errors /tmp/F0110641_806kbps.fmp4 /tmp/F0110641_320kbps.fmp4 /tmp/F0110641_1312kbps.fmp4 /tmp/F0110641_2069kbps.fmp4 /tmp/F0110641_3100kbps.fmp4 [+format=webvtt,+language=swe,+language_name=Svenska]/var/packager-testfiles/F0110641/219714-13.vtt

Errors:

Line 1043: ERROR: local variable 'language_name' referenced before assignment
# Might be fixed by changing line 1043 "language_name" to "subtitles_file.language_name"

Line 1044: ERROR: 'SubtitlesFile' object has no attribute 'hls_autoselect'
# Might be fixed by changing line 1044 "'YES' if subtitles_file.hls_autoselect else 'NO'," to "'YES' if hasattr(subtitles_file, 'hls_autoselect') and subtitles_file.hls_autoselect else 'NO',"

Suggested changes as a patch :

--- Bento4-SDK-1-6-0-639.x86_64-unknown-linux/utils/mp4-dash.py.orig    2021-11-09 14:04:47.698302013 +0100
+++ Bento4-SDK-1-6-0-639.x86_64-unknown-linux/utils/mp4-dash.py 2021-11-16 10:41:51.057855875 +0100
@@ -1040,8 +1040,8 @@
             if default:
                 default_selected = True
             master_playlist_file.write('#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitles",NAME="{}",AUTOSELECT={},DEFAULT={},LANGUAGE="{}",URI="{}/{}"\n'.format(
-                                       language_name,
-                                       'YES' if subtitles_file.hls_autoselect else 'NO',
+                                       subtitles_file.language_name,
+                                       'YES' if hasattr(subtitles_file, 'hls_autoselect') and subtitles_file.hls_autoselect else 'NO',
                                        'YES' if default else 'NO',
                                        subtitles_file.language,
                                        media_subdir,
barbibulle commented 2 years ago

Thanks for reporting this. The issue should be fixed with the latest commit, which fixes #667 (same issue)

ryankashi commented 1 year ago

Hi!

I am using the Bento4 binaries for windows downloaded from your website:

https://www.bento4.com/downloads/

I am using the command: mp4dash --hls "input_video_360p.mp4" "input_video_480p.mp4" [+format=webvtt,+language=en,+language_name=English]subtitle_track_en.vtt [+format=webvtt,+language=es,+language_name=Spanish]subtitle_track_es.vtt -o "output_videos/my_output"

And it returns the error: ERROR: cannot access local variable 'language_name' where it is not associated with a value

and I am still running into the issue where subtitles are not added to HLS playlists. Do you know if this is an issue with the official binaries not being up-to-date, or do we need to reopen this issue?

clia6547 commented 1 year ago

I run this on version 1.6.0-639 on M2 chip and got ERROR: local variable 'language_name' referenced before assignment