Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从外部设备通过setVideoURI流从android videoview获取帧?_Android_Bitmap_Streaming_Android Videoview - Fatal编程技术网

如何从外部设备通过setVideoURI流从android videoview获取帧?

如何从外部设备通过setVideoURI流从android videoview获取帧?,android,bitmap,streaming,android-videoview,Android,Bitmap,Streaming,Android Videoview,我正在制作一个android应用程序,从外部源流式传输视频,并在我的活动中的视频视图中显示它。 流运行良好,但我无法在sd卡上保存帧。这是我的代码,其中vv是videoview: int currentPosition = vv.getCurrentPosition(); //in millisecond MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); m

我正在制作一个android应用程序,从外部源流式传输视频,并在我的活动中的视频视图中显示它。 流运行良好,但我无法在sd卡上保存帧。这是我的代码,其中vv是videoview:

int currentPosition = vv.getCurrentPosition(); //in millisecond

        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        mediaMetadataRetriever.setDataSource(viewSource);

        Bitmap bmFrame = mediaMetadataRetriever.getFrameAtTime(currentPosition * 1000); //unit in microsecond

        if(bmFrame == null){
             Toast.makeText(MainActivity.this, 
               "bmFrame == null!", 
               Toast.LENGTH_LONG).show();
            }else{
             AlertDialog.Builder myCaptureDialog = 
               new AlertDialog.Builder(MainActivity.this);
             ImageView capturedImageView = new ImageView(MainActivity.this);
             capturedImageView.setImageBitmap(bmFrame);
             LayoutParams capturedImageViewLayoutParams = 
               new LayoutParams(LayoutParams.WRAP_CONTENT, 
                 LayoutParams.WRAP_CONTENT);
             capturedImageView.setLayoutParams(capturedImageViewLayoutParams);

             myCaptureDialog.setView(capturedImageView);
             myCaptureDialog.show();
这是我的视频测试url:

public String viewSource = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov";
我尝试为MediaMetadataRetriever的“setdatasource”设置viewSourc,就像我的视频的url一样,但它总是返回空位图

问题在哪里


谢谢

这个类有很多问题,我认为其中之一就是从外部源检索帧。我建议你使用。您只需将其添加到项目中,然后像使用mediametadataretriever类一样使用该类

希望它有用