在android中使用ffmpeg下载m3u8格式

时间:2017-06-19 09:50:37

标签: android ffmpeg hls m3u8 android-ffmpeg

我想在Android上下载一个m3u8 hls视频。 我正在使用这个https://github.com/WritingMinds/ffmpeg-android-java github项目。 我的代码运行完美,像这样的文件

#EXTM3U
#EXT-X-VERSION:5
#EXT-X-STREAM-INF:BANDWIDTH=560000,RESOLUTION=560x320
chunklist_w1370359847_b560000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=280000,RESOLUTION=280x160
chunklist_w1370359847_b280000.m3u8

但是当我想要其他一些像

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=307200
http://example.com/hls.m3u8?mwk=8337411690192241322178516954798640895&s=67456834233263474843895996561490854813
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3584000
http://example.com/hls.m3u8?mwk=8337411690192241322178516954798640895&s=67917168793981422148373769951238010028
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2457600
http://example.com/hls.m3u8?mwk=8337411690192241322178516954798640895&s=58718242671779879146351545392642701787
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1228800
http://example.com/hls.m3u8?mwk=8337411690192241322178516954798640895&s=76033982771160137261725364336240341356
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=614400
http://example.com/hls.m3u8?mwk=8337411690192241322178516954798640895&s=8799167971211576392205612488036401876
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=65536
http://example.com/hls.m3u8?mwk=8337411690192241322178516954798640895&s=84365905843905491151101581870671639752

,我收到Protocol not found错误。 我的网址是http,我用下面的命令

String.format("-i %s -acodec %s -bsf:a aac_adtstoasc -vcodec %s %s", mM3u8Url, "copy", "copy", dir.toString() + "/" + mContentId + ".mp4");

1 个答案:

答案 0 :(得分:0)

也许你的m3u8是加密的。你能找到"#EXT-X-KEY:METHOD = AES-128"在你的m3u8中,这意味着你需要解码它。