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

Using the FFmpegFrameGrabber.start() method, one thread is blocked。 #2200

Open
Aismy opened this issue Mar 1, 2024 · 4 comments
Open

Using the FFmpegFrameGrabber.start() method, one thread is blocked。 #2200

Aismy opened this issue Mar 1, 2024 · 4 comments

Comments

@Aismy
Copy link

Aismy commented Mar 1, 2024

You can see that one thread is blocked in the avformat_open_input method after entering the start() method, causing other threads to be unable to acquire the lock to process all the BLOCKED states.

"media-87" #217 prio=5 os_prio=0 cpu=2532193.98ms elapsed=3003.56s tid=0x00007fd42c003000 nid=0x366c08 runnable [0x00007fd21c66e000]
java.lang.Thread.State: RUNNABLE
at org.bytedeco.ffmpeg.global.avformat.avformat_open_input(Native Method)
at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:972)
- locked <0x00000005becf30f8> (a org.bytedeco.javacv.FFmpegFrameGrabber)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:903)
- locked <0x00000000807230b0> (a java.lang.Class for org.bytedeco.ffmpeg.global.avcodec)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:898)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)

"media-92" #222 prio=5 os_prio=0 cpu=68.47ms elapsed=2963.55s tid=0x00007fd320003000 nid=0x36762f waiting for monitor entry [0x00007fd21c16e000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:902)
- waiting to lock <0x00000000807230b0> (a java.lang.Class for org.bytedeco.ffmpeg.global.avcodec)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:898)
at reactor.core.publisher.LambdaMonoSubscriber.onNext(LambdaMonoSubscriber.java:137)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192)
at reactor.core.publisher.FluxSubscribeOnValue$ScheduledScalar.run(FluxSubscribeOnValue.java:178)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)

this is my code:
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("http://xxxxx");
grabber.start();

@saudet
Copy link
Member

saudet commented Mar 1, 2024

Please try to call startUnsafe() instead of start().

@Aismy
Copy link
Author

Aismy commented Mar 4, 2024

startUnsafe() will also acquire the lock ah, my method is blocked in the startUnsafe() method inside ah, and blocked for several days!

@Aismy
Copy link
Author

Aismy commented Mar 4, 2024

Now blocking at avformat_open_input() in startUnsafe()

@saudet
Copy link
Member

saudet commented Mar 9, 2024

Make sure to set a timeout value

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