Skip to content

Commit

Permalink
Added support for URL & media infos when the source is readable multi…
Browse files Browse the repository at this point in the history
…ple times

Release of 2.6.0
  • Loading branch information
a-schild committed Aug 6, 2019
1 parent 580895a commit 487012d
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 46 deletions.
4 changes: 3 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# JAVE2

## Changelog
- **2.6.0-SNAPSHOT**
- **2.6.0**
- Prepare for next dev cycle
- Change of logging api to slf4j as logging facade in version 1.7.x
- The encode methods now accept a List<> of MultimediaObject's, which are the concatenated
- Implemented set thread cound for encoding / decoding stages (Max number of cores/cpus to use)
- URL's as source are now treated as "multiple time readables" per default, can be overriden in the MultimediaObject
- Progress listener now works for URL's too, unless the "multiple time readables" flag is set to true
- **2.5.1**
- Renamed native folder where the executables are to nativebin too, to prevent Java 9+ problems
- Allow to create a MultimediaObject with an URL instead of a file as conversion source
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ It includes all binaries for the supported platforms
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-all-deps</artifactId>
<version>2.5.1</version>
<version>2.6.0</version>
</dependency>
```

Expand All @@ -59,7 +59,7 @@ Generally if you want to use for one platform or more what you have to do is add
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.5.1</version>
<version>2.6.0</version>
</dependency>
```

Expand All @@ -70,7 +70,7 @@ and then the specific jar(s) for your platform(s) :
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>2.5.1</version>
<version>2.6.0</version>
</dependency>
```

Expand All @@ -79,7 +79,7 @@ and then the specific jar(s) for your platform(s) :
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.5.1</version>
<version>2.6.0</version>
</dependency>
```

