相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to create a video player in Java using JavaCV and its FFmpegFrameGrabber class. Simply, Inside a loop, I use

.grab() to get a frame and then paint it on a panel

Problem is, player gets delayed. For example, after 30 seconds passes, in video only 20 seconds passes.

Source is ok. Other players can play the stream normally. Problem is possibly the long printing time.

What I do not understand is that : "why does .grab() method brings me a frame from 10 seconds ago ?" Shouldn't it just grab the frame which is being streamed at the moment ?

(Sorry for not providing a working code, it's all over different huge classes)

I use the following grabber options (selected by some other colleague):

grabber.setImageHeight(480);
grabber.setImageWidth(640);
grabber.setOption("reconnect", "1");
grabber.setOption("reconnect_at_eof", "1");
grabber.setOption("reconnect_streamed", "1");
grabber.setOption("reconnect_delay_max", "2");
grabber.setOption("preset", "veryfast");
grabber.setOption("probesize", "192");
grabber.setOption("tune", "zerolatency");
grabber.setFrameRate(30.0);
grabber.setOption("buffer_size", "" + this.bufferSize);
grabber.setOption("max_delay", "500000");
grabber.setOption("stimeout", String.valueOf(6000000));
grabber.setOption("loglevel", "quiet");
grabber.start();

Thanks

idk if it's too late but ffmpeg holds a buffer queue with recent frames, you'll have to read its frames before this queue gets filled, otherwise you will start losing frames because FFMpeg drops frames when whit queue is filled – guijob Oct 2, 2019 at 21:40

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

 
推荐文章