bytedeco / javacv

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

can i add FFmpegFrameRecorder after FFmpegFrameGrabber grabber.grab() #2038

Closed skill7899 closed 1 year ago

skill7899 commented 1 year ago

i try to do it but it will throw excpetion


10:00:13.937 [pool-6-thread-1] ERROR com.gc.iotools.stream.os.OutputStreamToInputStream - IOException while empty InputStream a thread can be locked
java.io.IOException: Write end dead
    at java.io.PipedInputStream.read(PipedInputStream.java:310)
    at java.io.PipedInputStream.read(PipedInputStream.java:377)
    at java.io.InputStream.read(InputStream.java:101)
    at com.gc.iotools.stream.os.OutputStreamToInputStream$DataConsumer.emptyInputStream(OutputStreamToInputStream.java:132)
    at com.gc.iotools.stream.os.OutputStreamToInputStream$DataConsumer.call(OutputStreamToInputStream.java:123)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    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)

org.bytedeco.javacv.FFmpegFrameRecorder$Exception: av_interleaved_write_frame() error -1 while writing interleaved video packet. (For more details, make sure FFmpegLogCallback.set() has been called.)
    at org.bytedeco.javacv.FFmpegFrameRecorder.writePacket(FFmpegFrameRecorder.java:1337)
    at org.bytedeco.javacv.FFmpegFrameRecorder.recordImage(FFmpegFrameRecorder.java:1093)
    at com.xxx.RtmpGrabber$1.run(RtmpGrabber.java:224)
    at java.util.concurrent.CompletableFuture$AsyncRun.run$$$capture(CompletableFuture.java:1640)
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java)
    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)
skill7899 commented 1 year ago

when i use recorder with outputStreamToInputStream or PipedInputStream will throw excpetion after FFmpegFrameGrabber grabber.grab() , but it work in FileOutputStream, so it‘s maybe a bug? @saudet

saudet commented 1 year ago

Maybe this will help you? https://stackoverflow.com/questions/5453525/write-end-dead-exception-using-pipedinputstream-java

skill7899 commented 1 year ago

Maybe this will help you? https://stackoverflow.com/questions/5453525/write-end-dead-exception-using-pipedinputstream-java

Thank you, I know the reason。I use multithreaded programming, The start of grap and record not same thread。i adjust the code。it work will。