Skip to content

Commit d65b619

Browse files
committed
Correctly handle invalid/unknow durations in containers
1 parent b01742f commit d65b619

File tree

16 files changed

+88
-55
lines changed

16 files changed

+88
-55
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# JAVE2
22

33
## Changelog
4+
- **2.7.2**
5+
- Handle invalid/unknown duration values in containers
46
- **2.7.1**
57
- Allow additional arguments on watermark filter
68
- Make positions optional (use -1 for posX and posY) and then use the setAddArgument() method

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ It includes all binaries for the supported platforms
4646
<dependency>
4747
<groupId>ws.schild</groupId>
4848
<artifactId>jave-all-deps</artifactId>
49-
<version>2.7.1</version>
49+
<version>2.7.2</version>
5050
</dependency>
5151
```
5252

@@ -60,7 +60,7 @@ Generally if you want to use for one platform or more what you have to do is add
6060
<dependency>
6161
<groupId>ws.schild</groupId>
6262
<artifactId>jave-core</artifactId>
63-
<version>2.7.1</version>
63+
<version>2.7.2</version>
6464
</dependency>
6565
```
6666

@@ -71,7 +71,7 @@ and then the specific jar(s) for your platform(s) :
7171
<dependency>
7272
<groupId>ws.schild</groupId>
7373
<artifactId>jave-nativebin-linux64</artifactId>
74-
<version>2.7.1</version>
74+
<version>2.7.2</version>
7575
</dependency>
7676
```
7777

@@ -80,7 +80,7 @@ and then the specific jar(s) for your platform(s) :
8080
<dependency>
8181
<groupId>ws.schild</groupId>
8282
<artifactId>jave-nativebin-win64</artifactId>
83-
<version>2.7.1</version>
83+
<version>2.7.2</version>
8484
</dependency>
8585
```
8686

