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

rotate parameter add #275

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 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 @@ -635,7 +635,13 @@ public void encode(
if (!SUCCESS_PATTERN.matcher(lastWarning).matches()) {
throw new EncoderException("No match for: " + SUCCESS_PATTERN + " in " + lastWarning);
}
}else {
if (listener != null) {
listener.done();
}

}

/*
* TODO: This is not thread safe. This needs to be a resulting value from the call to the
* Encoder. We can create a separate EncoderResult, but not a stateful variable.
Expand Down
7 changes: 7 additions & 0 deletions jave-core/src/main/java/ws/schild/jave/MultimediaObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,16 @@ private MultimediaInfo parseMultimediaInfo(String source, RBufferedReader reader
}
break;
}

case 2:
{
Matcher m = p3.matcher(line);
//视频方向***************
if (line.contains("rotate")) {
String[] r = line.split(":");
// Stay on level 2
info.setRotate(Integer.parseInt(r[1].trim()));
}
if (m.matches()) {
String type = m.group(1);
String specs = m.group(2);
Expand Down
295 changes: 158 additions & 137 deletions jave-core/src/main/java/ws/schild/jave/info/MultimediaInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,141 +27,162 @@
* @author Carlo Pelliccia
*/
public class MultimediaInfo {

/** The multimedia file format name. */
private String format = null;

/** The multimedia metadata. */
private Map<String, String> metadata = new HashMap<>();

/** The stream duration in millis. If less than 0 this information is not available. */
private long duration = -1;

/**
* A set of audio-specific informations. If null, there's no audio stream in the multimedia file.
*/
private AudioInfo audio = null;

/**
* A set of video-specific informations. If null, there's no video stream in the multimedia file.
*/
private VideoInfo video = null;

/**
* Returns the multimedia file format name.
*
* @return The multimedia file format name.
*/
public String getFormat() {
return format;
}

/**
* Sets the multimedia file format name.
*
* @param format The multimedia file format name.
* @return this instance
*/
public MultimediaInfo setFormat(String format) {
this.format = format;
return this;
}

/**
* Returns the multimedia metadata.
*
* @return The multimedia metadata.
*/
public Map<String, String> getMetadata() {
return metadata;
}

/**
* Sets the multimedia metadata.
*
* @param metadata The multimedia metadata.
* @return this instance
*/
public MultimediaInfo setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}

/**
* Returns the stream duration in millis. If less than 0 this information is not available.
*
* @return The stream duration in millis. If less than 0 this information is not available.
*/
public long getDuration() {
return duration;
}

/**
* Sets the stream duration in millis.
*
* @param duration The stream duration in millis.
* @return this instance
*/
public MultimediaInfo setDuration(long duration) {
this.duration = duration;
return this;
}

/**
* Returns a set of audio-specific informations. If null, there's no audio stream in the
* multimedia file.
*
* @return A set of audio-specific informations.
*/
public AudioInfo getAudio() {
return audio;
}

/**
* Sets a set of audio-specific informations.
*
* @param audio A set of audio-specific informations.
* @return this instance
*/
public MultimediaInfo setAudio(AudioInfo audio) {
this.audio = audio;
return this;
}

/**
* Returns a set of video-specific informations. If null, there's no video stream in the
* multimedia file.
*
* @return A set of audio-specific informations.
*/
public VideoInfo getVideo() {
return video;
}

/**
* Sets a set of video-specific informations.
*
* @param video A set of video-specific informations.
* @return this instance
*/
public MultimediaInfo setVideo(VideoInfo video) {
this.video = video;
return this;
}

@Override
public String toString() {
return getClass().getName()
+ " (format="
+ format
+ " (metadata="
+ metadata
+ ", duration="
+ duration
+ ", video="
+ video
+ ", audio="
+ audio
+ ")";
}
/**
* 视频方向
*/
private int rotate;

/**
* The multimedia file format name.
*/
private String format = null;

/**
* The multimedia metadata.
*/
private Map<String, String> metadata = new HashMap<>();

/**
* The stream duration in millis. If less than 0 this information is not available.
*/
private long duration = -1;

/**
* A set of audio-specific informations. If null, there's no audio stream in the multimedia file.
*/
private AudioInfo audio = null;

/**
* A set of video-specific informations. If null, there's no video stream in the multimedia file.
*/
private VideoInfo video = null;

/**
* Returns the multimedia file format name.
*
* @return The multimedia file format name.
*/
public String getFormat() {
return format;
}

/**
* Sets the multimedia file format name.
*
* @param format The multimedia file format name.
* @return this instance
*/
public MultimediaInfo setFormat(String format) {
this.format = format;
return this;
}

/**
* Returns the multimedia metadata.
*
* @return The multimedia metadata.
*/
public Map<String, String> getMetadata() {
return metadata;
}

/**
* Sets the multimedia metadata.
*
* @param metadata The multimedia metadata.
* @return this instance
*/
public MultimediaInfo setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}

/**
* Returns the stream duration in millis. If less than 0 this information is not available.
*
* @return The stream duration in millis. If less than 0 this information is not available.
*/
public long getDuration() {
return duration;
}

/**
* Sets the stream duration in millis.
*
* @param duration The stream duration in millis.
* @return this instance
*/
public MultimediaInfo setDuration(long duration) {
this.duration = duration;
return this;
}

/**
* Returns a set of audio-specific informations. If null, there's no audio stream in the
* multimedia file.
*
* @return A set of audio-specific informations.
*/
public AudioInfo getAudio() {
return audio;
}

/**
* Sets a set of audio-specific informations.
*
* @param audio A set of audio-specific informations.
* @return this instance
*/
public MultimediaInfo setAudio(AudioInfo audio) {
this.audio = audio;
return this;
}

/**
* Returns a set of video-specific informations. If null, there's no video stream in the
* multimedia file.
*
* @return A set of audio-specific informations.
*/
public VideoInfo getVideo() {
return video;
}

/**
* Sets a set of video-specific informations.
*
* @param video A set of video-specific informations.
* @return this instance
*/
public MultimediaInfo setVideo(VideoInfo video) {
this.video = video;
return this;
}

public int getRotate() {
return rotate;
}

public void setRotate(int rotate) {
this.rotate = rotate;
}

@Override
public String toString() {
return getClass().getName()
+ "rotate="
+ rotate
+ " (format="
+ format
+ " (metadata="
+ metadata
+ ", duration="
+ duration
+ ", video="
+ video
+ ", audio="
+ audio

+ ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public interface EncoderProgressListener {
*/
public void progress(int permil);

public void done();

/**
* This method is called every time the encoder need to send a message (usually, a warning).
*
Expand Down