shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.18k stars 1.34k forks source link

Unsupported HLS KEYFORMAT com.widevine #896

Closed mhassanist closed 7 years ago

mhassanist commented 7 years ago

I get this error when trying to play HLS playlist with Widevine.

Error code 4026 object Object { severity: 2, category: 4, code: 4026, data: Array[0] } myapp.js:54:3 Unsupported HLS KEYFORMAT com.widevine

I package it like that packager ^ input=input.mp4,stream=audio,segment_template=audio$Number$.ts,playlist_name=audio-playlist.m3u8 ^ input=200k.mp4,stream=video,segment_template=200k$Number$.ts,playlist_name=200k-playlist.m3u8 ^ input=400k.mp4,stream=video,segment_template=400k$Number$.ts,playlist_name=400k-playlist.m3u8 ^ input=700k.mp4,stream=video,segment_template=700k$Number$.ts,playlist_name=700k-playlist.m3u8 ^ --enable_widevine_encryption --key_server_url "https://license.uat.widevine.com/cenc/getcontentkey/widevine_test" --content_id "3031323334353637" --signer "widevine_test" --aes_signing_key "1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9" --aes_signing_iv "d58ce954203b7c9a9a9d467f59839249" --hls_master_playlist_output=master.m3u8

Is there any steps for configuring hls playing ?

TheModMaker commented 7 years ago

If you look at the logs, you probably see the following logs, right?

Widevine in HLS is only supported with SAMPLE-AES-CENC, not SAMPLE-AES