@@ -89,7 +89,7 @@ and then the specific jar(s) for your platform(s) :
8989
<dependency>
9090
<groupId>ws.schild</groupId>
9191
<artifactId>jave-nativebin-osx64</artifactId>
92-
<version>2.7.1</version>
92+
<version>2.7.2</version>
9393
</dependency>
9494
```
9595

@@ -98,13 +98,13 @@ and then the specific jar(s) for your platform(s) :
9898
It includes all binaries for the supported platforms
9999

100100
``` XML
101-
compile group: 'ws.schild', name: 'jave-all-deps', version: '2.7.1'
101+
compile group: 'ws.schild', name: 'jave-all-deps', version: '2.7.2'
102102
```
103103

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

110110
### Main Components of Jave2

jave-all-deps/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>ws.schild</groupId>
55
<packaging>jar</packaging>
6-
<version>2.7.1</version>
6+
<version>2.7.2</version>
77
<artifactId>jave-all-deps</artifactId>
88
<name>Jave all native dependencies package</name>
99
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
@@ -152,32 +152,32 @@
152152
<dependency>
153153
<groupId>ws.schild</groupId>
154154
<artifactId>jave-core</artifactId>
155-
<version>2.7.1</version>
155+
<version>2.7.2</version>
156156
</dependency>
157157
<dependency>
158158
<groupId>ws.schild</groupId>
159159
<artifactId>jave-nativebin-win32</artifactId>
160-
<version>2.7.1</version>
160+
<version>2.7.2</version>
161161
</dependency>
162162
<dependency>
163163
<groupId>ws.schild</groupId>
164164
<artifactId>jave-nativebin-win64</artifactId>
165-
<version>2.7.1</version>
165+
<version>2.7.2</version>
166166
</dependency>
167167
<dependency>
168168
<groupId>ws.schild</groupId>
169169
<artifactId>jave-nativebin-linux32</artifactId>
170-
<version>2.7.1</version>
170+
<version>2.7.2</version>
171171
</dependency>
172172
<dependency>
173173
<groupId>ws.schild</groupId>
174174
<artifactId>jave-nativebin-linux64</artifactId>
175-
<version>2.7.1</version>
175+
<version>2.7.2</version>
176176
</dependency>
177177
<dependency>
178178
<groupId>ws.schild</groupId>
179179
<artifactId>jave-nativebin-osx64</artifactId>
180-
<version>2.7.1</version>
180+
<version>2.7.2</version>
181181
</dependency>
182182
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
183183
<dependency>

jave-core-test-java11/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>ws.schild</groupId>
55
<packaging>jar</packaging>
6-
<version>2.7.1</version>
6+
<version>2.7.2</version>
77
<artifactId>jave-core-test-java11</artifactId>
88
<properties>
99
<maven.compiler.source>11</maven.compiler.source>
@@ -38,32 +38,32 @@
3838
<dependency>
3939
<groupId>ws.schild</groupId>
4040
<artifactId>jave-core</artifactId>
41-
<version>2.7.1</version>
41+
<version>2.7.2</version>
4242
</dependency>
4343
<dependency>
4444
<groupId>ws.schild</groupId>
4545
<artifactId>jave-nativebin-win32</artifactId>
46-
<version>2.7.1</version>
46+
<version>2.7.2</version>
4747
</dependency>
4848
<dependency>
4949
<groupId>ws.schild</groupId>
5050
<artifactId>jave-nativebin-win64</artifactId>
51-
<version>2.7.1</version>
51+
<version>2.7.2</version>
5252
</dependency>
5353
<dependency>
5454
<groupId>ws.schild</groupId>
5555
<artifactId>jave-nativebin-linux32</artifactId>
56-
<version>2.7.1</version>
56+
<version>2.7.2</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>ws.schild</groupId>
6060
<artifactId>jave-nativebin-linux64</artifactId>
61-
<version>2.7.1</version>
61+
<version>2.7.2</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>ws.schild</groupId>
6565
<artifactId>jave-nativebin-osx64</artifactId>
66-
<version>2.7.1</version>
66+
<version>2.7.2</version>
6767
</dependency>
6868
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
6969
<dependency>

jave-core-test/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>ws.schild</groupId>
55
<packaging>jar</packaging>
6-
<version>2.7.1</version>
6+
<version>2.7.2</version>
77
<artifactId>jave-core-test</artifactId>
88
<properties>
99
<maven.compiler.source>1.8</maven.compiler.source>
@@ -38,32 +38,32 @@
3838
<dependency>
3939
<groupId>ws.schild</groupId>
4040
<artifactId>jave-core</artifactId>
41-
<version>2.7.1</version>
41+
<version>2.7.2</version>
4242
</dependency>
4343
<dependency>
4444
<groupId>ws.schild</groupId>
4545
<artifactId>jave-nativebin-win32</artifactId>
46-
<version>2.7.1</version>
46+
<version>2.7.2</version>
4747
</dependency>
4848
<dependency>
4949
<groupId>ws.schild</groupId>
5050
<artifactId>jave-nativebin-win64</artifactId>
51-
<version>2.7.1</version>
51+
<version>2.7.2</version>
5252
</dependency>
5353
<dependency>
5454
<groupId>ws.schild</groupId>
5555
<artifactId>jave-nativebin-linux32</artifactId>
56-
<version>2.7.1</version>
56+
<version>2.7.2</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>ws.schild</groupId>
6060
<artifactId>jave-nativebin-linux64</artifactId>
61-
<version>2.7.1</version>
61+
<version>2.7.2</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>ws.schild</groupId>
6565
<artifactId>jave-nativebin-osx64</artifactId>
66-
<version>2.7.1</version>
66+
<version>2.7.2</version>
6767
</dependency>
6868
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
6969
<dependency>

jave-core-test/src/test/java/ws/schild/jave/MultimediaObjectTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,22 @@ public void testGetInfo04() throws Exception {
121121
assertEquals(result.getFormat(), "mpeg", "Invalid video format");
122122
assertEquals(result.getDuration(), 29800, "Invalid duration");
123123
}
124+
125+
126+
127+
/**
128+
* Test of getInfo method, of class MultimediaObject.
129+
* @throws java.lang.Exception
130+
*/
131+
@Test
132+
public void testGetInfo05() throws Exception {
133+
System.out.println("testGetInfo05");
134+
File file = new File(getResourceSourcePath(), "PCRecorded.mp4");
135+
MultimediaObject instance = new MultimediaObject(file);
136+
MultimediaInfo result = instance.getInfo();
137+
assertEquals("matroska", result.getFormat(), "Invalid video format");
138+
assertEquals("vp8", result.getVideo().getDecoder(), "Invalid video decoder format");
139+
assertEquals("opus", result.getAudio().getDecoder(), "Invalid audio decoder format");
140+
141+
}
124142
}

jave-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>ws.schild</groupId>
55
<artifactId>jave-core</artifactId>
66
<packaging>jar</packaging>
7-
<version>2.7.1</version>
7+
<version>2.7.2</version>
88
<name>Jave core package</name>
99
<description>The JAVE (Java Audio Video Encoder) library is Java wrapper on the
1010
ffmpeg project. Developers can take take advantage of JAVE2 to transcode

jave-core/src/main/java/ws/schild/jave/DefaultFFMPEGLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class DefaultFFMPEGLocator extends FFMPEGLocator {
4343
* Trace the version of the bundled ffmpeg executable. It's a counter: every
4444
* time the bundled ffmpeg change it is incremented by 1.
4545
*/
46-
private static final String MY_EXE_VERSION = "2.7.1";
46+
private static final String MY_EXE_VERSION = "2.7.2";
4747

4848
/**
4949
* The ffmpeg executable file path.

jave-core/src/main/java/ws/schild/jave/MultimediaObject.java

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ private MultimediaInfo parseMultimediaInfo(String source,
214214
EncoderException {
215215
Pattern p1 = Pattern.compile("^\\s*Input #0, (\\w+).+$\\s*",
216216
Pattern.CASE_INSENSITIVE);
217-
Pattern p2 = Pattern.compile(
217+
Pattern p21 = Pattern.compile(
218+
"^\\s*Duration:.*$",
219+
Pattern.CASE_INSENSITIVE);
220+
Pattern p22 = Pattern.compile(
218221
"^\\s*Duration: (\\d\\d):(\\d\\d):(\\d\\d)\\.(\\d\\d).*$",
219222
Pattern.CASE_INSENSITIVE);
220223
Pattern p3 = Pattern.compile(
@@ -257,22 +260,32 @@ private MultimediaInfo parseMultimediaInfo(String source,
257260
}
258261
case 1:
259262
{
260-
Matcher m = p2.matcher(line);
261-
if (m.matches())
263+
Matcher m1 = p21.matcher(line);
264+
Matcher m2 = p22.matcher(line);
265+
if (m1.matches())
262266
{
263-
long hours = Integer.parseInt(m.group(1));
264-
long minutes = Integer.parseInt(m.group(2));
265-
long seconds = Integer.parseInt(m.group(3));
266-
long dec = Integer.parseInt(m.group(4));
267-
long duration = (dec * 10L) + (seconds * 1000L)
268-
+ (minutes * 60L * 1000L)
269-
+ (hours * 60L * 60L * 1000L);
270-
info.setDuration(duration);
271-
step++;
272-
} else
267+
if (m2.matches())
268+
{
269+
long hours = Integer.parseInt(m2.group(1));
270+
long minutes = Integer.parseInt(m2.group(2));
271+
long seconds = Integer.parseInt(m2.group(3));
272+
long dec = Integer.parseInt(m2.group(4));
273+
long duration = (dec * 10L) + (seconds * 1000L)
274+
+ (minutes * 60L * 1000L)
275+
+ (hours * 60L * 60L * 1000L);
276+
info.setDuration(duration);
277+
step++;
278+
} else
279+
{
280+
LOG.warn("Invalid duration found {}", line);
281+
step++;
282+
// step = 3;
283+
}
284+
}
285+
else
273286
{
274287
// step = 3;
275-
}
288+
}
276289
break;
277290
}
278291
case 2:

jave-example/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>ws.schild</groupId>
55
<packaging>jar</packaging>
6-
<version>2.7.1</version>
6+
<version>2.7.2</version>
77
<artifactId>jave-example</artifactId>
88
<properties>
99
<maven.compiler.source>12</maven.compiler.source>
@@ -66,12 +66,12 @@
6666
<dependency>
6767
<groupId>ws.schild</groupId>
6868
<artifactId>jave-core</artifactId>
69-
<version>2.7.1</version>
69+
<version>2.7.2</version>
7070
</dependency>
7171
<dependency>
7272
<groupId>ws.schild</groupId>
7373
<artifactId>jave-nativebin-linux32</artifactId>
74-
<version>2.7.1</version>
74+
<version>2.7.2</version>
7575
</dependency>
7676
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
7777
<dependency>

0 commit comments

Comments
 (0)