Skip to content

Commit

Permalink
Reapply "Break out of the FFmpegFrameRecorder writePacket loop after …
Browse files Browse the repository at this point in the history
…maxRetries iterations instead of a single iteration."

This reverts commit bc8af55.
  • Loading branch information
Josh Bultman committed Dec 2, 2024
1 parent bc8af55 commit fce1be3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,8 @@ private boolean writeFrame(AVFrame frame) throws Exception {
frame.pts(frame.pts() + frame.nb_samples()); // magic required by libvorbis and webm
}

int retries = 0;
int maxRetries = 1000;
/* if zero size, it means the image was buffered */
got_audio_packet[0] = 0;
while (ret >= 0) {
Expand All @@ -1376,7 +1378,7 @@ private boolean writeFrame(AVFrame frame) throws Exception {
/* write the compressed frame in the media file */
writePacket(AVMEDIA_TYPE_AUDIO, audio_pkt);

if (frame == null) {
if (frame == null && retries++ > maxRetries) {
// avoid infinite loop with buggy codecs on flush
break;
}
Expand Down

0 comments on commit fce1be3

Please sign in to comment.