Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add loopAttribute to EncodingAttributes #79

Merged
merged 2 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions jave-core/src/main/java/ws/schild/jave/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ public void encode(List<MultimediaObject> multimediaObjects, File target, Encodi
String formatAttribute = attributes.getFormat();
Float offsetAttribute = attributes.getOffset();
Float durationAttribute = attributes.getDuration();
boolean loopAttribute = attributes.getLoop();
AudioAttributes audioAttributes = attributes.getAudioAttributes();
VideoAttributes videoAttributes = attributes.getVideoAttributes();
if (audioAttributes == null && videoAttributes == null)
Expand Down Expand Up @@ -457,6 +458,12 @@ public void encode(List<MultimediaObject> multimediaObjects, File target, Encodi
ffmpeg.addArgument("-threads");
ffmpeg.addArgument(Integer.toString(attributes.getDecodingThreads()));
}
if (loopAttribute && durationAttribute != null)
{
ffmpeg.addArgument("-loop");
ffmpeg.addArgument("1");
}

ffmpeg.addArgument("-i");
if (multimediaObjects.size() == 1)
{
Expand Down
27 changes: 25 additions & 2 deletions jave-core/src/main/java/ws/schild/jave/EncodingAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public class EncodingAttributes implements Serializable {
*/
private int encodingThreads= -1;


/**
* Should the input be treated as a loop
*/
private boolean loop = false;

/**
* Returns the format name for the encoded target multimedia file.
*
Expand Down Expand Up @@ -146,6 +150,25 @@ public EncodingAttributes setDuration(Float duration) {
return this;
}

/*
* Returns if the input is to be considered for looping.
* @return if the input will be looped.
*/
public boolean getLoop() {
return loop;
}

/**
* Sets if the inputs will be looped or not.
*
* @param loop if the input should be looped.
* @return this instance
*/
public EncodingAttributes setLoop(boolean loop) {
this.loop = loop;
return this;
}

/**
* Returns the attributes for the encoding of the audio stream in the target
* multimedia file.
Expand Down Expand Up @@ -199,7 +222,7 @@ public EncodingAttributes setVideoAttributes(VideoAttributes videoAttributes) {
@Override
public String toString() {
return getClass().getName() + "(format=" + format + ", offset="
+ offset + ", duration=" + duration + ", audioAttributes="
+ offset + ", duration=" + duration + ",loop=" + loop + ", audioAttributes="
+ audioAttributes + ", videoAttributes=" + videoAttributes
+ ")";
}
Expand Down