Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
7ed5cf69
Commit
7ed5cf69
authored
May 28, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
压缩视频
parent
33e3822a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
343 additions
and
5 deletions
+343
-5
pom.xml
yzg-util-image/pom.xml
+5
-0
MediaHelper.java
...image/src/main/java/com/yanzuoguang/util/MediaHelper.java
+268
-4
100M.mp4.jpg
yzg-util-image/src/test/java/helper/100M.mp4.jpg
+0
-0
100M.mp4.zip.jpg
yzg-util-image/src/test/java/helper/100M.mp4.zip.jpg
+0
-0
TestMediaHelper.java
yzg-util-image/src/test/java/helper/TestMediaHelper.java
+70
-1
No files found.
yzg-util-image/pom.xml
View file @
7ed5cf69
...
@@ -37,5 +37,10 @@
...
@@ -37,5 +37,10 @@
<version>
1.0.2
</version>
<version>
1.0.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.yanzuoguang
</groupId>
<artifactId>
yzg-util-base
</artifactId>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
yzg-util-image/src/main/java/com/yanzuoguang/util/MediaHelper.java
View file @
7ed5cf69
This diff is collapsed.
Click to expand it.
yzg-util-image/src/test/java/helper/100M.mp4.jpg
deleted
100644 → 0
View file @
33e3822a
400 KB
yzg-util-image/src/test/java/helper/100M.mp4.zip.jpg
deleted
100644 → 0
View file @
33e3822a
218 KB
yzg-util-image/src/test/java/helper/TestMediaHelper.java
View file @
7ed5cf69
package
helper
;
package
helper
;
import
com.yanzuoguang.util.MediaHelper
;
import
com.yanzuoguang.util.MediaHelper
;
import
com.yanzuoguang.util.thread.RunnableListAuto
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
it.sauronsoftware.jave.EncoderException
;
import
jdk.management.resource.internal.inst.ThreadRMHooks
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TestMediaHelper
{
public
class
TestMediaHelper
{
private
boolean
isFirstImage
=
false
;
private
boolean
isFirstImage
=
false
;
public
float
[]
sizes
=
new
float
[]{
1
f
,
0.5f
,
1
f
,
1
f
,
0.5f
,
0.5f
};
public
float
[]
quotes
=
new
float
[]{
1
f
,
1
f
,
0.5f
,
0.25f
,
0.5f
,
0.25f
};
private
String
getFile
()
{
private
String
getFile
()
{
// 注意,路径应为文件在工程中的相对路径
// 注意,路径应为文件在工程中的相对路径
...
@@ -26,7 +34,7 @@ public class TestMediaHelper {
...
@@ -26,7 +34,7 @@ public class TestMediaHelper {
return
;
return
;
}
}
String
file
=
getFile
();
String
file
=
getFile
();
MediaHelper
.
getFirstImage
(
file
,
file
+
".jpg"
);
MediaHelper
.
get
Video
FirstImage
(
file
,
file
+
".jpg"
);
isFirstImage
=
true
;
isFirstImage
=
true
;
}
}
...
@@ -37,4 +45,65 @@ public class TestMediaHelper {
...
@@ -37,4 +45,65 @@ public class TestMediaHelper {
String
file
=
getFile
();
String
file
=
getFile
();
MediaHelper
.
compressPic
(
file
+
".jpg"
,
file
+
".zip.jpg"
,
0.25f
);
MediaHelper
.
compressPic
(
file
+
".jpg"
,
file
+
".zip.jpg"
,
0.25f
);
}
}
@Test
public
void
testVideoZipFlv
()
{
List
<
Runnable
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
sizes
.
length
;
i
++)
{
list
.
add
(
testVideoZipFlvThread
(
sizes
[
i
],
quotes
[
i
]));
}
RunnableListAuto
.
run
(
list
);
}
private
Runnable
testVideoZipFlvThread
(
float
size
,
float
quote
)
{
return
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
testVideoZipFlv
(
size
,
quote
);
}
catch
(
EncoderException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
};
}
private
void
testVideoZipFlv
(
float
size
,
float
quote
)
throws
EncoderException
{
String
file
=
getFile
();
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.flv"
,
file
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
MediaHelper
.
zipVideoFlv
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
}
@Test
public
void
testVideoZipMpeg
()
throws
EncoderException
{
List
<
Runnable
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
sizes
.
length
;
i
++)
{
list
.
add
(
testVideoZipMpegThread
(
sizes
[
i
],
quotes
[
i
]));
}
RunnableListAuto
.
run
(
list
);
}
private
Runnable
testVideoZipMpegThread
(
float
size
,
float
quote
)
{
return
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
testVideoZipMpeg
(
size
,
quote
);
}
catch
(
EncoderException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
};
}
private
void
testVideoZipMpeg
(
float
size
,
float
quote
)
throws
EncoderException
{
String
file
=
getFile
();
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.mpeg.mp4"
,
file
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
MediaHelper
.
zipVideoMpeg
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment