1

i'm making and android application that stream a video from external source and display it in a videoview in my activity. The stream working fine, but i'm unable to save a frame on my sd card. this is my code where vv is 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();

this is my video test url:

public String viewSource = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov";

i try to set viewSourc for 'setdatasource' of the mediametadataretriver like the url to my video, but it return always null bitmap...

where is the problem?

Thankyou

Simone M
  • 677
  • 1
  • 10
  • 26

1 Answers1

3

This class has a lot of problems and I think one of them is the frame retrieving from a external source. I would suggest you to use this external library. You only have to add it into your project and next use the class like you do with the mediametadataretriever class.

Hope it´s useful

Gonzalo Solera
  • 1,182
  • 12
  • 26