Skip to content

Commit

Permalink
Merge pull request kokorin#358 from marklassau/issue-357-detect-ffmpe…
Browse files Browse the repository at this point in the history
…g-muxing-bug

Issue 357: Detect ffmpeg bug and ignore test that can't pass
  • Loading branch information
kokorin authored Sep 8, 2023
2 parents 42febbe + 0ab09b3 commit 5cb4b57
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/test/java/com/github/kokorin/jaffree/ffmpeg/FFmpegTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hamcrest.core.AllOf;
import org.hamcrest.core.StringContains;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -379,16 +380,31 @@ public void testSizeLimit() throws Exception {
Path tempDir = Files.createTempDirectory("jaffree");
Path outputPath = tempDir.resolve(Artifacts.VIDEO_MP4.getFileName());

FFmpegResult result = FFmpeg.atPath(Config.FFMPEG_BIN)
.addInput(UrlInput.fromPath(Artifacts.VIDEO_MP4))
.addOutput(UrlOutput
.toPath(outputPath)
.copyAllCodecs()
.setSizeLimit(1_000_000L)
)
.execute();
final AtomicBoolean muxingErrorDetected = new AtomicBoolean(false);
OutputListener outputListener = message -> {
if (message.endsWith("Error muxing a packet")) {
LOGGER.warn("Detected a muxing error, which indicates ffmpeg bug #10327");
muxingErrorDetected.set(true);
}
};

Assert.assertNotNull(result);
try {
FFmpegResult result = FFmpeg.atPath(Config.FFMPEG_BIN)
.addInput(UrlInput.fromPath(Artifacts.VIDEO_MP4))
.setOutputListener(outputListener)
.addOutput(UrlOutput
.toPath(outputPath)
.copyAllCodecs()
.setSizeLimit(1_000_000L)
)
.execute();
Assert.assertNotNull(result);
} catch (JaffreeAbnormalExitException ex) {
// Detect ffmpeg bug "Error muxing a packet when limit file size parameter is set"
// https://trac.ffmpeg.org/ticket/10327
Assume.assumeFalse("Hit ffmpeg bug #10327 - we will ignore this test", muxingErrorDetected.get());
Assert.fail("Abnormal exit for limit file size");
}

long outputSize = Files.size(outputPath);
assertTrue(outputSize > 900_000);
Expand Down

0 comments on commit 5cb4b57

Please sign in to comment.