mangui / flashls

HLS Flash Plugin/Player (Chromeless,OSMF,FlowPlayer,mediaelement.js,video.js,Clappr)
http://www.flashls.org
Mozilla Public License 2.0
751 stars 264 forks source link

HLS-AES128 playback fail if IV present in playlist or non zerro #345

Open rsereda opened 9 years ago

rsereda commented 9 years ago

The is two skeegle HLS-AES128 stream http://d39schri37b7n1.cloudfront.net/1e99251c4710b3717d043e99f6464460897b1b9b28e1c3a56950c03282e98720/hls/playlist.m3u8 - the is static video on demand stream generated by ffmpeg tool

https://d39schri37b7n1.cloudfront.net/vods3/_definst_/mp4:amazons3/skgl-pre-prd-content/wowza-recordings/d8770027b9d55911f37c24ab96e9d11d26033ff0978b6f9f25aed236d9dff7bb.mp4/playlist.m3u8 - the is dynamic stream generated by wowza media server 4.1.0

Both stream can play on mobile devices and tool like ffplay from ffmpeg pocket and VLC

$ ffplay http://d39schri37b7n1.cloudfront.net/1e99251c4710b3717d043e99f6464460897b1b9b28e1c3a56950c03282e98720/hls/playlist.m3u8 ffplay version 2.6.git Copyright (c) 2003-2015 the FFmpeg developers built with gcc 4.9.1 (Ubuntu 4.9.1-16ubuntu6) configuration: --prefix=/home/rsereda/ffmpeg_build --extra-cflags=-I/home/rsereda/ffmpeg_build/include --extra-ldflags=-L/home/rsereda/ffmpeg_build/lib --bindir=/home/rsereda/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-openssl libavutil 54. 22.100 / 54. 22.100 libavcodec 56. 34.100 / 56. 34.100 libavformat 56. 29.100 / 56. 29.100 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 13.101 / 5. 13.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 [mpegts @ 0x7fa43c00d5e0] DTS discontinuity in stream 0: packet 3 with DTS 134371, packet 4 with DTS 138510 [hls,applehttp @ 0x7fa43c004ac0] DTS discontinuity in stream 0: packet 3 with DTS 134371, packet 4 with DTS 138510 Input #0, hls,applehttp, from 'http://d39schri37b7n1.cloudfront.net/1e99251c4710b3717d043e99f6464460897b1b9b28e1c3a56950c03282e98720/hls/playlist.m3u8': Duration: 00:02:37.15, start: 1.400000, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 1280x720, 90k tbr, 90k tbn, 180k tbc Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 61 kb/s 3.71 A-V: 0.031 fd= 19 aq= 1KB vq= 36KB sq= 0B f=0/0

Also I catch this stream URL in google search http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes.m3u8 

than can play at this test player http://demo.jwplayer.com/stream-tester/

This stream is AES128 encrypted byt. The is one different

The is part of playlist oceans_aes.m3u8

EXT-X-KEY:METHOD=AES-128,URI="oceans.key"

And this similart part of playlist from sceegleapp streams

EXT-X-KEY:METHOD=AES-128,URI="https://preprod.skeegleapp.com/api/v1/aeskey/d8770027b9d55911f37c24ab96e9d11d26033ff0978b6f9f25aed236d9dff7bb",IV=0x6c51501334563809b2f83e264e6dc208,KEYFORMATVERSIONS="1"

From wowza

and

EXT-X-KEY:METHOD=AES-128,URI="https://preprod.skeegleapp.com/api/v1/aeskey/1e99251c4710b3717d043e99f6464460897b1b9b28e1c3a56950c03282e98720",IV=0x32E14FF7D2D8D378BED758CD0B6EBF28

from ffmpeg tool

SO different in #IV# that is described at this part of specification https://tools.ietf.org/html/draft-pantos-http-live-streaming-13#ref-AES_128

cromeless console output [Mon Jul 27 2015 15:13:53 GMT+0300 (EEST)] onHLSReady() 2(program):1 INFO:HLSNetStream:close www.flashls.org/:291 [Mon Jul 27 2015 15:14:06 GMT+0300 (EEST)] load URL http://d39schri37b7n1.cloudfront.net/1e99251c4710b3717d043e99f6464460897b1b9b28e1c3a56950c03282e98720/hls/playlist.m3u8 www.flashls.org/:291 [Mon Jul 27 2015 15:14:06 GMT+0300 (EEST)] new track list www.flashls.org/:291 [Mon Jul 27 2015 15:14:06 GMT+0300 (EEST)] manifest loaded, playlist duration:157.15 (program):1 INFO:HLSNetStream:play(-1) (program):1 INFO:HLSNetStream:seek(-1)

flowplayer console output

