diff --git a/README.md b/README.md index e322a328..08402a2f 100644 --- a/README.md +++ b/README.md @@ -78,16 +78,16 @@ FFmpegProbeResult probeResult = ffprobe.probe("input.mp4"); FFmpegFormat format = probeResult.getFormat(); System.out.format("%nFile: '%s' ; Format: '%s' ; Duration: %.3fs", - format.getFilename(), - format.getFormatLongName(), - format.getDuration() + format.filename, + format.format_long_name, + format.duration ); FFmpegStream stream = probeResult.getStreams().get(0); System.out.format("%nCodec: '%s' ; Width: %dpx ; Height: %dpx", - stream.getCodecLongName(), - stream.getWidth(), - stream.getHeigth() + stream.codec_long_name, + stream.width, + stream.height ); ``` @@ -106,21 +106,21 @@ FFmpegBuilder builder = new FFmpegBuilder() FFmpegJob job = executor.createJob(builder, new ProgressListener() { // Using the FFmpegProbeResult determine the duration of the input - final double duration_ns = in.getFormat().getDuration() * TimeUnit.SECONDS.toNanos(1); + final double duration_ns = in.getFormat().duration * TimeUnit.SECONDS.toNanos(1); @Override public void progress(Progress progress) { - double percentage = progress.getOutTimeNs() / duration_ns; + double percentage = progress.out_time_ns / duration_ns; // Print out interesting information about the progress System.out.println(String.format( "[%.0f%%] status:%s frame:%d time:%s ms fps:%.0f speed:%.2fx", percentage * 100, - progress.getStatus(), - progress.getFrame(), - FFmpegUtils.toTimecode(progress.getOutTimeNs(), TimeUnit.NANOSECONDS), - progress.getFps().doubleValue(), - progress.getSpeed() + progress.status, + progress.frame, + FFmpegUtils.toTimecode(progress.out_time_ns, TimeUnit.NANOSECONDS), + progress.fps.doubleValue(), + progress.speed )); } }); diff --git a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java index 6dfcbe28..a2785837 100644 --- a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java +++ b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java @@ -14,131 +14,58 @@ value = {"UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"}, justification = "POJO objects where the fields are populated by gson") public class FFmpegStream { - /** @deprecated Use {@link #getIndex()} instead */ - @Deprecated public int index; - /** @deprecated Use {@link #getCodecName()} instead */ - @Deprecated public String codec_name; - /** @deprecated Use {@link #getCodecLongName()} instead */ - @Deprecated public String codec_long_name; - /** @deprecated Use {@link #getProfile()} instead */ - @Deprecated public String profile; - /** @deprecated Use {@link #getCodecType()} instead */ - @Deprecated public CodecType codec_type; - /** @deprecated Use {@link #getCodecTimeBase()} instead */ - @Deprecated public Fraction codec_time_base; - /** @deprecated Use {@link #getCodecTagString()} instead */ - @Deprecated public String codec_tag_string; - /** @deprecated Use {@link #getCodecTag()} instead */ - @Deprecated public String codec_tag; - /** @deprecated Use {@link #getWidth()} instead */ - @Deprecated public int width; - /** @deprecated Use {@link #getHeight()} instead */ - @Deprecated public int height; - /** @deprecated Use {@link #getHasBFrames()} instead */ - @Deprecated public int has_b_frames; - /** @deprecated Use {@link #getSampleAspectRatio()} instead */ - @Deprecated public String sample_aspect_ratio; // TODO Change to a Ratio/Fraction object - /** @deprecated Use {@link #getDisplayAspectRatio()} instead */ - @Deprecated public String display_aspect_ratio; - /** @deprecated Use {@link #getPixFmt()} instead */ - @Deprecated public String pix_fmt; - /** @deprecated Use {@link #getLevel()} instead */ - @Deprecated public int level; - /** @deprecated Use {@link #getChromaLocation()} instead */ - @Deprecated public String chroma_location; - /** @deprecated Use {@link #getRefs()} instead */ - @Deprecated public int refs; - /** @deprecated Use {@link #getIsAvc()} instead */ - @Deprecated public String is_avc; - /** @deprecated Use {@link #getNalLengthSize()} instead */ - @Deprecated public String nal_length_size; - /** @deprecated Use {@link #getRFrameRate()} instead */ - @Deprecated public Fraction r_frame_rate; - /** @deprecated Use {@link #getAvgFrameRate()} instead */ - @Deprecated public Fraction avg_frame_rate; - /** @deprecated Use {@link #getTimeBase()} instead */ - @Deprecated public Fraction time_base; - /** @deprecated Use {@link #getStartPts()} instead */ - @Deprecated public long start_pts; - /** @deprecated Use {@link #getStartTime()} instead */ - @Deprecated public double start_time; - /** @deprecated Use {@link #getDurationTs()} instead */ - @Deprecated public long duration_ts; - /** @deprecated Use {@link #getDuration()} instead */ - @Deprecated public double duration; - /** @deprecated Use {@link #getBitRate()} instead */ - @Deprecated public long bit_rate; - /** @deprecated Use {@link #getMaxBitRate()} instead */ - @Deprecated public long max_bit_rate; - /** @deprecated Use {@link #getBitsPerRawSample()} instead */ - @Deprecated public int bits_per_raw_sample; - /** @deprecated Use {@link #getBitsPerSample()} instead */ - @Deprecated public int bits_per_sample; - /** @deprecated Use {@link #getNbFrames()} instead */ - @Deprecated public long nb_frames; - /** @deprecated Use {@link #getSampleFmt()} instead */ - @Deprecated public String sample_fmt; - /** @deprecated Use {@link #getSampleRate()} instead */ - @Deprecated public int sample_rate; - /** @deprecated Use {@link #getChannels()} instead */ - @Deprecated public int channels; - /** @deprecated Use {@link #getChannelLayout()} instead */ - @Deprecated public String channel_layout; - /** @deprecated Use {@link #getDisposition()} instead */ - @Deprecated public FFmpegDisposition disposition; - /** @deprecated Use {@link #getTags()} instead */ - @Deprecated + // TODO: Make Map immutable public Map tags; - /** @deprecated Use {@link #getSideDataList()} instead */ - @Deprecated + + // TODO: Convert array to immutable List public SideData[] side_data_list; public int getIndex() { @@ -294,14 +221,8 @@ public List getSideDataList() { } public static class SideData { - /** @deprecated Use {@link #getSideDataType()} instead */ - @Deprecated public String side_data_type; - /** @deprecated Use {@link #getDisplaymatrix()} instead */ - @Deprecated public String displaymatrix; - /** @deprecated Use {@link #getRotation()} instead */ - @Deprecated public int rotation; public String getSideDataType() { diff --git a/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java b/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java index b08635f5..8b996283 100644 --- a/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java @@ -232,8 +232,8 @@ public void testProgress() throws InterruptedException, ExecutionException, IOEx // Since the results of ffmpeg are not predictable, test for the bare minimum. assertThat(progesses, hasSize(greaterThanOrEqualTo(2))); - assertThat(progesses.get(0).getStatus(), is(Progress.Status.CONTINUE)); - assertThat(progesses.get(progesses.size() - 1).getStatus(), is(Progress.Status.END)); + assertThat(progesses.get(0).status, is(Progress.Status.CONTINUE)); + assertThat(progesses.get(progesses.size() - 1).status, is(Progress.Status.END)); } @Test diff --git a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java index e4baf51f..c01ce529 100644 --- a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java @@ -93,11 +93,11 @@ public void testProbeVideo() throws IOException { // Only a quick sanity check until we do something better assertThat(info.getStreams(), hasSize(2)); - assertThat(info.getStreams().get(0).getCodecType(), is(CodecType.VIDEO)); - assertThat(info.getStreams().get(1).getCodecType(), is(CodecType.AUDIO)); + assertThat(info.getStreams().get(0).codec_type, is(CodecType.VIDEO)); + assertThat(info.getStreams().get(1).codec_type, is(CodecType.AUDIO)); - assertThat(info.getStreams().get(1).getChannels(), is(6)); - assertThat(info.getStreams().get(1).getSampleRate(), is(48_000)); + assertThat(info.getStreams().get(1).channels, is(6)); + assertThat(info.getStreams().get(1).sample_rate, is(48_000)); assertThat(info.getChapters().isEmpty(), is(true)); // System.out.println(FFmpegUtils.getGson().toJson(info)); @@ -110,20 +110,20 @@ public void testProbeBookWithChapters() throws IOException { assertThat(info.getChapters().size(), is(24)); FFmpegChapter firstChapter = info.getChapters().get(0); - assertThat(firstChapter.getTimeBase(), is("1/44100")); - assertThat(firstChapter.getStart(), is(0L)); - assertThat(firstChapter.getStartTime(), is("0.000000")); - assertThat(firstChapter.getEnd(), is(11951309L)); - assertThat(firstChapter.getEndTime(), is("271.004739")); - assertThat(firstChapter.getTags().getTitle(), is("01 - Sammy Jay Makes a Fuss")); + assertThat(firstChapter.time_base, is("1/44100")); + assertThat(firstChapter.start, is(0L)); + assertThat(firstChapter.start_time, is("0.000000")); + assertThat(firstChapter.end, is(11951309L)); + assertThat(firstChapter.end_time, is("271.004739")); + assertThat(firstChapter.getTags().title, is("01 - Sammy Jay Makes a Fuss")); FFmpegChapter lastChapter = info.getChapters().get(info.getChapters().size() - 1); - assertThat(lastChapter.getTimeBase(), is("1/44100")); - assertThat(lastChapter.getStart(), is(237875790L)); - assertThat(lastChapter.getStartTime(), is("5394.008844")); - assertThat(lastChapter.getEnd(), is(248628224L)); - assertThat(lastChapter.getEndTime(), is("5637.828209")); - assertThat(lastChapter.getTags().getTitle(), is("24 - Chatterer Has His Turn to Laugh")); + assertThat(lastChapter.time_base, is("1/44100")); + assertThat(lastChapter.start, is(237875790L)); + assertThat(lastChapter.start_time, is("5394.008844")); + assertThat(lastChapter.end, is(248628224L)); + assertThat(lastChapter.end_time, is("5637.828209")); + assertThat(lastChapter.getTags().title, is("24 - Chatterer Has His Turn to Laugh")); } @Test @@ -361,15 +361,15 @@ public void testProbeVideo2() throws IOException { // Only a quick sanity check until we do something better assertThat(info.getStreams(), hasSize(2)); - assertThat(info.getStreams().get(0).getCodecType(), is(CodecType.VIDEO)); - assertThat(info.getStreams().get(1).getCodecType(), is(CodecType.AUDIO)); + assertThat(info.getStreams().get(0).codec_type, is(CodecType.VIDEO)); + assertThat(info.getStreams().get(1).codec_type, is(CodecType.AUDIO)); - assertThat(info.getStreams().get(1).getChannels(), is(2)); - assertThat(info.getStreams().get(1).getSampleRate(), is(48_000)); + assertThat(info.getStreams().get(1).channels, is(2)); + assertThat(info.getStreams().get(1).sample_rate, is(48_000)); // Test a UTF-8 name assertThat( - info.getFormat().getFilename(), + info.getFormat().filename, is("c:\\Users\\Bob\\Always On My Mind [Program Only] - Adelén.mp4")); // System.out.println(FFmpegUtils.getGson().toJson(info)); @@ -381,7 +381,7 @@ public void testProbeStartPts() throws IOException { assertFalse(info.hasError()); // Check edge case with a time larger than an integer - assertThat(info.getStreams().get(0).getStartPts(), is(8570867078L)); + assertThat(info.getStreams().get(0).start_pts, is(8570867078L)); } @Test @@ -390,7 +390,7 @@ public void testProbeDivideByZero() throws IOException { FFmpegProbeResult info = ffprobe.probe(Samples.divide_by_zero); assertFalse(info.hasError()); - assertThat(info.getStreams().get(1).getCodecTimeBase(), is(Fraction.ZERO)); + assertThat(info.getStreams().get(1).codec_time_base, is(Fraction.ZERO)); // System.out.println(FFmpegUtils.getGson().toJson(info)); } @@ -401,20 +401,20 @@ public void testProbeSideDataList() throws IOException { // Check edge case with a time larger than an integer assertThat(info.getStreams().get(0).getSideDataList().size(), is(1)); - assertThat(info.getStreams().get(0).getSideDataList().get(0).getSideDataType(), is("Display Matrix")); + assertThat(info.getStreams().get(0).getSideDataList().get(0).side_data_type, is("Display Matrix")); assertThat( - info.getStreams().get(0).getSideDataList().get(0).getDisplaymatrix(), + info.getStreams().get(0).getSideDataList().get(0).displaymatrix, is( "\n00000000: 0 -65536 0\n00000001: 65536 0 0\n00000002: 0 0 1073741824\n")); - assertThat(info.getStreams().get(0).getSideDataList().get(0).getRotation(), is(90)); + assertThat(info.getStreams().get(0).getSideDataList().get(0).rotation, is(90)); } @Test public void testChaptersWithLongIds() throws IOException { FFmpegProbeResult info = ffprobe.probe(Samples.chapters_with_long_id); - assertThat(info.getChapters().get(0).getId(), is(6613449456311024506L)); - assertThat(info.getChapters().get(1).getId(), is(-4433436293284298339L)); + assertThat(info.getChapters().get(0).id, is(6613449456311024506L)); + assertThat(info.getChapters().get(1).id, is(-4433436293284298339L)); } @Test diff --git a/src/test/java/net/bramp/ffmpeg/ReadmeTest.java b/src/test/java/net/bramp/ffmpeg/ReadmeTest.java index 552cf81b..e2256a43 100644 --- a/src/test/java/net/bramp/ffmpeg/ReadmeTest.java +++ b/src/test/java/net/bramp/ffmpeg/ReadmeTest.java @@ -78,18 +78,18 @@ public void testGetMediaInformation() throws IOException { String.format( locale, "File: '%s' ; Format: '%s' ; Duration: %.3fs", - format.getFilename(), - format.getFormatLongName(), - format.getDuration()); + format.filename, + format.format_long_name, + format.duration); FFmpegStream stream = probeResult.getStreams().get(0); String line2 = String.format( locale, "Codec: '%s' ; Width: %dpx ; Height: %dpx", - stream.getCodecLongName(), - stream.getWidth(), - stream.getHeight()); + stream.codec_long_name, + stream.width, + stream.height); assertThat( line1, @@ -118,23 +118,23 @@ public void testProgress() throws IOException { new ProgressListener() { // Using the FFmpegProbeResult determine the duration of the input - final double duration_ns = in.getFormat().getDuration() * TimeUnit.SECONDS.toNanos(1); + final double duration_ns = in.getFormat().duration * TimeUnit.SECONDS.toNanos(1); @Override public void progress(Progress progress) { - double percentage = progress.getOutTimeNs() / duration_ns; + double percentage = progress.out_time_ns / duration_ns; // Print out interesting information about the progress System.out.println( String.format( locale, "[%.0f%%] status:%s frame:%d time:%s fps:%.0f speed:%.2fx", - percentage * 100, - progress.getStatus(), - progress.getFrame(), - FFmpegUtils.toTimecode(progress.getOutTimeNs(), TimeUnit.NANOSECONDS), - progress.getFps().doubleValue(), - progress.getSpeed())); + percentage * 100, + progress.status, + progress.frame, + FFmpegUtils.toTimecode(progress.out_time_ns, TimeUnit.NANOSECONDS), + progress.fps.doubleValue(), + progress.speed)); } });