Open redoriental opened 1 year ago
We can't do that with recordPacket(). Please use record() for that.
thank you,my friend!What is the reason why the sound and picture are not synchronized sometimes in the record() method?
我们不能用 recordPacket() 来做到这一点。请为此使用 record()。
What is the reason why the sound and picture are not synchronized sometimes in the record() method
Please try to call recorder.setTimestamp(grabber.getTimestamp()) before record().
Make sure to call record() with a timestamp argument.
Oh,yes!thank you very much!Your project is very good,and hope you can create more fast javacv version that the delay can become lower.
where are you from? I believe we can become very good friends.
Oh,yes!thank you very much!Your project is very good,and hope you can create more fast javacv version that the delay can become lower.
We can use hardware acceleration to make it faster: https://trac.ffmpeg.org/wiki/HWAccelIntro
where are you from? I believe we can become very good friends.
There's a few places where you can look for that information, like here: https://www.linkedin.com/in/samuel-audet-24aa1627/
thank you
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(o, grabber.getImageWidth(), grabber.getImageHeight()); // 部分监控设备流信息里携带的帧率为9000,如出现此问题,会导致dts、pts时间戳计算失败,播放器无法播放,故出现错误的帧率时,默认为25帧 if (grabber.getFrameRate() > 0 && grabber.getFrameRate() < 100) { framerate = grabber.getFrameRate(); } else { framerate = 25.0; } recorder.setInterleaved(true); // 关键帧间隔,一般与帧率相同或者是视频帧率的两倍 recorder.setGopSize((int) framerate * 2); // 视频帧率(保证视频质量的情况下最低25,低于25会出现闪屏) recorder.setFrameRate(framerate); // 设置比特率 recorder.setVideoBitrate(grabber.getVideoBitrate()); recorder.setVideoCodec(AV_CODEC_ID_H264); // h264编/解码器 recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); //视频参数 Map<String, String> videoOption = new HashMap<>(); // 该参数用于降低延迟 videoOption.put("tune", "zerolatency"); videoOption.put("preset", "ultrafast"); videoOption.put("crf", "28"); videoOption.put("vcodec","libx264"); //------------------------------- recorder.setMaxDelay(500); recorder.setAudioOption("crf", "0"); // 最高音质 recorder.setAudioQuality(0); // 192 Kbps recorder.setAudioBitrate(192000); recorder.setSampleRate(44100); recorder.setAudioChannels(2); recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC); //-------------------------------- recorder.setOptions(videoOption);
FLV does not support sample rate 48000, choose from (44100, 22050, 11025)