Closed redoriental closed 1 year ago
long interval = 1_000 / 30;
long startTime = System.currentTimeMillis(); Frame frame; while ((frame = grabber.grab()) != null) { recorder.record(frame); long currentTime = 1_000 * (System.currentTimeMillis() - startTime); long frameTime = frame.timestamp; long sleepTime = (frameTime - currentTime) / 1_000; try { if (sleepTime > 500 + interval) { Thread.sleep(interval); } } catch (Exception e) { e.printStackTrace(); } }
When I use this code, I will have the problem that the sound and picture are not synchronized
If I use ffmpeg.exe directly, this problem will not occur
Try to call setTimestamp(frame.timestamp) before record(). Please do not open duplicate issues.
Duplicate of #1972
long interval = 1_000 / 30;
When I use this code, I will have the problem that the sound and picture are not synchronized