vlcj HeadlessMediaPlayer автоматическое завершение при обработке потока RTSP - PullRequest
0 голосов
/ 15 марта 2019

Я пытаюсь захватывать кадры с ip-камеры для обработки изображений, я использую HeadlessMediaPlayer для воспроизведения медиа с камеры и получаю BufferedImage в функции обратного вызова. Но он всегда останавливает воспроизведение после нескольких воспроизведенных сцен, затем программа завершается без исключения. Вот вывод консоли:

2019-03-15 10:21:26,344  INFO Info:78 - vlcj: 3.12.1
2019-03-15 10:21:26,348  INFO Info:79 - java: 1.8.0_171 Oracle Corporation
2019-03-15 10:21:26,348  INFO Info:80 - java home: E:\Java\jdk\jre
2019-03-15 10:21:26,350  INFO Info:81 - os: Windows 10 10.0 amd64
2019-03-15 10:21:27,286  INFO NativeDiscovery:121 - Discovery found libvlc at 'E:\VLC'
2019-03-15 10:21:27,565  INFO LibVlcFactory:171 - vlc: 3.0.4 Vetinari, changeset 3.0.4-0-gf615db6332
2019-03-15 10:21:27,565  INFO LibVlcFactory:172 - libvlc: E:\VLC\libvlc.dll
Start to play.
[0000000022740300] avcodec decoder: Using D3D11VA (NVIDIA GeForce RTX 2080, vendor 4318(NVIDIA), device 7810, revision 161) for hardware decoding
Stop.
Process finished with exit code 0

А это мой код

 new NativeDiscovery().discover();
    // Configure player factory.
    String[] VLC_ARGS = {
            "--intf", "dummy",          // no interface
            "--vout", "dummy",          // we don't want video (output)
            "--no-audio",               // we don't want audio (decoding)
            "--no-video-title-show",    // nor the filename displayed
            "--no-stats",               // no stats
            "--no-sub-autodetect-file", // we don't want subtitles
            "--no-disable-screensaver", // we don't want interfaces
            "--no-snapshot-preview",    // no blending in dummy vout
    };
    MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(VLC_ARGS);
    // Create player.
    HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
    // Select input device.
    String mrl = "rtsp://admin:wls771102@192.168.14.191:554/h264/ch1/sub/av_stream";  // Linux
    // Start processing.
    mediaPlayer.startMedia(mrl);
    mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventListener() {
        @Override
        public void mediaChanged(MediaPlayer mediaPlayer, libvlc_media_t libvlc_media_t, String s) {

        }

        @Override
        public void opening(MediaPlayer mediaPlayer) {

        }

        @Override
        public void buffering(MediaPlayer mediaPlayer, float v) {

        }

        @Override
        public void playing(MediaPlayer mediaPlayer) {
            image = mediaPlayer.getSnapshot();  //getBufferedImage
        }

        @Override
        public void paused(MediaPlayer mediaPlayer) {

        }

        @Override
        public void stopped(MediaPlayer mediaPlayer) {

        }

        @Override
        public void forward(MediaPlayer mediaPlayer) {

        }

        @Override
        public void backward(MediaPlayer mediaPlayer) {

        }

        @Override
        public void finished(MediaPlayer mediaPlayer) {

        }

        @Override
        public void timeChanged(MediaPlayer mediaPlayer, long l) {

        }

        @Override
        public void positionChanged(MediaPlayer mediaPlayer, float v) {

        }

        @Override
        public void seekableChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void pausableChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void titleChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void snapshotTaken(MediaPlayer mediaPlayer, String s) {

        }

        @Override
        public void lengthChanged(MediaPlayer mediaPlayer, long l) {

        }

        @Override
        public void videoOutput(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void scrambledChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void elementaryStreamAdded(MediaPlayer mediaPlayer, int i, int i1) {

        }

        @Override
        public void elementaryStreamDeleted(MediaPlayer mediaPlayer, int i, int i1) {

        }

        @Override
        public void elementaryStreamSelected(MediaPlayer mediaPlayer, int i, int i1) {

        }

        @Override
        public void corked(MediaPlayer mediaPlayer, boolean b) {

        }

        @Override
        public void muted(MediaPlayer mediaPlayer, boolean b) {

        }

        @Override
        public void volumeChanged(MediaPlayer mediaPlayer, float v) {

        }

        @Override
        public void audioDeviceChanged(MediaPlayer mediaPlayer, String s) {

        }

        @Override
        public void chapterChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void error(MediaPlayer mediaPlayer) {

        }

        @Override
        public void mediaPlayerReady(MediaPlayer mediaPlayer) {

        }

        @Override
        public void mediaMetaChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void mediaSubItemAdded(MediaPlayer mediaPlayer, libvlc_media_t libvlc_media_t) {

        }

        @Override
        public void mediaDurationChanged(MediaPlayer mediaPlayer, long l) {

        }

        @Override
        public void mediaParsedChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void mediaParsedStatus(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void mediaFreed(MediaPlayer mediaPlayer) {

        }

        @Override
        public void mediaStateChanged(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void mediaSubItemTreeAdded(MediaPlayer mediaPlayer, libvlc_media_t libvlc_media_t) {

        }

        @Override
        public void newMedia(MediaPlayer mediaPlayer) {

        }

        @Override
        public void subItemPlayed(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void subItemFinished(MediaPlayer mediaPlayer, int i) {

        }

        @Override
        public void endOfSubItems(MediaPlayer mediaPlayer) {

        }
    });
...