需求: 需要实现播放器切后台暂停,恢复前台从暂停位置继续播放的基本功能。
问题:使用硬解码时,后台恢复后出现只播放声音,画面黑屏持续几秒(黑屏时间长短不固定)后画面才能显示。应该是surfaceview重建后重新绑定到player后导致的现象,有遇到过此问题的朋友么?
It's a known issue, and no good solution, for now.
@bbcallen 请教下,视频黑屏持续期间
SDL_AMediaCodecFake_dequeueOutputBuffer 返回AMEDIACODEC__INFO_TRY_AGAIN_LATER,也就说现在MediaCodec一直没有输出数据对吧?可不可以理解次Surface发生变化都会导致codec reconfigure,重新设置后就会导致解码器输出延时的情况,这是AMEDIACODEC 的问题了?
No, actually, it's player's issue.
But for MediaCodec, it's a little difficult to workaround.
@bbcallen 您指的player问题,是说在这种情况下,不应该创建新的codec么?即使surface重新建立了,也可以继续使用原来的codec?
Do not recreate MediaCodec is the best practice in theory. You can take a look at github.com/google/grafika for this idea ('Double decode' section). But in real world, it may be broken on some vendor devices.
So, the only option left is that, the player should feed the correct data. This need some H264 knowledges.
@bbcallen ,very appreciate for your help!!:)
@bbcallen come back again. 看了下bilibili的应用,采用硬件解码,切后台回来后好像codec没有重新建立?还是用的以前的codec是么?
Sorry, I don't have any authority to talk about the detail of the application in public.
@bbcallen thanks a lot though:)
@bbcallen 我遇到的情况是开启硬解码后,后台切换回来播放会花屏几秒,然后正常,也是跟楼主一样的原因吗?

maybe codec requries idr frame when renew.
maybe codec requries idr frame when renew.
@gnwell But when I turn off the screen then turn on again ,It's not have this problem , Their life cycle should be no different
check log whether the decoder is configured with your operations. i have tried the ideas mentioned by bbcallen github.com/google/grafika for this idea ('Double decode' section). it works.
check log whether the decoder is configured with your operations. i have tried the ideas mentioned by bbcallen github.com/google/grafika for this idea ('Double decode' section). it works.
mark
@gnwell I see github.com/google/grafika for this idea ('Double decode' section).But I don't know what to do.Hope your reply in Chinese ~
mark @AliveingSoul 你解决了么 ??
@gnwell how to fix it
@lgengsy 可以参照TextureRenderView.java的实现,关键就是在View销毁的时候不要销毁SurfaceTexture
看了TextureRenderView.java 还是没有搞太懂,不知道怎样去修改。大神能帮忙详细的解释下吗?万分感谢 @gnwell
@zhangpingV5 这个问题你解决了没?
@gnwell 请问解决该问题,你用的 “可以参照TextureRenderView.java的实现,关键就是在View销毁的时候不要销毁SurfaceTexture” 方法, 还是用的 “Double decode” 方法? 另外,能不能给出代码示例?谢谢!
@gnwell @wutongluxjtu TextureRenderView也有这个问题。
@zhanggao 目前有什么好的解决方法吗?
@bbcallen 请问这个热点讨论issue, 是否考虑修复?
Nope
@wutongluxjtu 没有,我改成软解了。
@gnwell
android platform:
video output buffer maintain & alloc from surface.(bufferqueue).
-> becoz these sw flow need time costing, this is why black screen sustain a while.
there is a solution(see google bigflake).
use two surface. one surface for omx output buffer. & one surface for display.
use opengl es api for zero memcpy~
碰到同样的问题,请教各位 TextureRenderView 和Double decode 怎么使用
mediaPlayer = new TextureMediaPlayer(mediaPlayer);
TextureView 硬解切后台不会黑屏。
@wutongluxjtu @bingxuebage @lgengsy
@all,use TextureMediaPlayer
@Android4MediaPlayer SurfaceView 用 TextureMediaPlayer 是不是还会黑屏?
@gnwell @bbcallen 这个问题有没有一个好的解决方案,从后台切到前台reconfigure后无法输出有效的数据,是因为没有关键帧mediacodec无法解出有效数据吗?如何去解决这个问题?
@gnwell @bbcallen 后台切到前台后数据有问题,既无法得到关键帧,不能保证解码的正常,这个是本质原因吧?由于surface的变化重新create mediacodec并不是造成画面问题的原因。有没有可行的方案?
可以尝试用opengl来代替目前的surface
在 2017年3月15日 下午11:39,jinyunfeng notifications@github.com写道:
@gnwell https://github.com/gnwell @bbcallen
https://github.com/bbcallen 后台切到前台后数据有问题,既无法得到关键帧,不能保证解码的正常,这个是本质原因吧?由于surface的变化重新create
mediacodec并不是造成画面问题的原因。有没有可行的方案?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Bilibili/ijkplayer/issues/1324#issuecomment-286782086,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEOmlrLDoMMyXCo0ObLtf_8bC-Ush_3zks5rmAZLgaJpZM4Ihy9x
.
请问这个导致这个现象的原因是什么?是因为数据的问题mediacodec无法正常输出解码还是因为surface的变化导致的解码错误?
surface从后台切换到前台有些系统会等待下个关键帧才能渲染
2017-03-16 10:06 GMT+08:00 jinyunfeng notifications@github.com:
请问这个导致这个现象的原因是什么?是因为数据的问题mediacodec无法正常输出解码还是因为surface的变化导致的解码错误?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Bilibili/ijkplayer/issues/1324#issuecomment-286936477,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEOmlpcniP-SQKErhOE3SR1fKgydzmVeks5rmJk5gaJpZM4Ihy9x
.
好的,谢谢,我先试试自己的思路,然后再去尝试你的思路,很感谢
依然没有解决问题,如何使用OpenGL 代替surface,能否详细说一下这个流程
@gnwell 你使用surfaceview实现了切回前台不黑一会的效果了吗?如果实现了,请问是如何实现的?
@override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
if (savedSurfaceTexture == null){
savedSurfaceTexture = surface;
mSurface = new Surface(surface);
}else {
this.setSurfaceTexture(savedSurfaceTexture);
}
}
@1325679717 我这边会报 Cannot setSurfaceTexture to a released SurfaceTexture 这个异常,虽然surfaceTexture已经保存了,但是还是会被release掉。
03-14 17:08:42.220 29823-29823/com.example.zhangyang.ijktest D/IjkVideoView: MEDIA_INFO_VIDEO_ROTATION_CHANGED: 0
03-14 17:23:50.508 31014-31014/com.example.zhangyang.ijktest D/IjkVideoView: Error: -10000,0
03-14 17:24:35.307 31155-31155/com.example.zhangyang.ijktest D/IjkVideoView: MEDIA_INFO_VIDEO_ROTATION_CHANGED: 0
和
03-14 16:33:36.396 27148-27183/com.example.zhangyang.ijktest E/IJKMEDIA: SPS unavailable in decode_picture_timing
03-14 16:33:36.396 27148-27183/com.example.zhangyang.ijktest E/IJKMEDIA: non-existing PPS 0 referenced
03-14 16:33:36.396 27148-27183/com.example.zhangyang.ijktest E/IJKMEDIA: decode_slice_header error
03-14 16:33:36.396 27148-27183/com.example.zhangyang.ijktest E/IJKMEDIA: no frame!
感谢~
Most helpful comment
No, actually, it's player's issue.
But for MediaCodec, it's a little difficult to workaround.