在Android中流畅地擦洗视频 [英] Smooth Scrubbing video in Android

查看:117
本文介绍了在Android中流畅地擦洗视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Android VideoView实现流畅的视频清理. MediaPlayerseekTo方法未完全满足我的要求.它并没有精确地找到我经过的毫秒数,它实际上是从/跳到最近的位置,而不是我想要的精确位置.框架也显示有很大的间隙.不是毫秒的确切帧.

I am trying to achieve smooth video scrubbing with Android VideoView. The seekTo method of MediaPlayer is not doing exactly what i want. It does not exactly seek to millisecond i passed in it, it actually plays from/jumps to the nearest position, not the exact I seeked to. Also the frames are showing with a large gaps. Not the exact frame for millisecond.

我继续搜索,发现SEEK_CLOSEST_SYNC只能搜索到最接近的同步帧,而不能精确搜索.这取决于视频的生成方式. 我如何才能实现平滑的擦洗并寻求精确的位置,即使视频已暂停或正在播放.是否可以通过Android VideoViewMediaPlayer类,还是应该更改方法?

I came on searching around and found that SEEK_CLOSEST_SYNC can only seek to the nearest sync frame not the EXACT. It depends on the way the video was generated. How can i achieve the smooth scrubbing and seek to exact position Even video is paused or playing. Is it possible through Android VideoView or MediaPlayer class or should i change the approach?

推荐答案

这不是直接要回答的问题.我花了一个月的时间自己研究和实施.

This is not a straight forward question to answer. I spent a month researching and implementing it myself.

唯一可以实现的方法是使用 MediaCodec .

The only way this can be achieved is using MediaCodec.

您可以查看项目,该项目使用MediaCodec进行了精确的清理.我对该项目的唯一问题是加载缓冲区并将其显示在表面上需要花费大约0.5秒的时间.

You can look at this project that does exact scrubbing using MediaCodec. The only issue I had with that project is that it takes time to load the buffer and display it on the surface, about 0.5 seconds.

您还可以查看 Grafica ,尤其是MoviePlayer类.另一个来源是 BigFlake 网站.

You can also have a look at Grafica, especially the MoviePlayer class. Another source is the BigFlake website.

我最终要做的是使用MediaCodec创建自己的实现,因为当我构建高尔夫分析仪时,它们都无法提供我想要的东西,我需要(实时)精确(每帧) -frame)视频的擦洗.

What I ended up doing is creating my own implementation using MediaCodec as none of them provided me exactly what I was looking for, as I was building a golf analyzer, I needed (real-time) precise (frame-per-frame) scrubbing of the video.

您还可以查看一个问题,该问题类似于为此,我在其中添加了许多有关如何实现此目标的信息.尽管这个问题更多地是关于逐帧播放视频,但我认为其中包含有价值的信息.

You can also look at a question I asked that is similar to this, where I added a lot of info on how I achieved this. Though this question is more about playing a video frame-per-frame, I think there is valuable info in it.

这篇关于在Android中流畅地擦洗视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