CN114071229B - 一种解决SurfaceView渲染器重载视频解码时回收延迟的方法 - Google Patents

一种解决SurfaceView渲染器重载视频解码时回收延迟的方法 Download PDF

Info

Publication number
CN114071229B
CN114071229B CN202111493204.XA CN202111493204A CN114071229B CN 114071229 B CN114071229 B CN 114071229B CN 202111493204 A CN202111493204 A CN 202111493204A CN 114071229 B CN114071229 B CN 114071229B
Authority
CN
China
Prior art keywords
video
renderer
current
decoding
holder
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111493204.XA
Other languages
English (en)
Other versions
CN114071229A (zh
Inventor
孔世明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Qiruike Technology Co Ltd
Original Assignee
Sichuan Qiruike Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Qiruike Technology Co Ltd filed Critical Sichuan Qiruike Technology Co Ltd
Priority to CN202111493204.XA priority Critical patent/CN114071229B/zh
Publication of CN114071229A publication Critical patent/CN114071229A/zh
Application granted granted Critical
Publication of CN114071229B publication Critical patent/CN114071229B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440236Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by media transcoding, e.g. video is transformed into a slideshow of still pictures, audio is converted into text
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/41Structure of client; Structure of client peripherals
    • H04N21/414Specialised client platforms, e.g. receiver in car or embedded in a mobile appliance
    • H04N21/41407Specialised client platforms, e.g. receiver in car or embedded in a mobile appliance embedded in a portable device, e.g. video client on a mobile phone, PDA, laptop
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/41Structure of client; Structure of client peripherals
    • H04N21/426Internal components of the client ; Characteristics thereof
    • H04N21/42653Internal components of the client ; Characteristics thereof for processing graphics
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/431Generation of visual interfaces for content selection or interaction; Content or additional data rendering
    • H04N21/4312Generation of visual interfaces for content selection or interaction; Content or additional data rendering involving specific graphical features, e.g. screen layout, special fonts or colors, blinking icons, highlights or animations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4331Caching operations, e.g. of an advertisement for later insertion during playback
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/44004Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving video buffer management, e.g. video decoder buffer or video display buffer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440245Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display the reformatting operation being performed only on part of the stream, e.g. a region of the image or a time segment
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/442Monitoring of processes or resources, e.g. detecting the failure of a recording device, monitoring the downstream bandwidth, the number of times a movie has been viewed, the storage space available from the internal hard disk
    • H04N21/4424Monitoring of the internal components or processes of the client device, e.g. CPU or memory load, processing speed, timer, counter or percentage of the hard disk space used
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Databases & Information Systems (AREA)
  • Computer Graphics (AREA)
  • General Engineering & Computer Science (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

本发明公开了一种解决SurfaceView渲染器重载视频解码时回收延迟的方法,包括:步骤1:动态计算RenderView;步骤2:使用setRenderView动态计算渲染器;步骤3:renderView的初始化:步骤4:进行静帧画面的缓存。使用基于SurfaceView硬解码及软解码核心算法处理视频切换后台时重新进入主应用是不会产生黑屏闪烁问题;切换视频画面不会产生上一个媒体文件的当前帧画面。

Description

一种解决SurfaceView渲染器重载视频解码时回收延迟的 方法
技术领域
本发明涉及Android手持设备及车载设备等等的音视频媒体处理技术领域,具体涉及一种解决SurfaceView渲染器重载视频解码时回收延迟的方法。
背景技术
在如今日新月异的今天,高科技不断涌现,在当下人均互联网流量爆炸的时代,万物互联及手持设备帮助着人们在生活及工作中随时随地与外界进行信息交互及娱乐办公。自2007年11月5日谷歌公司正式向外界展示Android的操作系统,并建立由34家手机制造商、软件开发商、电信运营商以及芯片制造商共同组成的全球性组织。更是极大将手持移动设备的触角延伸到越来越多的用户生活中,而人们庞大复杂的各种应用场景交互里面,媒体类处理已然成为占比最大的应用类服务。
从早期基于PC端桌面媒体播放程序到Web端在线视频门户平台的建立,视频娱乐已经形成物质生活基础需求,再加上这两年移动设备的大量繁衍进化,曾经的视频门户已经越来越呈现向移动端过渡的趋势,尤其是各类短视频交互平台的滋生壮大更是将这一需求带入新纪元。而开源的Android操作系统更是提供了各类强大的支持音视频媒体解码处理方案及可用组件,从而保证各种基础化或定制化的Android应用能灵活方便的处理在线流媒体及本地媒体文件。本方案就是采用最经典的SurfaceView+MediaPlayer技术,在实现基础播放需求的同时,完美解决这些大量的视频切换或者应用挂起时重新载入卡帧、黑屏等一系列交互体验问题。
发明内容
本发明发的目的在于提供一种解决SurfaceView渲染器重载视频解码时回收延迟的方法,以期解决背景技术中存在的技术问题。
为了实现上述目的,本发明采用以下技术方案:
一种解决SurfaceView渲染器重载视频解码时回收延迟的方法,包括:
步骤1:动态计算RenderView;
步骤2:使用setRenderView动态计算渲染器;
步骤3:renderView的初始化:
步骤4:进行静帧画面的缓存。
在一些实施例中,所述步骤1,动态计算RenderView包括:
重载setRender方法,接收渲染器类型参数,允许开发人员传入渲染器型号,做分支处理,分别计算两种渲染器类型。
在一些实施例中,所述两种渲染器类型,具体包括:
①RENDER_TEXTURE_VIEW:创建构造TextureRenderView对象并获取上下文,得到当前视频播放活动页的上下文context,校验当前MediaPlayer是否为null,如果MediaPlayer对象存在,则getSurfaceHolder得到当前RenderView的holder缓存对象并绑定到Mediaplayer上,此时根据新版视频资源路径生成的解码数据流通过setVideoSize获取到视频宽高尺寸,setVideoSampleAspectRatio动态计算宽高比,接收VideoSarNum及VideoSarDen参数,并执行setRenderView重置;
②RENDER_SURFACE_VIEW:构造SurfaceRenderView对象并使用上下文初始化此对象,同步开启线程缓存上一个媒体解码对象holder,使用此holder display当前MediaPlayer参数,因为相比TextrueView,SurfaceView对象会销毁目标对象并重建,因此这一步要使用holder缓存进行RenderView的重置.
在一些实施例中,所述步骤2:使用setRenderView动态计算渲染器,包括:重新判断当前MediaPlayer对象是否为空,否则setDisplay为null,保证当前画面置空,显示短暂黑屏,构造renderUIView渲染器对象针对此前所有旧版mSHCallback回调实施removeRenderCallback处理,解除与上一个视频的监听绑定,解除成功要记得解除renderUIView的关联。
在一些实施例中,所述步骤3:renderView的初始化,包括:根据处理得到的renderView,需要做clear处理将旧版初始化数据重置为默认状态,调用系统设置执行getEnableSurfaceView开启系统窗口层使用SurfaceView的权限,为mAllRenders添加RENDER_SURFACE_VIEW,如果此权限开启成功并且判断当前Android系统版本大于ICE_CREAM_SANDWICH,则执行最终Ui绑定mAllRenders.add。
在一些实施例中,所述步骤4:进行静帧画面的缓存,包括:创建MediaMetadataRetriever对象并使用上下文关联,注入当前媒体流资源路径,使用mSeekBarProgress记录当前视频帧画面转Bitmap进度,新建一个主线程监听应用回调挂起生命周期状态,一旦进入onPause流程,马上runThreadUi执行定时器操作。
在一些实施例中,所述runThreadUi执行定时器操作包括:
获取currentPostion定位当前进度并做getMax处理,该处理生成进度写入SeekBar对象;
使用getFrameAtTime传入currentPostion参数返回一个Bitmap流对象,此时捕获RuntimeException异常,若捕获成功,则执行retriever释放,并将截图保存路径定向为getExternalStorageDirectory拼接Temp索引头。
在一些实施例中,所述索引头为一个临时内存开辟使用权限,允许FileOutputStream处理此流文件,得到的流对象被执行compress并传入itmap.CompressFormat参数实施画面压缩,得到最终静帧Panel并display到ImageHolderView外层父容器上;当应用重新被唤起时,用户即可看到视频播放暂停状态下的现场帧画面,重新执行播放,将imageholder执行View.GONE类型隐藏并释放掉Bitmap流,即可继续播放。
本申请所披露的解决SurfaceView渲染器重载视频解码时回收延迟的方法可能带来的有益效果包括但不限于:
1、使用基于SurfaceView硬解码及软解码核心算法处理视频切换后台时重新进入主应用是不会产生黑屏闪烁问题;
2、切换视频画面不会产生上一个媒体文件的当前帧画面。本发明采用的是对当前媒体文件解码过程中及OpenGL ES渲染时输出帧画面实时监控,当检测到应用挂起时回收RenderView组件,并且中间切换为TextrueView绑定当前画面生成Bitmap,做静帧定格处理,实现静帧画面避免黑屏,对于切换媒体解码任务时,尝试对RenderView进行回收及重映射,动态计算媒体流参数的方式回收缓存帧,实现无缝切换。与其他第三方视频解码器的处理相比,市面上主流播放器在软解码类型的处理上都未优化此问题,所以本方案的提出,优先保证了视频播放器在用户体验交互上更加流畅自然,实现真正的无缝切换。
附图说明
图1视频切换时SurfaceView重载映射的流程图;
图2视频切换后台区遮罩生成维持静帧的流程图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
相反,本申请涵盖任何由权利要求定义的在本申请的精髓和范围上做的替代、修改、等效方法以及方案。进一步,为了使公众对本申请有更好的了解,在下文对本申请的细节描述中,详尽描述了一些特定的细节部分。对本领域技术人员来说没有这些细节部分的描述也可以完全理解本申请。
以下将结合图1-2对本申请实施例所涉及的解决SurfaceView渲染器重载视频解码时回收延迟的方法进行详细说明。值得注意的是,以下实施例仅仅用于解释本申请,并不构成对本申请的限定。
本发明针对Android设备播放媒体文件无缝切换及回收延迟的解决思路分两个交互场景:一是播放当前视频过程中进行上一曲或者下一曲切换,此过程中要回收视频缓冲区,重置disPlayHolder,将MediaPlayer回收并执行RenderView动态处理,大致工作流程参见附图图1;二是播放当前视频中,通过手势导航或语音唤起将视频应用转入后台挂起,待当前任务处理完毕返回应用时,需要保持视频现场。主要是采用在上层SurfaceView父容器外层封装ImageHolder接收器,在当前PlayActivity挂起时回调onPause周期内执行截取当前视频帧画面生成Bitmap流渲染到ImageHolder内,而当重新进入应用时再销毁Bitmap,将帧容器隐藏。本发明的有益效果为,应用挂起重启能迅速恢复视频播放状态,切换上下曲视频文件能实现无缝切换,增强用户体验。主要工作流程如附图图2.下面将展开步骤详细阐述:
(1)视频播放中切换上下曲:
①终端操作应用下发用户切换命令,获取最新视频路径,此路径回调setMediaData绑定新版url至MediaPlayer;
②原解析线程被终止,视频资源被释放,新的媒体流通过索引头预加载并开启硬解码双缓冲解析视频画面,自适应当前渲染器类型动态计算新视频尺寸比例等问题,最后重置RenderView;
③发起新的解码线程进入Main程序Loop,等待SurfaceView holder对象被重新实例化后绑定至MediaPlayer进入prepare,即可清除上一个媒体文件的残存帧画面;
(2)视频应用进入后台被重新唤起:
①首先回调生命周期onPause将视频音画暂停并释放焦点,获取当前视频解码postion,缓存至MediaLoacalProvider,记录视频进度;
②构造Bitmap对象,初始化为null,并创建MediaMetadataRetriever对象。设置DataSource传入当前资源路径,通过extractMetadata API指定timeString类型,用于中转存储跳转内存资源索引等操作,使用此MediaMetadataRetriever对象获取该时间节点画面并转Bitmap对象,渲染至Imageholder;
③使用Imageholder组件作为摄像头前景遮罩覆盖MediaPlayer,并设置组件可见;
④重新唤起进入视频播放界面,回调onResume周期重新初始化视频并定位索引,载入就绪执行播放,并设置Imageholder不可见。
如图1-2所示,本发明一种解决SurfaceView渲染器重载视频解码时回收延迟的方法,包括以下步骤:
步骤1:动态计算RenderView:重载setRender方法,接收渲染器类型参数,允许开发人员传入渲染器型号,做分支处理,分别计算两种渲染器类型:
①RENDER_TEXTURE_VIEW:创建构造TextureRenderView对象并获取上下文,得到当前视频播放活动页的上下文context,校验当前MediaPlayer是否为null,如果MediaPlayer对象存在,则getSurfaceHolder得到当前RenderView的holder缓存对象并绑定到Mediaplayer上,此时根据新版视频资源路径生成的解码数据流通过setVideoSize获取到视频宽高尺寸,setVideoSampleAspectRatio动态计算宽高比,接收VideoSarNum及VideoSarDen参数,并执行setRenderView重置;
②RENDER_SURFACE_VIEW:构造SurfaceRenderView对象并使用上下文初始化此对象,同步开启线程缓存上一个媒体解码对象holder,使用此holder display当前MediaPlayer参数,因为相比TextrueView,SurfaceView对象会销毁目标对象并重建,因此这一步要使用holder缓存进行RenderView的重置;
步骤2:使用setRenderView动态计算渲染器:重新判断当前MediaPlayer对象是否为空,否则setDisplay为null,保证当前画面置空,显示短暂黑屏,构造renderUIView渲染器对象针对此前所有旧版mSHCallback回调实施removeRenderCallback处理,解除与上一个视频的监听绑定,解除成功要记得解除renderUIView的关联,此时重置渲染器成功,画面虽然出现黑屏,不过是毫秒级别的显示。
使用步骤1中构造的mCurrentAspectRatio视频动态比例对象setVideoSize,使得重置的渲染器拥有特定的比例及可视化区域,此时声明FrameLayout.LayoutParams参数对象,设置渲染器WRAP_CONTENT的父容器参数,并使用setLayoutParams方法将此参数传递给RenderViewUI,最后执行addView为渲染器二次指定addRenderCallback回调监听及mVideoRotationDegree,最后例行initRenders为解码器做prepared等储备工作,使解码工作进入循环程序.
步骤3:renderView的初始化:根据步骤2中处理得到的renderView,需要做clear处理将旧版初始化数据重置为默认状态,调用系统设置执行getEnableSurfaceView开启系统窗口层使用SurfaceView的权限,为mAllRenders添加RENDER_SURFACE_VIEW,如果此权限开启成功并且判断当前Android系统版本大于ICE_CREAM_SANDWICH,则执行最终Ui绑定mAllRenders.add(RENDER_SURFACE_VIEW),到这一步,如果资源路径合法且文件未损坏,即可成功实现无卡帧现象的无缝切换下一曲目的解码。
步骤4:静帧画面的缓存:创建MediaMetadataRetriever对象并使用上下文关联,注入当前媒体流资源路径,使用mSeekBarProgress记录当前视频帧画面转Bitmap进度,新建一个主线程监听应用回调挂起生命周期状态,一旦进入onPause流程,马上runThreadUi执行定时器操作,首先获取currentPostion定位当前进度并做getMax处理,该处理生成进度写入SeekBar对象,接着使用getFrameAtTime传入currentPostion参数返回一个Bitmap流对象,此时应注意捕获RuntimeException异常,若捕获成功,则执行retriever释放,并将截图保存路径定向为getExternalStorageDirectory拼接Temp索引头,该索引头为一个临时内存开辟使用权限,允许FileOutputStream处理此流文件,得到的流对象被执行compress并传入itmap.CompressFormat参数实施画面压缩,得到最终静帧Panel并display到ImageHolder View外层父容器上;当应用重新被唤起时,用户即可看到视频播放暂停状态下的现场帧画面,重新执行播放,只需将imageholder执行View.GONE类型隐藏并释放掉Bitmap流,即可继续播放。
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。

Claims (3)

1.一种解决SurfaceView渲染器重载视频解码时回收延迟的方法,其特征在于,包括:
步骤1:动态计算RenderView;
步骤2:使用setRenderView动态计算渲染器;
步骤3:renderView的初始化:
步骤4:进行静帧画面的缓存;
所述步骤1,动态计算RenderView包括:
重载setRender方法,接收渲染器类型参数,允许开发人员传入渲染器型号,做分支处理,分别计算两种渲染器类型;
所述两种渲染器类型,具体包括:
①RENDER_TEXTURE_VIEW:创建构造TextureRenderView对象并获取上下文,得到当前视频播放活动页的上下文context,校验当前MediaPlayer是否为null,如果MediaPlayer对象存在,则getSurfaceHolder得到当前RenderView的holder缓存对象并绑定到Mediaplayer上,此时根据新版视频资源路径生成的解码数据流通过setVideoSize获取到视频宽高尺寸,setVideoSampleAspectRatio动态计算宽高比,接收VideoSarNum及VideoSarDen参数,并执行setRenderView重置;
②RENDER_SURFACE_VIEW:构造SurfaceRenderView对象并使用上下文初始化此对象,同步开启线程缓存上一个媒体解码对象holder,使用此holder display当前MediaPlayer参数,使用holder缓存进行RenderView的重置;
所述步骤2:使用setRenderView动态计算渲染器,包括:重新判断当前MediaPlayer对象是否为空,否则setDisplay为null,保证当前画面置空,显示短暂黑屏,构造renderUIView渲染器对象针对此前所有旧版mSHCallback回调实施removeRenderCallback处理,解除与上一个视频的监听绑定,解除成功时将renderUIView的关联解除;
所述步骤3:renderView的初始化,包括:根据处理得到的renderView,需要做clear处理将旧版初始化数据重置为默认状态,调用系统设置执行getEnableSurfaceView开启系统窗口层使用SurfaceView的权限,为mAllRenders添加RENDER_SURFACE_VIEW,如果此权限开启成功并且判断当前Android系统版本大于ICE_CREAM_SANDWICH,则执行最终Ui绑定mAllRenders.add;
所述步骤4:进行静帧画面的缓存,包括:创建MediaMetadataRetriever对象并使用上下文关联,注入当前媒体流资源路径,使用mSeekBarProgress记录当前视频帧画面转Bitmap进度,新建一个主线程监听应用回调挂起生命周期状态,一旦进入onPause流程,马上runThreadUi执行定时器操作。
2.根据权利要求1所述的一种解决SurfaceView渲染器重载视频解码时回收延迟的方法,其特征在于,所述runThreadUi执行定时器操作包括:
获取currentPostion定位当前进度并做getMax处理,该处理生成进度写入SeekBar对象;
使用getFrameAtTime传入currentPostion参数返回一个Bitmap流对象,此时捕获RuntimeException异常,若捕获成功,则执行retriever释放,并将截图保存路径定向为getExternalStorageDirectory拼接Temp索引头。
3.根据权利要求2所述的一种解决SurfaceView渲染器重载视频解码时回收延迟的方法,其特征在于,所述索引头为一个临时内存开辟使用权限,允许FileOutputStream处理此流文件,得到的流对象被执行compress并传入itmap.CompressFormat参数实施画面压缩,得到最终静帧Panel并display到ImageHolder View外层父容器上;当应用重新被唤起时,用户即可看到视频播放暂停状态下的现场帧画面,重新执行播放,将imageholder执行View.GONE类型隐藏并释放掉Bitmap流,即可继续播放。
CN202111493204.XA 2021-12-08 2021-12-08 一种解决SurfaceView渲染器重载视频解码时回收延迟的方法 Active CN114071229B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111493204.XA CN114071229B (zh) 2021-12-08 2021-12-08 一种解决SurfaceView渲染器重载视频解码时回收延迟的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111493204.XA CN114071229B (zh) 2021-12-08 2021-12-08 一种解决SurfaceView渲染器重载视频解码时回收延迟的方法

Publications (2)

Publication Number Publication Date
CN114071229A CN114071229A (zh) 2022-02-18
CN114071229B true CN114071229B (zh) 2023-06-09

Family

ID=80229220

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111493204.XA Active CN114071229B (zh) 2021-12-08 2021-12-08 一种解决SurfaceView渲染器重载视频解码时回收延迟的方法

Country Status (1)

Country Link
CN (1) CN114071229B (zh)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108235096A (zh) * 2018-01-18 2018-06-29 湖南快乐阳光互动娱乐传媒有限公司 移动终端硬解码智能切换软解码播放视频的方法
CN110572715A (zh) * 2019-09-24 2019-12-13 四川长虹电器股份有限公司 一种解决Android TV播放webp卡顿的方法

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8139070B1 (en) * 2007-10-03 2012-03-20 Matrox Graphics, Inc. Systems for and methods of context switching in a graphics processing system
US20120167122A1 (en) * 2010-12-27 2012-06-28 Nokia Corporation Method and apparatus for pre-initializing application rendering processes
SG11201407413WA (en) * 2012-12-07 2014-12-30 Yota Devices Ipr Ltd Display surface contains a cut out region reformatting display data
CN103366391B (zh) * 2013-06-26 2016-07-06 广州市动景计算机科技有限公司 动态图像的画面渲染方法及画面渲染装置
CN105491452B (zh) * 2015-11-25 2019-02-15 浙江宇视科技有限公司 一种多视频窗口层级切换方法及装置
CN105916052A (zh) * 2015-12-15 2016-08-31 乐视致新电子科技(天津)有限公司 一种视频画面的绘制方法及装置
CN105791938B (zh) * 2016-03-14 2019-06-21 腾讯科技(深圳)有限公司 多媒体文件的拼接方法和装置
PH12016000220A1 (en) * 2016-06-06 2018-02-12 Samsung Electronics Co Ltd Signal processing with operating state-dependent handling of multimedia attributes
CN108449641B (zh) * 2018-03-28 2021-04-27 聚好看科技股份有限公司 播放媒体流的方法、装置、计算机设备和存储介质
CN108882038B (zh) * 2018-06-25 2020-10-27 苏宁易购集团股份有限公司 一种基于Android的多路视频播放方法
CN111314791B (zh) * 2020-03-19 2022-04-05 杭州小影创新科技股份有限公司 一种基于Android的视频播放中无缝跳转方法
CN113709556A (zh) * 2020-05-20 2021-11-26 中兴通讯股份有限公司 频道切换方法、装置、设备、系统和存储介质
CN112363723A (zh) * 2020-11-11 2021-02-12 海看网络科技(山东)股份有限公司 一种动态组合安卓布局的方法
CN112929733B (zh) * 2021-01-18 2022-06-28 稿定(厦门)科技有限公司 视频预览播放方法及装置
CN113411683B (zh) * 2021-06-23 2022-07-22 北京奇艺世纪科技有限公司 一种视频播放方法及装置
CN113407283A (zh) * 2021-06-24 2021-09-17 优地网络有限公司 一种界面显示方法、装置及电子设备

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108235096A (zh) * 2018-01-18 2018-06-29 湖南快乐阳光互动娱乐传媒有限公司 移动终端硬解码智能切换软解码播放视频的方法
CN110572715A (zh) * 2019-09-24 2019-12-13 四川长虹电器股份有限公司 一种解决Android TV播放webp卡顿的方法

Also Published As

Publication number Publication date
CN114071229A (zh) 2022-02-18

Similar Documents

Publication Publication Date Title
CN108156520B (zh) 视频播放方法、装置、电子设备及存储介质
CN101815199B (zh) 一种视频处理方法及终端
WO2020103218A1 (zh) 一种WebRTC中的直播流处理方法及推流客户端
JP2018026816A (ja) 動画録画方法およびシステム
EP3975126A1 (en) Method and system for cloud-native 3d-scene game
US20050132385A1 (en) System and method for creating and executing rich applications on multimedia terminals
CN112929740B (zh) 一种渲染视频流的方法、装置、存储介质及设备
CN107995482B (zh) 视频文件的处理方法和装置
CN109788212A (zh) 一种分段视频的处理方法、装置、终端和存储介质
US11900551B2 (en) Creating cloud-hosted, streamed augmented reality experiences with low perceived latency
CN113893524B (zh) 云应用处理系统、方法、装置及设备
WO2017129117A1 (zh) 一种gpu资源重建的方法、用户设备,系统及存储介质
JP6379107B2 (ja) 情報処理装置並びにその制御方法、及びプログラム
CN112004041A (zh) 视频录制方法、装置、终端及存储介质
EP4089515A2 (en) User interface engine for cloud ui rendering
CN115002359A (zh) 视频处理方法、装置、电子设备及存储介质
CN113365150B (zh) 视频处理方法和视频处理装置
CN114445600A (zh) 一种特效道具的展示方法、装置、设备及存储介质
CN114071229B (zh) 一种解决SurfaceView渲染器重载视频解码时回收延迟的方法
WO2018094261A1 (en) Method and system for managing buffers
CN111954041A (zh) 一种视频加载方法、计算机设备及可读存储介质
CN113411661B (zh) 用于记录信息的方法、装置、设备、存储介质及程序产品
CN116309969A (zh) 游戏内的剧情动画生成方法、装置、存储介质与电子设备
CN116112617A (zh) 演播画面的处理方法、装置、电子设备及存储介质
CN117065357A (zh) 媒体数据处理方法、装置、计算机设备和存储介质

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant