Skip to content

Commit

Permalink
Correctly handle invalid/unknow durations in containers
Browse files Browse the repository at this point in the history
  • Loading branch information
a-schild committed Jan 9, 2020
1 parent b01742f commit d65b619
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 55 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# JAVE2

## Changelog
- **2.7.2**
- Handle invalid/unknown duration values in containers
- **2.7.1**
- Allow additional arguments on watermark filter
- Make positions optional (use -1 for posX and posY) and then use the setAddArgument() method
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ It includes all binaries for the supported platforms
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-all-deps</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
```

Expand All @@ -60,7 +60,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.7.1</version>
<version>2.7.2</version>
</dependency>
```

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

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

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

Expand All @@ -98,13 +98,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.7.1'
compile group: 'ws.schild', name: 'jave-all-deps', version: '2.7.2'
```

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

### 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.7.1</version>
<version>2.7.2</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.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win32</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>2.7.1</version>
<version>2.7.2</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.7.1</version>
<version>2.7.2</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.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win32</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>2.7.1</version>
<version>2.7.2</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.7.1</version>
<version>2.7.2</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.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win32</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>2.7.1</version>
<version>2.7.2</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 @@ -121,4 +121,22 @@ public void testGetInfo04() throws Exception {
assertEquals(result.getFormat(), "mpeg", "Invalid video format");
assertEquals(result.getDuration(), 29800, "Invalid duration");
}



/**
* Test of getInfo method, of class MultimediaObject.
* @throws java.lang.Exception
*/
@Test
public void testGetInfo05() throws Exception {
System.out.println("testGetInfo05");
File file = new File(getResourceSourcePath(), "PCRecorded.mp4");
MultimediaObject instance = new MultimediaObject(file);
MultimediaInfo result = instance.getInfo();
assertEquals("matroska", result.getFormat(), "Invalid video format");
assertEquals("vp8", result.getVideo().getDecoder(), "Invalid video decoder format");
assertEquals("opus", result.getAudio().getDecoder(), "Invalid audio decoder format");

}
}
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.7.1</version>
<version>2.7.2</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.7.1";
private static final String MY_EXE_VERSION = "2.7.2";

/**
* The ffmpeg executable file path.
Expand Down
41 changes: 27 additions & 14 deletions jave-core/src/main/java/ws/schild/jave/MultimediaObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ private MultimediaInfo parseMultimediaInfo(String source,
EncoderException {
Pattern p1 = Pattern.compile("^\\s*Input #0, (\\w+).+$\\s*",
Pattern.CASE_INSENSITIVE);
Pattern p2 = Pattern.compile(
Pattern p21 = Pattern.compile(
"^\\s*Duration:.*$",
Pattern.CASE_INSENSITIVE);
Pattern p22 = Pattern.compile(
"^\\s*Duration: (\\d\\d):(\\d\\d):(\\d\\d)\\.(\\d\\d).*$",
Pattern.CASE_INSENSITIVE);
Pattern p3 = Pattern.compile(
Expand Down Expand Up @@ -257,22 +260,32 @@ private MultimediaInfo parseMultimediaInfo(String source,
}
case 1:
{
Matcher m = p2.matcher(line);
if (m.matches())
Matcher m1 = p21.matcher(line);
Matcher m2 = p22.matcher(line);
if (m1.matches())
{
long hours = Integer.parseInt(m.group(1));
long minutes = Integer.parseInt(m.group(2));
long seconds = Integer.parseInt(m.group(3));
long dec = Integer.parseInt(m.group(4));
long duration = (dec * 10L) + (seconds * 1000L)
+ (minutes * 60L * 1000L)
+ (hours * 60L * 60L * 1000L);
info.setDuration(duration);
step++;
} else
if (m2.matches())
{
long hours = Integer.parseInt(m2.group(1));
long minutes = Integer.parseInt(m2.group(2));
long seconds = Integer.parseInt(m2.group(3));
long dec = Integer.parseInt(m2.group(4));
long duration = (dec * 10L) + (seconds * 1000L)
+ (minutes * 60L * 1000L)
+ (hours * 60L * 60L * 1000L);
info.setDuration(duration);
step++;
} else
{
LOG.warn("Invalid duration found {}", line);
step++;
// step = 3;
}
}
else
{
// step = 3;
}
}
break;
}
case 2:
Expand Down
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.7.1</version>
<version>2.7.2</version>
<artifactId>jave-example</artifactId>
<properties>
<maven.compiler.source>12</maven.compiler.source>
Expand Down Expand Up @@ -66,12 +66,12 @@
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux32</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion jave-nativebin-linux32/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.7.1</version>
<version>2.7.2</version>
<artifactId>jave-nativebin-linux32</artifactId>
<name>Jave linux 32 bit native package</name>
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
Expand Down
2 changes: 1 addition & 1 deletion jave-nativebin-linux64/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.7.1</version>
<version>2.7.2</version>
<artifactId>jave-nativebin-linux64</artifactId>
<name>Jave linux 64 bit native package</name>
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
Expand Down
2 changes: 1 addition & 1 deletion jave-nativebin-osx64/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.7.1</version>
<version>2.7.2</version>
<artifactId>jave-nativebin-osx64</artifactId>
<name>Jave OSX 64 bit native package</name>
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
Expand Down
2 changes: 1 addition & 1 deletion jave-nativebin-win32/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.7.1</version>
<version>2.7.2</version>
<artifactId>jave-nativebin-win32</artifactId>
<name>Jave windows 32 bit native package</name>
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
Expand Down
2 changes: 1 addition & 1 deletion jave-nativebin-win64/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.7.1</version>
<version>2.7.2</version>
<artifactId>jave-nativebin-win64</artifactId>
<name>Jave windows 64 bit native package</name>
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<artifactId>jave-modules</artifactId>
<packaging>pom</packaging>
<properties>
<revision>2.7.1</revision>
<revision>2.7.2</revision>
<!-- Don't forget to change it also in DefaultFFMPEGLocator.java -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<version>2.7.1</version>
<version>2.7.2</version>
<name>Jave master project</name>
<description>Jave master project</description>
<url>https://github.com/a-schild/jave2</url>
Expand Down

0 comments on commit d65b619

Please sign in to comment.