Expand All @@ -88,7 +88,7 @@ and then the specific jar(s) for your platform(s) :
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>2.5.1</version>
<version>2.6.0</version>
</dependency>
```

Expand All @@ -97,13 +97,13 @@ and then the specific jar(s) for your platform(s) :
It includes all binaries for the supported platforms

``` XML
compile group: 'ws.schild', name: 'jave-all-deps', version: '2.5.1'
compile group: 'ws.schild', name: 'jave-all-deps', version: '2.6.0'
```

### For one platform only (Linux 64Bit in this case)
``` XML
compile group: 'ws.schild', name: 'jave-core', version: '2.5.1'
compile group: 'ws.schild', name: 'jave-nativebin-linux64', version: '2.5.1'
compile group: 'ws.schild', name: 'jave-core', version: '2.6.0'
compile group: 'ws.schild', name: 'jave-nativebin-linux64', version: '2.6.0'
```

### Main Components of Jave2
Expand Down
14 changes: 7 additions & 7 deletions jave-all-deps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ws.schild</groupId>
<packaging>jar</packaging>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
<artifactId>jave-all-deps</artifactId>
<name>Jave all native dependencies package</name>
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
Expand Down Expand Up @@ -152,32 +152,32 @@
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win32</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
Expand Down
14 changes: 7 additions & 7 deletions jave-core-test-java11/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ws.schild</groupId>
<packaging>jar</packaging>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
<artifactId>jave-core-test-java11</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down Expand Up @@ -38,32 +38,32 @@
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win32</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
Expand Down
14 changes: 7 additions & 7 deletions jave-core-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ws.schild</groupId>
<packaging>jar</packaging>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
<artifactId>jave-core-test</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down Expand Up @@ -38,32 +38,32 @@
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win32</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.io.File;
import java.net.URL;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -63,10 +65,48 @@ public void testEncodeVideo13() throws Exception {
encodingAttr.setVideoAttributes(videoAttr);
encodingAttr.setFormat("mp4");

PListener listener = new PListener();
Encoder encoder = new Encoder();
encoder.encode(new MultimediaObject(source), target, encodingAttr);
encoder.encode(new MultimediaObject(source, false), target, encodingAttr, listener);
assertNotNull(listener.getInfo(), "URL should be able to read twice");
assertTrue(target.exists(), "Output file missing");
}

/**
* Test of encode method, of class Encoder.
* @throws java.lang.Exception
*/
@Test
public void testEncodeVideo14() throws Exception {
System.out.println("testEncodeVideo14");

URL source = new URL("https://samples.ffmpeg.org/MPEG1/zelda%20first%20commercial.mpeg");
File target = new File(getResourceTargetPath(), "testEncodeVideo14.mp4");
if (target.exists())
{
target.delete();
}
AudioAttributes audioAttr = new AudioAttributes();
VideoAttributes videoAttr = new VideoAttributes();
EncodingAttributes encodingAttr = new EncodingAttributes();

audioAttr.setChannels(2);
audioAttr.setCodec("aac");
audioAttr.setBitRate(128000);
audioAttr.setSamplingRate(44100);

videoAttr.setCodec("libx264");
videoAttr.setBitRate(4000000);

encodingAttr.setAudioAttributes(audioAttr);
encodingAttr.setVideoAttributes(videoAttr);
encodingAttr.setFormat("mp4");

Encoder encoder = new Encoder();
PListener listener = new PListener();
encoder.encode(new MultimediaObject(source, true), target, encodingAttr, listener);
assertNull(listener.getInfo(), "URL should not be read twice");
assertTrue(target.exists(), "Output file missing");
}

}
2 changes: 1 addition & 1 deletion jave-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<packaging>jar</packaging>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
<name>Jave core package</name>
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
ffmpeg project. Developers can take take advantage of JAVE2 to transcode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DefaultFFMPEGLocator extends FFMPEGLocator {
* Trace the version of the bundled ffmpeg executable. It's a counter: every
* time the bundled ffmpeg change it is incremented by 1.
*/
private static final String MY_EXE_VERSION = "2.6.0-SNAPSHOT";
private static final String MY_EXE_VERSION = "2.6.0";

/**
* The ffmpeg executable file path.
Expand Down
2 changes: 1 addition & 1 deletion jave-core/src/main/java/ws/schild/jave/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public void encode(List<MultimediaObject> multimediaObjects, File target, Encodi
RBufferedReader reader = new RBufferedReader(
new InputStreamReader(ffmpeg.getErrorStream()));
MultimediaInfo info = null;
if (multimediaObjects.size() == 1 && !multimediaObjects.get(0).isURL() )
if (multimediaObjects.size() == 1 && (!multimediaObjects.get(0).isURL() || !multimediaObjects.get(0).isReadURLOnce()) )
{
info= multimediaObjects.get(0).getInfo();
}
Expand Down
36 changes: 34 additions & 2 deletions jave-core/src/main/java/ws/schild/jave/MultimediaObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

public class MultimediaObject {

/**
* @param readURLOnce the readURLOnce to set
*/
public void setReadURLOnce(boolean readURLOnce) {
this.readURLOnce = readURLOnce;
}

private static final Logger LOG = LoggerFactory.getLogger(MultimediaObject.class);
/**
* This regexp is used to parse the ffmpeg output about the size of a video
Expand Down Expand Up @@ -51,6 +58,12 @@ public class MultimediaObject {

private File inputFile;
private URL inputURL;
/**
* When true, we try to not read the source more than once
* One of the side effects is, that no progressbar is available.
*
*/
private boolean readURLOnce= false;

/**
* It builds an extractor using a {@link DefaultFFMPEGLocator} instance to
Expand All @@ -61,7 +74,6 @@ public class MultimediaObject {
public MultimediaObject(File input) {
this.locator = new DefaultFFMPEGLocator();
this.inputFile = input;

}

/**
Expand All @@ -73,7 +85,20 @@ public MultimediaObject(File input) {
public MultimediaObject(URL input) {
this.locator = new DefaultFFMPEGLocator();
this.inputURL = input;

}

/**
* It builds an extractor using a {@link DefaultFFMPEGLocator} instance to
* locate the ffmpeg executable to use.
*
* @param input Input URL for creating MultimediaObject
* @param readURLOnce When true, we try to not read the source more than once
* One of the side effects is, that no progressbar is available.
*/
public MultimediaObject(URL input, boolean readURLOnce) {
this.locator = new DefaultFFMPEGLocator();
this.inputURL = input;
this.readURLOnce= readURLOnce;
}

/**
Expand Down Expand Up @@ -395,4 +420,11 @@ private MultimediaInfo parseMultimediaInfo(String source,
}
return info;
}

/**
* @return the readURLOnce
*/
public boolean isReadURLOnce() {
return readURLOnce;
}
}
6 changes: 3 additions & 3 deletions jave-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ws.schild</groupId>
<packaging>jar</packaging>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
<artifactId>jave-example</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down Expand Up @@ -66,12 +66,12 @@
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
Expand Down
Loading

0 comments on commit 487012d

Please sign in to comment.