bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.59k stars 8.14k forks source link

分段播放视频 ffconcat.ffconcat: Protocol not found #1180

Closed simtice closed 8 years ago

simtice commented 8 years ago

写了一段ffconcat的txt:

ffconcat version 1.0 file http://cn-gdfs5-dx.acgvideo.com/vg7/2/0e/6546710-1.flv?expires=1460724300&ssig=yqOcE8bCE8ntlgkB1v7rqQ&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0 duration 267544 file http://cn-gdfs5-dx.acgvideo.com/vg7/2/0e/6546710-2.flv?expires=1460724300&ssig=jJ_iWb08zIhLxU6KICXx4w&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0 duration 442732 file http://cn-gdfs5-dx.acgvideo.com/vg7/2/0e/6546710-3.flv?expires=1460724300&ssig=T-c2-csCpdmW3xuCdKIHGg&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0 duration 276423

然后使用VideoView.setVideoURI(“ffconcat://.... /ffconcat.ffconcat”) 提示ffconcat.ffconcat: Protocol not found,是什么原因呢,怎么解决

Android4MediaPlayer commented 8 years ago

放本地测试可以这样,VideoView.setVideoURI(“/sdcard/ffconcat.concat”)

simtice commented 8 years ago

@Android4MediaPlayer 使用mVideoView.setVideoPath(“/sdcard/ffconcat.concat”) 提示ffconcat.concat: Invalid data found when processing input, 是文件数据有问题么?还是视频源本身有问题?

Android4MediaPlayer commented 8 years ago

用的哪个版本播放

simtice commented 8 years ago

@Android4MediaPlayer 刚用最新版本试了下,提示: IJKMEDIA: Protocol not on whitelist 'file'! IJKMEDIA: Impossible to open 'http://cn-gdjm5-dx.acgvideo.com/vg6/8/8a/6546710-1.flv?expires=1460722500&ssig=pnYEiyDaFmmHBuuqkdQ7Xw&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0' JKMEDIA: /storage/emulated/0/ffconcat.concat: Invalid argument

simtice commented 8 years ago

@Android4MediaPlayer 能否帮忙测试一下上面的这个文件,看到底是数据源的问题还是哪里出了问题 另外,我用同样的数据构造了一个m3u8文件:

EXTM3U

EXT-X-TARGETDURATION:986699

EXTINF:267544

http://cn-gdjm5-dx.acgvideo.com/vg6/8/8a/6546710-1.flv?expires=1460728200&ssig=ugAKG4ri5--IrDsb1KeYhQ&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0

EXTINF:442732

http://cn-gdjm5-dx.acgvideo.com/vg6/8/8a/6546710-2.flv?expires=1460728200&ssig=k69slVHjhfna8nvxNRNX-A&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0

EXTINF:276423

http://cn-gdjm5-dx.acgvideo.com/vg6/8/8a/6546710-3.flv?expires=1460728200&ssig=y1AntuA5QJz7fCFBOkLwIg&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0

EXT-X-ENDLIST

报这个错: IJKMEDIA: Protocol not on whitelist 'file'! IJKMEDIA: Failed to open segment of playlist 0 IJKMEDIA: Protocol not on whitelist 'file'! IJKMEDIA: Failed to open segment of playlist 0 IJKMEDIA: Protocol not on whitelist 'file'! IJKMEDIA: Failed to open segment of playlist 0 IJKMEDIA: Error when loading first segment 'http://cn-gdjm5-dx.acgvideo.com/vg6/8/8a/6546710-1.flv?expires=1460729700&ssig=wvZYpvCyW4gU4lLO9yEDIQ&oi=3070666578&appkey=f3bb208b3d081dc8&or=3074230573&rate=0' IJKMEDIA: /storage/emulated/0/test.m3u8: Invalid data found when processing input

Protocol not on whitelist 'file'! 这个提示代表啥意思呢?两个文件都提示了

Android4MediaPlayer commented 8 years ago

建议你用回上一个版本0.4,ffmpeg3.0加入黑白名单,有好多规范限制更标准化

simtice commented 8 years ago

@Android4MediaPlayer 换回0.5.0之前的版本确实可以了,非常感谢,但如果使用0.5.0的版本该怎么处理上面的问题呢

Android4MediaPlayer commented 8 years ago

那就先用之前的版本

bbcallen commented 8 years ago

https://ffmpeg.org/ffmpeg-protocols.html#Protocol-Options

CoXier commented 7 years ago

@bbcallen I use the newest version of this lib.In the example you provided,I add following code in IjkVideoView to support concat.

 ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "protocol_whitelist ", "ffconcat,file,crypto");
 ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"safe",0);

But it seems not useful for me:

E/IJKMEDIA: Protocol not on whitelist 'file,crypto'!

Thanks

TedaLIEz commented 7 years ago

@CoXier @simtice Add those settings to your ijkMediaPlayer :

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "protocol_whitelist ", "ffconcat,file,http,https"); ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"safe",0);

this works with ijkplayer v0.7.6 on my OnePlus3, the content of whitelist is up to you. It is not clear about the relationships between the constant in IjkMediaPlayer and ffmpeg. Maybe some docs are needed.

p.s I found some issues that do not include spaces between the protocol in protocol_whitelist, I haven't tried this, just be aware of it.

edit: thanks to @NotLooker, I made a mistake here:

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "protocol_whitelist ", "ffconcat,file,http,https");

should be:

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "protocol_whitelist ", "ffconcat,file,http,https");

NotLooker commented 7 years ago

@TedaLIEz Are you sure add this settings? ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "protocol_whitelist ", "ffconcat,file,http,https");

type isn't IjkMediaPlayer.OPT_CATEGORY_PLAYER; you should set ' OPT_CATEGORY_FORMAT'; add this code: ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "protocol_whitelist", "concat,file,subfile,http,https,tls,rtp,tcp,udp,crypto");

it can set player file and the concat can use m3u8.

TedaLIEz commented 7 years ago

@NotLooker You're right. Sorry for the typo :D

huangjianfeng1 commented 7 years ago

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"safe",0); ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "protocol_whitelist ", "ffconcat,crypto,file,http,https");

it seems not useful for me: E/IJKMEDIA: Protocol not on whitelist 'file,crypto'! Impossible to open 'http://gslb.miaopai.com/stream/bfuYKGig5EtL1mEbxjBk~I~4TT4y1tWK.mp4' E/IJKMEDIA: /storage/emulated/0/ggzu/temp.ffconcat: Invalid argument E/tv.danmaku.ijk.media.player.IjkMediaPlayer: Error (-10000,0)

NotLooker commented 7 years ago

@huangjianfeng1 看了下源码,ijk本身的白名单设置被重载覆盖了,所以这里应该吧白名单协议扩展; ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "protocol_whitelist", "async,cache,crypto,file,http,https,ijkhttphook,ijkinject,ijklivehook,ijklongurl,ijksegment,ijktcphook,pipe,rtp,tcp,tls,udp,ijkurlhook,data,concat,subfile,udp");

huangjianfeng1 commented 7 years ago

@NotLooker 多谢大神,之前看网上说"protocol_whitelist "这里面要加一个空格,用旧版是可以的,所以从没怀疑过,但使用新版的时候就是不行,看了大神的回复后,直接复制粘贴就解决问题了,再次感谢大神!!!

hardcattle1 commented 7 years ago

@huangjianfeng1 兄弟我的还是报错啊, ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"safe",0); ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "protocol_whitelist", "async,cache,crypto,file,http,https,ijkhttphook,ijkinject,ijklivehook,ijklongurl," + "ijksegment,ijktcphook,pipe,rtp,tcp,tls,udp,ijkurlhook,data,concat,subfile,udp"); LOG:

07-14 19:40:03.889 29610-31570/xxx D/IJKMEDIA: request: GET /Admin/Service/plconcat?url=http%3A%2F%2Fv.youku.com%2Fv_show%2Fid_XMjg4ODUzMDQyNA%3D%3D.html&source_id=1&sel_type=FLV&stream_type=SD HTTP/1.1 User-Agent: Lavf/57.56.100 Accept: */* Range: bytes=0- Connection: close Host: pl.feixiong.tv Icy-MetaData: 1 07-14 19:40:03.992 29610-31570/xxx W/IJKMEDIA: Unknown content coding: none 07-14 19:40:03.994 29610-31570/xxxI/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 2 07-14 19:40:03.995 29610-31570/xxx D/IJKMEDIA: Format concat probed with size=2048 and score=100 07-14 19:40:03.995 29610-31570/xxx E/IJKMEDIA: Unsafe file name 'http://k.youku.com/player/getFlvPath/sid/050003230807412e1245d/st/flv/fileid/030002030059672873F1540742760115678531-E94D-FB6A-2EF5-4F89F76E5BF0?k=bea7ad1b0c3e9a18282c8179&hd=0&myp=0&ts=394&ctype=12&ev=1&token=0524&oip=1992197172&ep=cieUGkmOVM0A7SPYjD8bMi3gcHJbXP4J9h%2BFg9JhALshQe64mzbWxOuxS%2FtCEf0bdSQGEer0rdfv%0Ab0MVYYVKrRwQqTyuSPrii4bm5aklzJl2YR9Dd7%2BhtFSeRjL1&ccode=0401&duration=393&expire=18000&psid=f318acb878c9caa1af5419fa8c322a63&ups_client_netip=118.190.132.52&ups_ts=1500032308&ups_userid=&utid=M5vvEQliICoCAXa%2BhDQ0GpD7&vid=XMjg4ODUzMDQyNA%3D%3D&vkey=A4fb1440d636e25742ac0fd29edd6905a' 07-14 19:40:03.995 29610-31570/xxx D/IJKMEDIA: Statistics: 1874 bytes read, 0 seeks 07-14 19:40:03.996 29610-31570/xxx E/IJKMEDIA: http://pl.feixiong.tv/Admin/Service/plconcat?url=http%3A%2F%2Fv.youku.com%2Fv_show%2Fid_XMjg4ODUzMDQyNA%3D%3D.html&source_id=1&sel_type=FLV&stream_type=SD: Operation not permitted 07-14 19:40:03.996 29610-31568/xxx D/IJKMEDIA: FFP_MSG_ERROR: 0