From 80ac60f8e965bab9c544479d11f24a44b93a00e6 Mon Sep 17 00:00:00 2001 From: Raya <100813231+rayacode@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:36:51 +0330 Subject: [PATCH 1/3] Create TuneEnum.java Tune enum for h264 --- .../ws/schild/jave/encode/enums/TuneEnum.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 jave-core/src/main/java/ws/schild/jave/encode/enums/TuneEnum.java diff --git a/jave-core/src/main/java/ws/schild/jave/encode/enums/TuneEnum.java b/jave-core/src/main/java/ws/schild/jave/encode/enums/TuneEnum.java new file mode 100644 index 0000000..b5dc826 --- /dev/null +++ b/jave-core/src/main/java/ws/schild/jave/encode/enums/TuneEnum.java @@ -0,0 +1,20 @@ +public enum TuneEnum { + FILM("film"),//use for high quality movie content; lowers deblocking + ANIMATION("animation"),//good for cartoons; uses higher deblocking and more reference frames + GRAIN("grain"),//preserves the grain structure in old, grainy film material + STILLIMAGE("stillimage"),//good for slideshow-like content + FASTDECODE("fastdecode"),//allows faster decoding by disabling certain filters + ZEROLATENCY("zerolatency"),//good for fast encoding and low-latency streaming + PSNR("psnr"),//ignore this as it is only used for codec development + SSIM("ssim");//ignore this as it is only used for codec development + + private final String tuneName; + + TuneEnum(String tuneName) { + this.tuneName = tuneName; + } + + public String getTuneName() { + return tuneName; + } +} From c648ea51f2821493b705840d8f76c027df5986b4 Mon Sep 17 00:00:00 2001 From: Raya <100813231+rayacode@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:44:44 +0330 Subject: [PATCH 2/3] Update VideoAttributes.java setting up tune in video attributes --- .../ws/schild/jave/encode/VideoAttributes.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jave-core/src/main/java/ws/schild/jave/encode/VideoAttributes.java b/jave-core/src/main/java/ws/schild/jave/encode/VideoAttributes.java index c504f0a..a1f1711 100644 --- a/jave-core/src/main/java/ws/schild/jave/encode/VideoAttributes.java +++ b/jave-core/src/main/java/ws/schild/jave/encode/VideoAttributes.java @@ -47,6 +47,7 @@ public class VideoAttributes implements Serializable { * direct stream copy. */ private String codec = null; + /** The the forced tag/fourcc value for the video stream. */ private String tag = null; /** @@ -89,7 +90,9 @@ public class VideoAttributes implements Serializable { * The downside is that it is less compatible with other applications. */ private boolean faststart = false; - + + private TuneEnum tune = null; + private X264_PROFILE x264Profile = null; /** @@ -299,7 +302,18 @@ public String toString() { + quality + ")"; } - + /** @return the Tune value */ + public Optional getTune() { + return Optional.ofNullable(tune); + } + /** + * @param TuneEnum the TuneEnum to set + * @return this instance + */ + public VideoAttributes setTune(TuneEnum tune){ + this.tune = tune; + return this; + } /** @return the x264Profile */ public Optional getX264Profile() { return Optional.ofNullable(x264Profile); From 70eb717ec796bb01c65047e9b6373af71fe526ae Mon Sep 17 00:00:00 2001 From: Raya <100813231+rayacode@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:46:29 +0330 Subject: [PATCH 3/3] Update Encoder.java updating list for tune --- jave-core/src/main/java/ws/schild/jave/Encoder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jave-core/src/main/java/ws/schild/jave/Encoder.java b/jave-core/src/main/java/ws/schild/jave/Encoder.java index ce626ab..0aad733 100644 --- a/jave-core/src/main/java/ws/schild/jave/Encoder.java +++ b/jave-core/src/main/java/ws/schild/jave/Encoder.java @@ -439,7 +439,9 @@ public void encode( new ValueArgument(ArgType.OUTFILE, "-crf", ea -> ea.getVideoAttributes().flatMap(VideoAttributes::getCrf).map(Object::toString)), new ValueArgument(ArgType.OUTFILE, "-preset", - ea -> ea.getVideoAttributes().flatMap(VideoAttributes::getPreset)) + ea -> ea.getVideoAttributes().flatMap(VideoAttributes::getPreset)), + new ValueArgument(ArgType.OUTFILE, "-tune", + ea -> ea.getVideoAttributes().flatMap(VideoAttributes::getTune).map(TuneEnum::getTuneName)) ) );