javacv-ffmpeg (6) performance improvement

Description

Most of my performance improvements are tricks, that is, to improve performance in business or logic.
There is a synchronization code block in FFmpegFrameGrabber, and I haven't tried the consequences after dropping it. Mainly lazy.
If anyone tries, please give back the results, thank you.

1. Live screenshot

Because of the problem of synchronizing code blocks, thread pool threads should not be too many.
If you have been receiving stream information and taking screenshots, the 8-core CPU that consumes a lot of resources and supports 16-50 channels is good, depending on the resolution.

Solution: See if the requirement is a picture per second (this can be configured and managed)
plus a task queue,
get the first key frame after the url is connected,
save the picture and close it,
update the next execution time, and
re-add the task to the queue.

2-core cpu supports about 200-250 roads

Two, video recording

Video recording cannot be so tricky,
but the main resource consumption of video recording is decoding and encoding during recording.

Solution:
Use recordPacket method without default or set codec

AVPacket pkt = null;
while (isStart) {
    
    
	pkt = grabber.grabPacket();
	recorder.recordPacket(pkt);
	org.bytedeco.ffmpeg.global.avcodec.av_packet_unref(pkt);
}

Guess you like

Origin blog.csdn.net/u013947963/article/details/103426088