Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android用硬解码播放器切后台恢复问题 #1324

Closed
gnwell opened this issue May 18, 2016 · 46 comments
Closed

android用硬解码播放器切后台恢复问题 #1324

gnwell opened this issue May 18, 2016 · 46 comments

Comments

@gnwell
Copy link

gnwell commented May 18, 2016

需求: 需要实现播放器切后台暂停,恢复前台从暂停位置继续播放的基本功能。
问题:使用硬解码时,后台恢复后出现只播放声音,画面黑屏持续几秒(黑屏时间长短不固定)后画面才能显示。应该是surfaceview重建后重新绑定到player后导致的现象,有遇到过此问题的朋友么?

@bbcallen
Copy link
Contributor

It's a known issue, and no good solution, for now.

@gnwell
Copy link
Author

gnwell commented May 19, 2016

@bbcallen 请教下,视频黑屏持续期间
SDL_AMediaCodecFake_dequeueOutputBuffer 返回AMEDIACODEC__INFO_TRY_AGAIN_LATER,也就说现在MediaCodec一直没有输出数据对吧?可不可以理解次Surface发生变化都会导致codec reconfigure,重新设置后就会导致解码器输出延时的情况,这是AMEDIACODEC 的问题了?

@bbcallen
Copy link
Contributor

No, actually, it's player's issue.
But for MediaCodec, it's a little difficult to workaround.

@gnwell
Copy link
Author

gnwell commented May 19, 2016

@bbcallen 您指的player问题,是说在这种情况下,不应该创建新的codec么?即使surface重新建立了,也可以继续使用原来的codec?

@bbcallen
Copy link
Contributor

bbcallen commented May 19, 2016

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.

@gnwell
Copy link
Author

gnwell commented May 19, 2016

@bbcallen ,very appreciate for your help!!:)

@gnwell
Copy link
Author

gnwell commented May 19, 2016

@bbcallen come back again. 看了下bilibili的应用,采用硬件解码,切后台回来后好像codec没有重新建立?还是用的以前的codec是么?

@bbcallen
Copy link
Contributor

Sorry, I don't have any authority to talk about the detail of the application in public.

@gnwell
Copy link
Author

gnwell commented May 19, 2016

@bbcallen thanks a lot though:)

@AliveingSoul
Copy link

@bbcallen 我遇到的情况是开启硬解码后,后台切换回来播放会花屏几秒,然后正常,也是跟楼主一样的原因吗?
qq 20160519195510

@gnwell
Copy link
Author

gnwell commented May 19, 2016

maybe codec requries idr frame when renew.

1 similar comment
@gnwell
Copy link
Author

gnwell commented May 19, 2016

maybe codec requries idr frame when renew.

@AliveingSoul
Copy link

@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

@gnwell
Copy link
Author

gnwell commented May 19, 2016

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.

1 similar comment
@gnwell
Copy link
Author

gnwell commented May 19, 2016

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.

@gnwell gnwell closed this as completed May 19, 2016
@dourgulf
Copy link

mark

@edwardZj
Copy link

@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 ~

@lgengsy
Copy link

lgengsy commented Sep 12, 2016

mark @AliveingSoul 你解决了么 ??

@lgengsy
Copy link

lgengsy commented Sep 14, 2016

@gnwell how to fix it

@gnwell
Copy link
Author

gnwell commented Sep 26, 2016

@lgengsy 可以参照TextureRenderView.java的实现,关键就是在View销毁的时候不要销毁SurfaceTexture

@zhangpingV5
Copy link

看了TextureRenderView.java 还是没有搞太懂,不知道怎样去修改。大神能帮忙详细的解释下吗?万分感谢 @gnwell

@zhanggao
Copy link

@zhangpingV5 这个问题你解决了没?

@wutongluxjtu
Copy link

@gnwell 请问解决该问题,你用的 “可以参照TextureRenderView.java的实现,关键就是在View销毁的时候不要销毁SurfaceTexture” 方法, 还是用的 “Double decode” 方法? 另外,能不能给出代码示例?谢谢!

@zhanggao
Copy link

zhanggao commented Mar 7, 2017

@gnwell @wutongluxjtu TextureRenderView也有这个问题。

@wutongluxjtu
Copy link

@zhanggao 目前有什么好的解决方法吗?

@wutongluxjtu
Copy link

@bbcallen 请问这个热点讨论issue, 是否考虑修复?

@bbcallen
Copy link
Contributor

bbcallen commented Mar 7, 2017

Nope

@zhanggao
Copy link

zhanggao commented Mar 7, 2017

@wutongluxjtu 没有,我改成软解了。

@teddyla
Copy link
Contributor

teddyla commented Mar 8, 2017

@gnwell
android platform:
video output buffer maintain & alloc from surface.(bufferqueue).
when ur surface is in background. surface is disconnect-> bufferqueue is destroyed

after surface return foreground. surface connect & realloc output buffer for omx port. then fillbuffer. wait buffer done, do avsync & queueBuffer, consumer composite & render

-> becoz these sw flow need time costing, this is why black screen sustain a while.

@teddyla
Copy link
Contributor

teddyla commented Mar 8, 2017

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~

@bingxuebage
Copy link

碰到同样的问题,请教各位 TextureRenderView 和Double decode 怎么使用

@zhanggao
Copy link

mediaPlayer = new TextureMediaPlayer(mediaPlayer);
TextureView 硬解切后台不会黑屏。
@wutongluxjtu @bingxuebage @lgengsy

@Android4MediaPlayer
Copy link

@ALL,use TextureMediaPlayer

@zhanggao
Copy link

@Android4MediaPlayer SurfaceView 用 TextureMediaPlayer 是不是还会黑屏?

@jinyunfeng
Copy link

@gnwell @bbcallen 这个问题有没有一个好的解决方案,从后台切到前台reconfigure后无法输出有效的数据,是因为没有关键帧mediacodec无法解出有效数据吗?如何去解决这个问题?

@jinyunfeng
Copy link

@gnwell @bbcallen 后台切到前台后数据有问题,既无法得到关键帧,不能保证解码的正常,这个是本质原因吧?由于surface的变化重新create mediacodec并不是造成画面问题的原因。有没有可行的方案?

@raymond1012
Copy link
Member

raymond1012 commented Mar 16, 2017 via email

@jinyunfeng
Copy link

请问这个导致这个现象的原因是什么?是因为数据的问题mediacodec无法正常输出解码还是因为surface的变化导致的解码错误?

@raymond1012
Copy link
Member

raymond1012 commented Mar 16, 2017 via email

@jinyunfeng
Copy link

好的,谢谢,我先试试自己的思路,然后再去尝试你的思路,很感谢

@jinyunfeng
Copy link

依然没有解决问题,如何使用OpenGL 代替surface,能否详细说一下这个流程

@jinyunfeng
Copy link

@gnwell 你使用surfaceview实现了切回前台不黑一会的效果了吗?如果实现了,请问是如何实现的?

@1325679717
Copy link

@OverRide
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
if (savedSurfaceTexture == null){
savedSurfaceTexture = surface;
mSurface = new Surface(surface);

}else {
    this.setSurfaceTexture(savedSurfaceTexture);
}

}

@wzybupt
Copy link

wzybupt commented Mar 16, 2018

@1325679717 我这边会报 Cannot setSurfaceTexture to a released SurfaceTexture 这个异常,虽然surfaceTexture已经保存了,但是还是会被release掉。

@weigtman
Copy link

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!

感谢~

@kaihuang666
Copy link

//GSYvideoPlayer已经这么做了,不过我却发现在电视上SurfaceView渲染比SurfaceTextureView好太多,比如我这台海信居然可以打开画质引擎和HDR,所以在电视上就忍了。手机上的效果差别不大。
@OverRide
public void onSurfaceTextureAvailable(SurfaceTexture texture, int width, int height) {
if (mSaveTexture == null) {
mSaveTexture = texture;
mSurface = new Surface(texture);
if (mIGSYSurfaceListener != null) {
mIGSYSurfaceListener.onSurfaceAvailable(mSurface);
}
} else {
setSurfaceTexture(mSaveTexture);
if (mIGSYSurfaceListener != null) {
mIGSYSurfaceListener.onSurfaceAvailable(mSurface);
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests