From 5133c564ccefa46501678a51abfa65fceb9660fb Mon Sep 17 00:00:00 2001 From: Joel Widmer Date: Sat, 10 Aug 2024 01:48:24 +0200 Subject: [PATCH 1/4] chore: Update fixture --- .../java/net/bramp/ffmpeg/FFprobeTest.java | 6 ++-- .../ffprobe-big_buck_bunny_720p_1mb.mp4 | 36 +++++++++++++++---- .../fixtures/ffprobe-disposition_all_true | 1 + 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java index 4ef49d4a..d1f6aff0 100644 --- a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java @@ -547,7 +547,7 @@ public void testFullVideoStreamDeserialization() throws IOException { assertEquals(31, stream.getLevel()); assertEquals("left", stream.getChromaLocation()); assertEquals(1, stream.getRefs()); - assertEquals("1", stream.getIsAvc()); + assertEquals("true", stream.getIsAvc()); assertEquals("4", stream.getNalLengthSize()); assertEquals(Fraction.getFraction(25, 1), stream.getRFrameRate()); assertEquals(Fraction.getFraction(25, 1), stream.getAvgFrameRate()); @@ -565,7 +565,7 @@ public void testFullVideoStreamDeserialization() throws IOException { assertEquals(0, stream.getSampleRate()); assertEquals(0, stream.getChannels()); assertNull(stream.getChannelLayout()); - assertEquals(3, stream.getTags().size()); + assertEquals(4, stream.getTags().size()); assertEquals("und", stream.getTags().get("language")); assertEquals(0, stream.getSideDataList().size()); } @@ -610,7 +610,7 @@ public void testFullAudioStreamDeserialization() throws IOException { assertEquals(48000, stream.getSampleRate()); assertEquals(6, stream.getChannels()); assertEquals("5.1", stream.getChannelLayout()); - assertEquals(3, stream.getTags().size()); + assertEquals(4, stream.getTags().size()); assertEquals("und", stream.getTags().get("language")); assertEquals(0, stream.getSideDataList().size()); } diff --git a/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-big_buck_bunny_720p_1mb.mp4 b/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-big_buck_bunny_720p_1mb.mp4 index 79380adc..0c9c75c2 100644 --- a/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-big_buck_bunny_720p_1mb.mp4 +++ b/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-big_buck_bunny_720p_1mb.mp4 @@ -13,15 +13,19 @@ "height": 720, "coded_width": 1280, "coded_height": 720, + "closed_captions": 0, + "film_grain": 0, "has_b_frames": 0, "sample_aspect_ratio": "1:1", "display_aspect_ratio": "16:9", "pix_fmt": "yuv420p", "level": 31, "chroma_location": "left", + "field_order": "progressive", "refs": 1, - "is_avc": "1", + "is_avc": "true", "nal_length_size": "4", + "id": "0x1", "r_frame_rate": "25/1", "avg_frame_rate": "25/1", "time_base": "1/12800", @@ -32,6 +36,7 @@ "bit_rate": "1205959", "bits_per_raw_sample": "8", "nb_frames": "132", + "extradata_size": 38, "disposition": { "default": 1, "dub": 0, @@ -43,12 +48,20 @@ "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, - "attached_pic": 0 + "attached_pic": 0, + "timed_thumbnails": 0, + "non_diegetic": 0, + "captions": 0, + "descriptions": 0, + "metadata": 0, + "dependent": 0, + "still_image": 0 }, "tags": { "creation_time": "1970-01-01 00:00:00", "language": "und", - "handler_name": "VideoHandler" + "handler_name": "VideoHandler", + "vendor_id": "[0][0][0][0]" } }, { @@ -65,6 +78,8 @@ "channels": 6, "channel_layout": "5.1", "bits_per_sample": 0, + "initial_padding": 0, + "id": "0x2", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/48000", @@ -75,6 +90,7 @@ "bit_rate": "384828", "max_bit_rate": "400392", "nb_frames": "249", + "extradata_size": 2, "disposition": { "default": 1, "dub": 0, @@ -86,12 +102,20 @@ "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, - "attached_pic": 0 + "attached_pic": 0, + "timed_thumbnails": 0, + "non_diegetic": 0, + "captions": 0, + "descriptions": 0, + "metadata": 0, + "dependent": 0, + "still_image": 0 }, "tags": { - "creation_time": "1970-01-01 00:00:00", + "creation_time": "1970-01-01T00:00:00.000000Z", "language": "und", - "handler_name": "SoundHandler" + "handler_name": "SoundHandler", + "vendor_id": "[0][0][0][0]" } } ], diff --git a/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-disposition_all_true b/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-disposition_all_true index b090d66d..e15ba102 100644 --- a/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-disposition_all_true +++ b/src/test/resources/net/bramp/ffmpeg/fixtures/ffprobe-disposition_all_true @@ -51,6 +51,7 @@ "clean_effects": 1, "attached_pic": 1, "timed_thumbnails": 1, + "non_diegetic": 1, "captions": 1, "descriptions": 1, "metadata": 1, From ffbfc2db23b4fcab08b190f26e1b46158d5cb7c7 Mon Sep 17 00:00:00 2001 From: Joel Widmer Date: Sat, 10 Aug 2024 01:48:46 +0200 Subject: [PATCH 2/4] feat: Add missing fields to disposition --- .../bramp/ffmpeg/probe/FFmpegDisposition.java | 28 +++++++++++++++++++ .../java/net/bramp/ffmpeg/FFprobeTest.java | 4 +++ 2 files changed, 32 insertions(+) diff --git a/src/main/java/net/bramp/ffmpeg/probe/FFmpegDisposition.java b/src/main/java/net/bramp/ffmpeg/probe/FFmpegDisposition.java index 887b279b..ad961513 100644 --- a/src/main/java/net/bramp/ffmpeg/probe/FFmpegDisposition.java +++ b/src/main/java/net/bramp/ffmpeg/probe/FFmpegDisposition.java @@ -44,6 +44,12 @@ public class FFmpegDisposition { @JsonAdapter(BooleanTypeAdapter.class) public boolean attached_pic; + @JsonAdapter(BooleanTypeAdapter.class) + public boolean timed_thumbnails; + + @JsonAdapter(BooleanTypeAdapter.class) + public boolean non_diegetic; + @JsonAdapter(BooleanTypeAdapter.class) public boolean captions; @@ -53,6 +59,12 @@ public class FFmpegDisposition { @JsonAdapter(BooleanTypeAdapter.class) public boolean metadata; + @JsonAdapter(BooleanTypeAdapter.class) + public boolean dependent; + + @JsonAdapter(BooleanTypeAdapter.class) + public boolean still_image; + public boolean isDefault() { return _default; } @@ -97,6 +109,14 @@ public boolean isAttachedPic() { return attached_pic; } + public boolean isTimedThumbnails() { + return timed_thumbnails; + } + + public boolean isNonDiegetic() { + return non_diegetic; + } + public boolean isCaptions() { return captions; } @@ -108,4 +128,12 @@ public boolean isDescriptions() { public boolean isMetadata() { return metadata; } + + public boolean isDependent() { + return dependent; + } + + public boolean isStillImage() { + return still_image; + } } diff --git a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java index d1f6aff0..d9851257 100644 --- a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java @@ -663,9 +663,13 @@ public void testDispositionWithAllFieldsTrueDeserialization() throws IOException assertTrue(disposition.isVisualImpaired()); assertTrue(disposition.isCleanEffects()); assertTrue(disposition.isAttachedPic()); + assertTrue(disposition.isTimedThumbnails()); + assertTrue(disposition.isNonDiegetic()); assertTrue(disposition.isCaptions()); assertTrue(disposition.isDescriptions()); assertTrue(disposition.isMetadata()); + assertTrue(disposition.isDependent()); + assertTrue(disposition.isStillImage()); } @Test From 6f2e85c727bd7b503fdf3ba7b5507d23ef238ee9 Mon Sep 17 00:00:00 2001 From: Joel Widmer Date: Sat, 10 Aug 2024 01:49:12 +0200 Subject: [PATCH 3/4] feat: Add missing id field to FFmpegStream fixes #273 --- src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java | 5 +++++ src/test/java/net/bramp/ffmpeg/FFprobeTest.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java index 4cea7bcb..32099f8a 100644 --- a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java +++ b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java @@ -39,6 +39,7 @@ public class FFmpegStream { public int refs; public String is_avc; public String nal_length_size; + public String id; public Fraction r_frame_rate; public Fraction avg_frame_rate; public Fraction time_base; @@ -145,6 +146,10 @@ public String getNalLengthSize() { return nal_length_size; } + public String getId() { + return id; + } + public Fraction getRFrameRate() { return r_frame_rate; } diff --git a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java index d9851257..d211dfea 100644 --- a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java @@ -549,6 +549,7 @@ public void testFullVideoStreamDeserialization() throws IOException { assertEquals(1, stream.getRefs()); assertEquals("true", stream.getIsAvc()); assertEquals("4", stream.getNalLengthSize()); + assertEquals("0x1", stream.getId()); assertEquals(Fraction.getFraction(25, 1), stream.getRFrameRate()); assertEquals(Fraction.getFraction(25, 1), stream.getAvgFrameRate()); assertEquals(Fraction.getFraction(1, 12800), stream.getTimeBase()); @@ -594,6 +595,7 @@ public void testFullAudioStreamDeserialization() throws IOException { assertEquals(0, stream.getRefs()); assertNull(stream.getIsAvc()); assertNull(stream.getNalLengthSize()); + assertEquals("0x2", stream.getId()); assertEquals(Fraction.getFraction(0, 1), stream.getRFrameRate()); assertEquals(Fraction.getFraction(0, 1), stream.getAvgFrameRate()); assertEquals(Fraction.getFraction(1, 48_000), stream.getTimeBase()); From 1df2543c6485e7832c33a1001b36ce336b134707 Mon Sep 17 00:00:00 2001 From: Joel Widmer Date: Sat, 10 Aug 2024 01:55:54 +0200 Subject: [PATCH 4/4] chore: Add Serializable to FFmpegError --- src/main/java/net/bramp/ffmpeg/FFmpegException.java | 2 +- src/main/java/net/bramp/ffmpeg/probe/FFmpegError.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/bramp/ffmpeg/FFmpegException.java b/src/main/java/net/bramp/ffmpeg/FFmpegException.java index a6b5cb36..d00dc011 100644 --- a/src/main/java/net/bramp/ffmpeg/FFmpegException.java +++ b/src/main/java/net/bramp/ffmpeg/FFmpegException.java @@ -7,7 +7,7 @@ public class FFmpegException extends IOException { private static final long serialVersionUID = 3048288225568984942L; - private FFmpegError error; + private final FFmpegError error; public FFmpegException(String message, FFmpegError error) { super(message); diff --git a/src/main/java/net/bramp/ffmpeg/probe/FFmpegError.java b/src/main/java/net/bramp/ffmpeg/probe/FFmpegError.java index 13b49c99..da9634f7 100644 --- a/src/main/java/net/bramp/ffmpeg/probe/FFmpegError.java +++ b/src/main/java/net/bramp/ffmpeg/probe/FFmpegError.java @@ -2,10 +2,14 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.io.Serializable; + @SuppressFBWarnings( value = {"UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"}, justification = "POJO objects where the fields are populated by gson") -public class FFmpegError { +public class FFmpegError implements Serializable { + private static final long serialVersionUID = 1L; + public int code; public String string;