bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.61k stars 1.59k forks source link

Screen tear when recording at 1080p on Android #1561

Open sasanian opened 3 years ago

sasanian commented 3 years ago

Hello. I'm recording video with some graphics superimposed that's being applied on top, which is why I'm using Javacv library. I can record video at 720p at 30 fps without any issues. However when I switch to 1080p there is screen tear. here's my code I use to init recorder.

int frameRate = 30; converter = new AndroidFrameConverter(); ffmpeg_link = Environment.getExternalStorageDirectory().getAbsolutePath()+String.format("/dashcam_%03d.flv", vidIndex); recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight); recorder.setFormat("mp4"); recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC); recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); recorder.setVideoOption("preset", "ultrafast"); recorder.setFrameRate(frameRate); recorder.setVideoBitrate(10 * 1024 * 1024); recorder.setSampleRate(sampleAudioRateInHz); recorder.setAudioChannels(1); recorder.setAudioBitrate(96000); // default 192000 audioRecordRunnable = new AudioRecordRunnable();

Thanks in advance for your help.

saudet commented 3 years ago

That's probably happening in the source frames, in the Android API. You'll most likely need to figure out how to capture from Android without tear for that, which isn't something that's related to JavaCV at all.

sasanian commented 3 years ago

That's probably happening in the source frames, in the Android API. You'll most likely need to figure out how to capture from Android without tear for that, which isn't something that's related to JavaCV at all.

You were right. It's not JavaCV related. Thanks for your help.