bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.45k stars 1.57k forks source link

is grabber's startUnsafe have any risk? #2030

Open ggslayer opened 1 year ago

ggslayer commented 1 year ago

Hi, I met a problem when grab local video file and remote rtmp concurrent, when the rtmp is no stream, the rtmp's grabber's start method will block in the start method by rw_timeout,in this time, if local file 's grabber's start called, this call will block by the code in start method : synchronized (org.bytedeco.ffmpeg.global.avcodec.class)

So, I found the no synchronized version: startUnsafe and releaseUnsafe,I use them in the unstable rtmp situation and start/stop in local file, there is no problem found.

But, I worried about the "unsafe", Can you tell me is there some risk about the startunsafe/releaseUnsafe ? thank you!

saudet commented 1 year ago

Some codecs are not thread-safe, but if the codecs you are using are thread-safe, then we don't need the extra synchronization.

ggslayer commented 1 year ago

In my scene, the libx264 and libacc are used, do you know and can you tell me they are thread safe? thank you @saudet