How to capture a frame from video in android?

前端 未结 2 1973
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 15:09

Hi i have made a custom video played in android.with some simple \"play\",\"pause\",\"play again\" and \"capture\" button.NOw i have done all this functionalities except \"c

2条回答
  •  青春惊慌失措
    2021-01-20 15:59

    You can get a video frame with MediaMetadataRetriever. The basic usage is as follows.

    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    
    // Set data source to retriever.
    // From your code, you might want to use your 'String path' here.
    retriever.setDataSource(yourPath);
    
    // Get a frame in Bitmap by specifying time.
    // Be aware that the parameter must be in "microseconds", not milliseconds.
    Bitmap bitmap = retriever.getFrameAtTime(timeInMicroSeconds);
    
    // Do something with your bitmap.
    

    You might want to use FFmpegMediaMetadataRetriever for better performance.

提交回复
热议问题