bytedeco/javacv

Cannot play ffmpeg in JavaFX MediaPlayer

Open

#1,140 opened on Feb 16, 2019

View on GitHub
 (23 comments) (0 reactions) (0 assignees)Java (1,583 forks)batch import
enhancementhelp wantedquestion

Repository metrics

Stars
 (6,985 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

What I have to set for recording video stream. I can play result in VLC but not in JavaFX MediaPlayer. There is no exception just no playing. Code:

        recorder = new FFmpegFrameRecorder(file, captureWidth, captureHeight);
        recorder.setFormat("mp4");
        recorder.setVideoCodecName("libx264");
        recorder.setAudioChannels(0);

I dried with different options:

        recorder = new FFmpegFrameRecorder(file, captureWidth, captureHeight);
        recorder.setVideoBitrate(10 * captureWidth * captureHeight);
        recorder.setFormat("mp4");
        recorder.setVideoCodecName("libx264");
        recorder.setVideoOption("crf", "23");
        recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
        recorder.setFrameRate(30);
        recorder.setGopSize(60);
        recorder.setAudioChannels(0);

Contributor guide