Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some problem with these code, sometime recorder may blocked? #2180

Open
swinghu opened this issue Jan 30, 2024 · 0 comments
Open

Some problem with these code, sometime recorder may blocked? #2180

swinghu opened this issue Jan 30, 2024 · 0 comments

Comments

@swinghu
Copy link

swinghu commented Jan 30, 2024

        FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(localPath, width, height);
        recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
        recorder.setFrameRate(frame);
        recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
        recorder.setFormat("mp4");
        recorder.start();

        Future<Void> future =closeTaskExecutor.submit(()->{
                int index = imgMap.firstKey();
                int maxIndex = imgMap.lastKey();
                try {
                    for(int i =0; i<timeSlash; i++) {
                        for(int j =0; j<frame; j++) {
                            sb.append(" " + index);
                            File file = imgMap.get(index);
                            if (null == file){
                                continue;
                            }
                            recorder.record(imgFrameMap2.get(index).get());
                            index++;
                            if (index > maxIndex) {
                                break;
                            }
                        }
                    }
                }catch (Exception e) {
                    LOGGER.error("e, ", e);
                }finally {
                    LOGGER.info("future release record!");
                    try {
                        recorder.stop();
                        recorder.release();
                    }catch (Exception e){
                        LOGGER.warn("e ", e);
                    }
                }
                return null;
            });

most of the time run very well record finished in 300ms , but when request press goes up, some times it record slowly , may cost more than 20s, some problem with the implemention? May javacv + ffmpeg some component would be blocked?

version info :
org.bytedeco:javacv-platform:1.5.5
org.bytedeco:ffmpeg:4.3.2-1.5.5:linux-x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants