axiomatic-systems / Bento4

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

MP4DASH --hls option with AES Encryption #600

Open ashutoshsingh0223 opened 3 years ago

ashutoshsingh0223 commented 3 years ago

I am trying to output my clearkey encrypted DASH manifest and AES-128 HLS manifest like this.

mp4dash 1080-frag.mp4 720-frag.mp4 480-frag.mp4 audio-frag.mp4 -o ready 
-f --profiles='on-demand'='urn:mpeg:dash:profile:isoff-on-demand:2011' 
--use-segment-timeline --clearkey
--encryption-key=55a71282cdb0f27cf5aae74c1d06262a:687a6ad8f817d7cca5510acc76720636 
--clearkey-license-uri="https://dev.flowgiga.com/ninerasa/license/" 
--hls --hls-key-url="https://dev.flowgiga.com/ninerasa/license/" 
--encryption-cenc-scheme=cbcs 
--subtitles [+format=webvtt,+language=eng]PAUSE_FINAL.mp4.eng.srt

Then I created my test.key file with binary key like this:

export AA=687a6ad8f817d7cca5510acc76720636 
echo ${AA} | xxd -p -r > test.key

Now I am delivering the manifest created as content-type:application/vnd.apple.mpegurl and test.key as content-type:application/pgpkeys and I also tried with content-type:application/octet-stream.

When I run this is safari my payback starts and timer starts moving but I cannot see anything in the video.

Am in doing something wrong.

ashutoshsingh0223 commented 3 years ago

On other note

 mp4hls 480.mp4 audio.mp4 -o encrypt  --encryption-mode=SAMPLE-AES 
--encryption-key=3f59234ba0dce26165b94ad867069341  
--encryption-iv-mode=random 
--encryption-key-uri="https://dev.flowgiga.com/key/test.key"
 mp4hls 480.mp4 audio.mp4 -o encrypt  --encryption-mode=SAMPLE-AES 
--encryption-key=3f59234ba0dce26165b94ad867069341 
--encryption-key-uri="https://dev.flowgiga.com/key/test.key"

The above commands don't work when I use my own delivery service. I am delivering test.key file through nginx. File has the following permissions -rw-r--r-- 1 ubuntu ubuntu 17 Apr 26 09:39 /var/www/test.key

The below command works and output is key.bin with the same binary content as test.key and similar permissions. Only difference is one is using relative URL and other a key service as mentioned in the above commands

mp4hls 480.mp4 audio.mp4 -o reencrypt 
--encryption-mode=SAMPLE-AES  
--encryption-key=3f59234ba0dce26165b94ad867069341 
--output-encryption-key