The problem is that we don't support cbc1 encryption with HLS content. Even if we did, there aren't any browsers that support it (only Safari supports CBC and doesn't support Widevine). You can specify the --protection_scheme cenc parameter to the packager to use cenc encryption, which is playable on all Widevine platforms. I don't think the packager supports it with TS output; but it does support it with MP4 output.

mhassanist commented 7 years ago

Hello, For your question, I don't see that log message, However I tried your suggestion but still not working. Here is my packaging command and the log

packager ^ input=input.mp4,stream=audio,segment_template=audio$Number$.ts,playlist_name=audio-playlist.m3u8 ^ input=200k.mp4,stream=video,segment_template=200k$Number$.ts,playlist_name=200k-playlist.m3u8 ^ input=400k.mp4,stream=video,segment_template=400k$Number$.ts,playlist_name=400k-playlist.m3u8 ^ input=700k.mp4,stream=video,segment_template=700k$Number$.ts,playlist_name=700k-playlist.m3u8 ^ --enable_widevine_encryption --key_server_url "https://license.uat.widevine.com/cenc/getcontentkey/widevine_test" --protection_scheme cenc --content_id "3031323334353637" --signer "widevine_test" --aes_signing_key "1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9" --aes_signing_iv "d58ce954203b7c9a9a9d467f59839249" --hls_master_playlist_output=master.m3u8

Log

indexed_db.js:36 IndexedDB.install
mathround.js:40 mathRound.install
mediakeys.js:43 MediaKeys.install
mediakeys.js:52 Using native EME as-is.
mediasource.js:35 MediaSource.install
mediasource.js:49 Using native MSE as-is.
promise.js:118 Using native Promises.
video_play_promise.js:35 VideoPlayPromise.install
vttcue.js:36 Using native VTTCue.
player.js:477 Unload latency: 0.002
hls_parser.js:642 Unsupported HLS KEYFORMAT com.widevine
(anonymous) @ hls_parser.js:642
(anonymous) @ hls_parser.js:625
player.js:614 load() failed: shaka.util.Error {severity: 2, category: 4, code: 4026, data: Array(0)}
myapp.js:55 Error code 4026 object shaka.util.Error {severity: 2, category: 4, code: 4026, data: Array(0)}
onError @ myapp.js:55
2hls_parser.js:642 Unsupported HLS KEYFORMAT com.widevine
(anonymous) @ hls_parser.js:642
(anonymous) @ hls_parser.js:625
mhassanist commented 7 years ago

I did not get this part "I don't think the packager supports it with TS output; but it does support it with MP4 output."

Is there any way I can do encrypted hls play list protected by widevine and play it with Shaka ? Is there any samples ?

TheModMaker commented 7 years ago

Our demo app contains an HLS Widevine asset Angel One (HLS, MP4, multilingual, Widevine). This was generated using the Shaka packager.

What I meant is that you are generating HLS with MPEG2-TS media files. The packager doesn't support cenc when using TS media, you must use cbc1. If you change to output the media in MP4 format (which is supported on more browsers), then it will be playable. To do this, you can just change the output file extensions from .ts to .mp4 (e.g. segment_template=audio$Number$.mp4).

joeyparrish commented 7 years ago

@mhassanist, to state it another way, TS content must be encrypted with a CBC scheme that is not widely supported by browsers. MP4 content can be encrypted with a CTR scheme called cenc which is widely supported. MP4 files should be preferred for compatibility with all browsers, and Shaka Packager can produce this kind of output.

mhassanist commented 7 years ago

Thanks @joeyparrish , I got your point. But when I try this I get another error

packager ^ input=input.mp4,stream=audio,segment_template=audio$Number$.mp4,playlist_name=audio-playlist.m3u8 ^ input=200k.mp4,stream=video,segment_template=200k$Number$.mp4,playlist_name=200k-playlist.m3u8 ^ input=400k.mp4,stream=video,segment_template=400k$Number$.mp4,playlist_name=400k-playlist.m3u8 ^ input=700k.mp4,stream=video,segment_template=700k$Number$.mp4,playlist_name=700k-playlist.m3u8 ^ --enable_widevine_encryption --key_server_url "https://license.uat.widevine.com/cenc/getcontentkey/widevine_test" --protection_scheme cenc --content_id "3031323334353637" --signer "widevine_test" --aes_signing_key "1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9" --aes_signing_iv "d58ce954203b7c9a9a9d467f59839249" --protection_scheme cenc --hls_master_playlist_output=master.m3u8

This error [0621/105219:ERROR:stream_descriptor.cc(194)] Stream output not specified.

mhassanist commented 7 years ago

If I understood you correctly, what I shall change is only the extension in the command ? Will I keep the .m3u8 and play list scheme ?

joeyparrish commented 7 years ago

@kqyang, can you assist with this Packager question? @mhassanist is trying to create fMP4 HLS output for playback in Shaka Player.

kqyang commented 7 years ago

@mhassanist Sorry for the misleading error message. You also need to include the init_segment in the command for fMP4. And yes, keep everything else.

Something like:

packager input=input.mp4,stream=audio,init_segment=audio_init.mp4,segment_template=audio$Number$.mp4,playlist_name=audio-playlist.m3u8 ...

mhassanist commented 7 years ago

@kqyang I tried you suggestion and I still get the same error message

packager ^ input=input.mp4,stream=audio,init_segment=audio_init.mp4,segment_template=audio$Number$.mp4,playlist_name=audio-playlist.m3u8 ^ input=200k.mp4,stream=video,segment_template=200k$Number$.mp4,playlist_name=200k-playlist.m3u8 ^ input=400k.mp4,stream=video,segment_template=400k$Number$.mp4,playlist_name=400k-playlist.m3u8 ^ input=700k.mp4,stream=video,segment_template=700k$Number$.mp4,playlist_name=700k-playlist.m3u8 ^ --enable_widevine_encryption --key_server_url "https://license.uat.widevine.com/cenc/getcontentkey/widevine_test" --protection_scheme cenc --content_id "3031323334353637" --signer "widevine_test" --aes_signing_key "1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9" --aes_signing_iv "d58ce954203b7c9a9a9d467f59839249" --protection_scheme cenc --hls_master_playlist_output=master.m3u8

[0622/124711:ERROR:stream_descriptor.cc(194)] Stream output not specified.

joeyparrish commented 7 years ago

It looks like you only put init_segment on the audio. It must be in every stream.

TheModMaker commented 7 years ago

@mhassanist Did you get the packager command to work? Is there anything else we can do?

joeyparrish commented 7 years ago

Closing due to inactivity. We can reopen at any time if you need further assistance.