wseemann / FFmpegMediaMetadataRetriever

FFmpegMediaMetadataRetriever provides a unified interface for retrieving frame and meta data from an input media file.
1.72k stars 387 forks source link

FFmpegMediaMetadataRetriever keep scanning url in background #259

Closed montasar8 closed 1 year ago

montasar8 commented 2 years ago

Hi , i am using FFmpegMediaMetadataRetriever in my android app side by side with libvlc , my problem is after pulling info from the video url the FFmpegMediaMetadataRetriever keeps scanning the stream in the background

this is my code :

                  ((LiveActivity) getContext()).mmr.setDataSource(
                            Constants.getLiveStreamUrl(epgChannel.getStream_id()));
                    String audio = ((LiveActivity) getContext()).mmr.extractMetadata(
                            FFmpegMediaMetadataRetriever.METADATA_KEY_AUDIO_CODEC);
                    String video = ((LiveActivity) getContext()).mmr.extractMetadata(
                            FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_CODEC);
                    String frameRate = ((LiveActivity) getContext()).mmr.extractMetadata(
                            FFmpegMediaMetadataRetriever.METADATA_KEY_FRAMERATE);
                    String width = ((LiveActivity) getContext()).mmr.extractMetadata(
                            FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);

                    String resolution = "HD";
                    if (Integer.parseInt(width) <= 720) {
                        resolution = "SD";
                    } else if (Integer.parseInt(width) <= 1280) {
                        resolution = "HD";
                    } else if (Integer.parseInt(width) <= 1920) {
                        resolution = "FULL HD";
                    } else if (Integer.parseInt(width) <= 3840) {
                        resolution = "ULTRA HD";
                    }
                    String finalResolution = resolution;
                    if (getContext() != null)
                        ((Activity) getContext()).runOnUiThread(() -> {
                            video_codec.setText(video);
                            audio_codec.setText(audio);
                            frame_rate.setText(frameRate + " FPS");
                            video_resolution.setText(finalResolution);
                        });
                }
            } catch (Exception e) {

                if (getContext() != null)
                    ((Activity) getContext()).runOnUiThread(() -> {
                        txt_first_epg.setText("No Information");
                        txt_second_epg.setText("No Information");
                        video_codec.setText("...");
                        audio_codec.setText("...");
                        frame_rate.setText("...");
                        video_resolution.setText("...");
                    });

                e.printStackTrace();
wseemann commented 1 year ago

@montasar8 This is possibly because I don't see a call to [release()](https://wseemann.github.io/FFmpegMediaMetadataRetriever/apidocs/wseemann/media/FFmpegMediaMetadataRetriever.html#release()) in your code.

wseemann commented 1 year ago

Closed due to inactivity.