A couple of users have reported (in Github #15) that when they enable encryption, nothing happens
An example call provided is
./HLS-Stream-Creator.sh -i trailer.mov -s 10 -e -o trailer -b 272,872,1372,1872
When the issue was originally raised I ran a test and it seemed to work, but the original user never provided the further info I asked for.
Another user has reported the same issue (in the same thread) and has provided the commandline above, so need to revisit this
Activity
2017-04-26 19:57:35
2017-04-26 20:06:26
All looks fine so far.
Now with encryption enabled
That's running, but encryption doesn't happen until the end, so will need to wait for the transcodes to complete. Will have a look over the code while I wait
2017-04-26 20:16:27
I don't see anything odd on either stdout or stderr
I wonder if it might be a weird product of creating an Adaptive stream. Will re-run with a single bitrate and see if encrypt then gets called
2017-04-26 20:26:17
Was definitely working before?
2017-04-26 20:30:44
It's a result of the conditional at Line 353 ( https://github.com/bentasker/HLS-Stream-Creator/blob/4a9e0a019f3eed8036836b37c93e213a03c0fade/HLS-Stream-Creator.sh#L353 )
If bitrates have been specified in the argument list, we fork off down a different code path (because we need to spin up sub-processes etc). Processing effectively ends once awaitCompletion has done it's bit.
The call to encrypt happens in the other (smaller) code path, that we follow when bitrates haven't been explicitly specified, essentially everything below the else at line 438 ( https://github.com/bentasker/HLS-Stream-Creator/blob/4a9e0a019f3eed8036836b37c93e213a03c0fade/HLS-Stream-Creator.sh#L438 )
So the original pull request was wrong. Damn, I should've caught that
2017-04-26 21:00:00
Specify a single bitrate on the CL
Not perfect though, the m3u8 rewrite is using an incorrect manifest name
Thinking about it, the key will need to be written into the bitrate manifests (and not the master) anyway. I'm going to put that into a seperate commit
Test with no bitrate specified
And (expectedly) no complaints about not being able to find the manifest.
Checking playback
Playback fails.
Looking in the access logs, VLC is requesting a range
The 206 is just because VLC requests uses "Range: bytes=0-"
Getting 16 bytes back, which should be right, the HLS spec says
OK, need to look into that then. No point encrypting if you can't play back (the ultimate DRM :D)
2017-04-26 21:17:16
Something's done horribly wrong there :(
OK, lets manually run an encrypt and see where we get. Will use one of the cleartext segments from the tests where encryption didn't run. Using the same key as the one above
Which would suggest something's going wrong in script and affecting the segments themselves, rather than specifically being an issue with the key. As a starting point, have dropped an echo into the script and set a run going to see exactly what's being run
2017-04-26 21:23:41
If I remove the key definition from the manifest, the video plays, so the fragments aren't being encrypted. A quick check with xxd confirms
There's obviously something wrong with the for loop in encrypt. The complaints about invalid length are, of course, because the data's not padded (because it's not encrypted in the first place)
2017-04-26 21:26:12
ben@milleniumfalcon:/tmp/hlstest/HLS-Stream-Creator$ OUTPUT_DIRECTORY='test9' ben@milleniumfalcon:/tmp/hlstest/HLS-Stream-Creator$ export OUTPUT_DIRECTORY ben@milleniumfalcon:/tmp/hlstest/HLS-Stream-Creator$ for file in $(ls ${OUTPUT_DIRECTORY}/*.ts | cut -f3 -d '/'); do echo "$file"; doneLet's take the subcommand out of it (I don't particularly like the variable being called file either, but will fix that once I've sorted the iteration out)
2017-04-26 21:37:58
test10/test10/big_buck_bunny_720p_stereo.avi_00059.ts: No such file or directory 139653670704792:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('test10/test10/big_buck_bunny_720p_stereo.avi_00059.ts','r') 139653670704792:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400: mv: cannot stat 'test10/big_buck_bunny_720p_stereo.avi_enc_59.ts': No such file or directoryThough the commands being run now look more or less right (aside from the input file path being incorrect)
Next test run underway. I really wish I'd checked that pull more carefully, I'm not convinced this should ever have worked fully, unless you specified an absolute path for the output directory
2017-04-26 21:43:19
ben@milleniumfalcon:/tmp/hlstest/HLS-Stream-Creator$ xxd test11/big_buck_bunny_720p_stereo.avi_00000.ts | head -n 25 00000000: 6969 bede 9aac 3913 564c 457b 42b9 6559 ii....9.VLE{B.eY 00000010: b4eb a4db 5089 a843 b0bb 09c4 7f94 6186 ....P..C......a. 00000020: 0056 9c11 6e3c 10c5 8408 bc45 22c0 c0cb .V..n<.....E"... 00000030: 01b4 b548 4e78 2c9e b36f 8452 557b cf81 ...HNx,..o.RU{.. 00000040: 2d38 06e5 8809 f27e cc89 32e5 b8bd 187c -8.....~..2....| 00000050: 7d59 49ee 2579 cb9d 0fde 9ed9 8d9b 41d5 }YI.%y........A. 00000060: 23fa fb2e 4baa c783 a8ef e8ee 5d9d 288a #...K.......].(. 00000070: e1c0 d5e0 932a c9e2 0006 ce92 7624 cf37 .....*......v$.7 00000080: b609 a817 a0e5 4239 328c dfa7 22ff 6ec4 ......B92...".n. 00000090: 6852 cd1f b784 8f20 3928 a3db 765a f912 hR..... 9(..vZ.. 000000a0: b49f 2d04 9b3c e9bb 546a 46f4 c1df 9367 ..-..<..TjF....g 000000b0: 3a3b abc1 c33b b43b c1b1 395f f067 76a6 :;...;.;..9_.gv. 000000c0: 72e6 4f71 d94e 10ae 39a8 01db 6a18 c133 r.Oq.N..9...j..3 000000d0: e7dc 2148 5b17 b823 2b80 92db 6692 c0b0 ..!H[..#+...f... 000000e0: 2f5d e226 3c51 1fb9 9afb 94ce 3fc2 399f /].&<Q......?.9. 000000f0: 385a 8bb1 261f 61c2 12bd 827f f2f8 ff11 8Z..&.a......... 00000100: 9510 0fc8 a33b 88c7 7d3e a15d b80b 288e .....;..}>.]..(. 00000110: d6fa 6f16 d7e4 cbe3 4b06 1c0e 3435 741e ..o.....K...45t. 00000120: 7084 3000 93a5 905f 3bce 0462 98cc 5f03 p.0...._;..b.._. 00000130: c172 d286 52b3 412c f9a8 7e46 b278 85e2 .r..R.A,..~F.x.. 00000140: a22f 7f53 2e14 df63 7dbe b279 61b2 7cb7 ./.S...c}..ya.|. 00000150: 233f daf0 9682 216d 142b 44d4 9572 98a7 #?....!m.+D..r.. 00000160: 021e 2a1f c9d7 9c5b dc8c 975d 9c4f 7476 ..*....[...].Otv 00000170: b7b7 aa8b dd88 6100 841f 3e1a a4ed 334d ......a...>...3M 00000180: 915a 5c50 06d8 2b9a 9619 4313 cdad fcb4 .Z\P..+...C.....VLC no longer complains about the key, and ffplay can correctly play the stream back
VLC also plays back.
Will commit the fixes made so far, and fix the manifest location issue in encrypt so that this should all work with adaptive streams (as well as single bitrate streams where only one bitrate has been specified)
2017-04-26 21:44:51
Webhook User-Agent
View Commit
2017-04-26 21:44:52
Webhook User-Agent
View Commit
2017-04-26 22:02:27
No complaints this time
Playback works, and the segments are definitely encrypted
Testing with a single bitrate specified
I'm happy with that, will commit and push the changes.
Need to update the README to reference the encryption flag before closing this issue though
2017-04-26 22:04:51
Webhook User-Agent
View Commit
2017-04-26 22:08:17
2017-04-26 22:08:51
Webhook User-Agent
View Commit
2017-04-26 22:14:08
Marking as fixed as all my tests have passed. Will re-open if the users report they're still have issues
2017-04-26 22:14:08
2017-04-26 22:14:08
2017-04-26 22:14:13
2017-04-26 22:19:37
2017-04-26 22:19:37
2017-04-26 22:19:56
2017-04-26 22:20:00
2017-04-26 22:20:00
2017-04-26 22:20:04
2017-04-29 11:44:51
Webhook User-Agent
View Commit