From 1b7075d94a506989c180d84fb6e6316d5054a591 Mon Sep 17 00:00:00 2001 From: angel_hu Date: Fri, 10 Jan 2025 14:27:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=AE=8C=E6=88=90=20=E7=9B=91=E5=90=AC=20done=20=20=20?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=96=B9=E5=90=91=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ws/schild/jave/Encoder.java | 6 + .../ws/schild/jave/info/MultimediaInfo.java | 295 ++++++++++-------- .../progress/EncoderProgressListener.java | 2 + 3 files changed, 166 insertions(+), 137 deletions(-) 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 825e12f..04ee440 100644 --- a/jave-core/src/main/java/ws/schild/jave/Encoder.java +++ b/jave-core/src/main/java/ws/schild/jave/Encoder.java @@ -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. diff --git a/jave-core/src/main/java/ws/schild/jave/info/MultimediaInfo.java b/jave-core/src/main/java/ws/schild/jave/info/MultimediaInfo.java index 49a028c..cbb6f87 100644 --- a/jave-core/src/main/java/ws/schild/jave/info/MultimediaInfo.java +++ b/jave-core/src/main/java/ws/schild/jave/info/MultimediaInfo.java @@ -27,141 +27,162 @@ * @author Carlo Pelliccia */ public class MultimediaInfo { - - /** The multimedia file format name. */ - private String format = null; - - /** The multimedia metadata. */ - private Map 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 getMetadata() { - return metadata; - } - - /** - * Sets the multimedia metadata. - * - * @param metadata The multimedia metadata. - * @return this instance - */ - public MultimediaInfo setMetadata(Map 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 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 getMetadata() { + return metadata; + } + + /** + * Sets the multimedia metadata. + * + * @param metadata The multimedia metadata. + * @return this instance + */ + public MultimediaInfo setMetadata(Map 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 + + + ")"; + } } diff --git a/jave-core/src/main/java/ws/schild/jave/progress/EncoderProgressListener.java b/jave-core/src/main/java/ws/schild/jave/progress/EncoderProgressListener.java index 24e2bb7..fe61a21 100644 --- a/jave-core/src/main/java/ws/schild/jave/progress/EncoderProgressListener.java +++ b/jave-core/src/main/java/ws/schild/jave/progress/EncoderProgressListener.java @@ -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). * From ce05de56fe35d23d1bf90ada7adb37335949265f Mon Sep 17 00:00:00 2001 From: angel_hu Date: Fri, 10 Jan 2025 14:34:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=AE=8C=E6=88=90=20=E7=9B=91=E5=90=AC=20done=20=20=20?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=96=B9=E5=90=91=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ws/schild/jave/MultimediaObject.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java b/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java index c4ad454..b39024b 100644 --- a/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java +++ b/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java @@ -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);