Skip to content

Commit

Permalink
Merge pull request #262 from rayacode/master
Browse files Browse the repository at this point in the history
Adding Tune video attribute
  • Loading branch information
a-schild authored Feb 15, 2024
2 parents 5a2a6e3 + 70eb717 commit c1144ef
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
4 changes: 3 additions & 1 deletion jave-core/src/main/java/ws/schild/jave/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)
);

Expand Down
18 changes: 16 additions & 2 deletions jave-core/src/main/java/ws/schild/jave/encode/VideoAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down Expand Up @@ -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;

/**
Expand Down Expand Up @@ -299,7 +302,18 @@ public String toString() {
+ quality
+ ")";
}

/** @return the Tune value */
public Optional<TuneEnum> 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<X264_PROFILE> getX264Profile() {
return Optional.ofNullable(x264Profile);
Expand Down
20 changes: 20 additions & 0 deletions jave-core/src/main/java/ws/schild/jave/encode/enums/TuneEnum.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit c1144ef

Please sign in to comment.