LOG] time 15:16:59.243 :: org.flowplayer.controller::PlayListController : moving to state [object WaitingState] VM177:1 [LOG] time 15:16:59.257 :: org.flowplayer.controller::WaitingState : is active: true VM179:1 [LOG] time 15:16:59.263 :: org.flowplayer.controller::LocalSOVolumeStorage : in constructor VM181:1 [LOG] time 15:16:59.266 :: org.flowplayer.controller::LocalSOVolumeStorage : get volume undefined VM189:1 [LOG] time 15:16:59.437 :: org.flowplayer.controller::WaitingState : startBuffering() VM191:1 [LOG] time 15:16:59.443 :: org.flowplayer.controller::WaitingState : dispatchBeforeEvent() onBegin, current clip [Clip] 'https://d39schri37b7n1.cloudfront.net/vods3/_definst_/mp4:amazons3/skgl-pre…b9d55911f37c24ab96e9d11d26033ff0978b6f9f25aed236d9dff7bb.mp4/playlist.m3u8' VM193:1 [LOG] time 15:16:59.445 :: org.flowplayer.controller::WaitingState : canOnEvent(): dispatching before event for onBegin VM196:1 [LOG] time 15:16:59.467 :: org.flowplayer.controller::PlayListController : moving to state [object BufferingState] VM198:1 [LOG] time 15:16:59.469 :: org.flowplayer.controller::WaitingState : is active: false VM200:1 [LOG] time 15:16:59.471 :: org.flowplayer.controller::BufferingState : is active: true VM202:1 [LOG] time 15:16:59.474 :: org.flowplayer.controller::WaitingState : calling onEvent(onBegin) on media controller VM204:1 [LOG] time 15:16:59.477 :: org.flowplayer.controller::StreamProviderController : calling doLoad VM206:1 [INFO] time 15:16:59.484 :: org.flowplayer.controller::StreamProviderController : onBegin, initializing content for clip [Clip] 'https://d39schri37b7n1.cloudfront.net/vods3/_definst_/mp4:amazons3/skgl-pre…b9d55911f37c24ab96e9d11d26033ff0978b6f9f25aed236d9dff7bb.mp4/playlist.m3u8' VM233:1 [LOG] time 15:17:00.317 :: org.flowplayer.controller::BufferingState : moving to state [object PausedState] VM235:1 [LOG] time 15:17:00.320 :: org.flowplayer.controller::PlayListController : moving to state [object PausedState] VM237:1 [LOG] time 15:17:00.322 :: org.flowplayer.controller::BufferingState : is active: false VM239:1 [LOG] time 15:17:00.326 :: org.flowplayer.controller::PausedState : is active: true VM241:1 [LOG] time 15:17:00.328 :: org.flowplayer.controller::PausedState : adding event listeners VM254:1 [LOG] time 15:17:08.580 :: org.flowplayer.controller::PlayListController : resume(), silent? false VM256:1 [LOG] time 15:17:08.582 :: org.flowplayer.controller::PausedState : resume(), changing to stage [object PlayingState] VM258:1 [LOG] time 15:17:08.583 :: org.flowplayer.controller::PausedState : dispatchBeforeEvent() onResume, current clip [Clip] 'https://d39schri37b7n1.cloudfront.net/vods3/_definst_/mp4:amazons3/skgl-pre…b9d55911f37c24ab96e9d11d26033ff0978b6f9f25aed236d9dff7bb.mp4/playlist.m3u8' VM260:1 [LOG] time 15:17:08.585 :: org.flowplayer.controller::PausedState : canOnEvent(): dispatching before event for onResume VM263:1 [LOG] time 15:17:08.591 :: org.flowplayer.controller::PlayListController : moving to state [object PlayingState] VM265:1 [LOG] time 15:17:08.592 :: org.flowplayer.controller::PausedState : is active: false VM267:1 [LOG] time 15:17:08.594 :: org.flowplayer.controller::PlayingState : is active: true VM269:1 [LOG] time 15:17:08.596 :: org.flowplayer.controller::PlayingState : adding event listeners VM271:1 [LOG] time 15:17:08.597 :: org.flowplayer.controller::PausedState : calling onEvent(onResume) on media controller

mangui commented 9 years ago

hi @rsereda this stream plays fine with flashls http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes.m3u8

regarding your stream, I am suspecting a cross domain issue when Flash Player is trying to load the key. plz check your crossdomain.xml on your key server.

rsereda commented 9 years ago

Hello

I test my crossdomain.xls

The is key URL https://preprod.skeegleapp.com/api/v1/aeskey/1e99251c4710b3717d043e99f6464460897b1b9b28e1c3a56950c03282e98720

And crossdomain call

$ curl https://preprod.skeegleapp.com/crossdomain.xml
     <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-              policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*"/>
</cross-domain-policy>

Also I test stream server crossdomain

$ curl http://d39schri37b7n1.cloudfront.net/crossdomain.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <allow-access-from domain="*" secure="false"/>
    <site-control permitted-cross-domain-policies="all"/>
</cross-domain-policy>
mangui commented 9 years ago

ok, have you tried adding secure="false" to https://preprod.skeegleapp.com/crossdomain.xml ?

mangui commented 9 years ago

because I checked and flashls is definitely stuck on key loading. the last thing I see is in access to crossdomain.xml for an unknown reason the SECURITY_ERROR handler is not triggered ... https://github.com/mangui/flashls/blame/dev/src/org/mangui/hls/loader/FragmentLoader.as#L724 in theory this should happen in that case.

rsereda commented 9 years ago

Hello

I retest all carefully and I can confirm that IV values did not play in this issue. This issue happened with stream that have or happened this IV values.

the is stream without IV https://d39schri37b7n1.cloudfront.net/43865d1fbe63d87c1fd01489d4dcfd31817266ffb3f376209549f4784f8d450a/hls/playlist.m3u8

Also i can confirm that other flash player that did not use you plugin have similar issue. But ffplay version 2.6.git and vlc 2.2.0 and android 5.1 play this stream without issue.

Also I set secure="false" to https://preprod.skeegleapp.com/crossdomain.xml - did not help.

mangui commented 9 years ago

it looks like loading HTTPS from HTTP could be tricky, you might have to tweak your swf, see below http://www.liquidcomposition.com/devblog/?p=9