问题描述
我试图找到一个解决方案,寻求逐帧(不仅关键帧)在我的Android应用程序。
-
办法:一个简单的
VideoView
的Android SDK中的
:
在这里,我有一个onSeekCompleteListener
的MediaPlayer
从在$ P $的基类pparedListener
的VideoView
和暂停
播放权后开始,并移动到preferred位置。照片问题:只有寻求关键帧 ! -
办法:
MediaMetaRetriever
:我有这样的事情:类MediaMetadataRetriever猎犬; 朗姿; ImageView的视频; TextView的lbPosition; @覆盖 保护无效的onCreate(包savedInstanceState){ super.onCreate(savedInstanceState); 的setContentView(R.layout.activity_main); 视频=(ImageView的)findViewById(R.id.imVideo); lbPosition =(TextView中)findViewById(R.id.lbPosition); bnTake =(按钮)findViewById(R.id.bntake); retriever.setDataSource(此,Uri.parse(android.resource://+ getPackageName()+/+ R.raw.vid)); video.setOnClickListener(新ImageView.OnClickListener(){ @覆盖 公共无效的onClick(查看为arg0){ 职位+ = 100000; 位图帧= retriever.getFrameAtTime(位置,MediaMetadataRetriever.OPTION_CLOSEST); video.setImageBitmap(架); lbPosition.setText(将String.valueOf(位置)); } }); bnTake.setOnClickListener(新Button.OnClickListener(){ @覆盖 公共无效的onClick(查看为arg0){ 意图takeVideoIntent =新的意图(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(takeVideoIntent,123123); } }); }
当我使用 OPTION_CLOSESTS
在 retriever.getFrameAtTime
它给了我一个 getFrameAtTime:videoFrame是一个NULL
指针错误。当我不使用这个选项,它通过关键帧。
也许可能的解决方案:
-
办法:更多的关键帧录制视频。如果我将记录在我的Android应用程序具有更高的
关键帧速率
视频,会是一个解决方案?这可能吗? -
办法(我没试过!):视频播放器的第三方库的机器人使用我听说过的东西
FFMPEG
。是否有任何可以争取,而在暂停状态,并更新位置的屏幕? 在视频库
您是否尝试过 FFmpegMediaMetadataRetriever
I've tried to find a solution to seek frame by frame (not only to keyframes) in my android app.
approach: A simple
VideoView
of theandroid sdk
:
Here I've got aonSeekCompleteListener
of the base classMediaPlayer
from theonPreparedListener
ofVideoView
andpause
the playback right after started it and moved to a preferred position.
Problem: Only seeks to keyframes!approach:
MediaMetaRetriever
:I have got something like this:MediaMetadataRetriever retriever; long Position; ImageView video; TextView lbPosition; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); video = (ImageView)findViewById(R.id.imVideo); lbPosition = (TextView)findViewById(R.id.lbPosition); bnTake = (Button)findViewById(R.id.bntake); retriever.setDataSource(this, Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.vid)); video.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View arg0) { Position += 100000; Bitmap frame = retriever.getFrameAtTime(Position, MediaMetadataRetriever.OPTION_CLOSEST); video.setImageBitmap(frame); lbPosition.setText(String.valueOf(Position)); } }); bnTake.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View arg0) { Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(takeVideoIntent, 123123); } }); }
When I use OPTION_CLOSESTS
in retriever.getFrameAtTime
it gives me a getFrameAtTime: videoFrame is a NULL
pointer error. When I don't use this option, it goes through keyframes.
Maybe possible solutions:
approach: Record video with more keyframes. If I would record the video with an higher
keyframe rate
in my android app, could that be a solution? Is this possible?approach (I haven't tried!): I've heard something of video player 3rd party libraries for android that use
FFMPEG
. Is there any library that can seek while in pause state and update the position for the video on the screen?
Have you tried FFmpegMediaMetadataRetriever?
这篇关于如何不寻求关键帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!