From b76367390330957119bfc2cabc3eb126bf56a000 Mon Sep 17 00:00:00 2001 From: kimvde Date: Tue, 11 Jun 2024 08:18:37 -0700 Subject: [PATCH] Increase sleep duration when video encoder ends with no output frames This duration was not sufficient on a Pixel 3a PiperOrigin-RevId: 642276212 --- .../java/androidx/media3/transformer/DefaultCodec.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultCodec.java b/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultCodec.java index e10a06cf14..558b49660d 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultCodec.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultCodec.java @@ -254,12 +254,12 @@ public final class DefaultCodec implements Codec { @Override public void signalEndOfInputStream() throws ExportException { if (!videoOutputStarted.get()) { - // When encoding a 1-frame video, there is a synchronization problem between feeding the frame - // to the encoder input surface and signaling end of stream. On some devices, sometimes, - // the frame gets lost and an empty output is produced. Waiting before signaling end of stream - // seems to resolve this issue. See b/301603935. + // When encoding a video with a small number of frames, there is a synchronization problem + // between feeding the frame to the encoder input surface and signaling end of stream. On some + // devices, sometimes, the frame gets lost and an empty output is produced. Waiting before + // signaling end of stream seems to resolve this issue. See b/301603935. try { - Thread.sleep(10); + Thread.sleep(30); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }