bytedeco/javacv

When to get data from recorder's stream

Open

#1,773 opened on Mar 8, 2022

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Java (1,583 forks)batch import
help wantedquestion

Repository metrics

Stars
 (6,985 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I tried this for record sample data

PipedOutputStream pos=new PipedOutputStream();
FFMpegFrameRecorder recorder=new FFmpegFrameRecorder(pos,channels);
PipedInputStream pis=new PipedInputStream(pos,640000);
...setRecorder...
recorder.start();
....get frame from somewhere...
while((frame!=null){
     recorder.record(frame);
     while(pis.avaliable()>0){
          pis.read(new byte[2048]);
    }
    frame.close();
}

I run this code for a while and the JVM crushed. Location is swr_convert called by recordSample() As I known. the data in frame won't be put in the stream immediately when the recorder.record(sample) is called. Usually I can only get the date from pis after several frame is recorded(for example 10frames) So I think this problem may be caused by I closing the frame before the data is dump into the stream actually. But I have to close this frame. some flush methods from recorder、pos、pis. I alse tried these. but no effect. Do you have some idea on how to flush the frame data into pis immediately? Looking forward to your reply

Contributor guide