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
754ac705
Commit
754ac705
authored
Jul 10, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打印模板处理
parent
712b38e2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
TestMediaHelper.java
yzg-util-image/src/test/java/helper/TestMediaHelper.java
+30
-18
xuziming.mp4
yzg-util-image/src/test/java/helper/xuziming.mp4
+0
-0
No files found.
yzg-util-image/src/test/java/helper/TestMediaHelper.java
View file @
754ac705
...
@@ -53,17 +53,17 @@ public class TestMediaHelper {
...
@@ -53,17 +53,17 @@ public class TestMediaHelper {
}
}
private
void
testConvert
(
String
item
,
float
size
,
float
quote
)
throws
EncoderException
{
private
void
testConvert
(
String
item
,
float
size
,
float
quote
)
throws
EncoderException
{
String
file
=
getFile
();
String
file
=
getFile
(
"100M.mp4"
);
String
targetFile
=
getTargetFile
();
String
targetFile
=
getTargetFile
(
"target/100M.mp4"
);
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.%s.mp4"
,
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.%s.mp4"
,
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
),
item
);
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
),
item
);
MediaHelper
.
zipVideo
(
file
,
name
,
"mp4"
,
item
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
MediaHelper
.
zipVideo
(
file
,
name
,
"mp4"
,
item
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
}
}
private
String
getFile
()
{
private
String
getFile
(
String
file
)
{
// 注意,路径应为文件在工程中的相对路径
// 注意,路径应为文件在工程中的相对路径
File
f
=
new
File
(
"src/test/java/helper/
100M.mp4"
);
File
f
=
new
File
(
"src/test/java/helper/
"
+
file
);
if
(!
f
.
exists
())
{
if
(!
f
.
exists
())
{
System
.
out
.
println
(
f
.
getAbsoluteFile
());
System
.
out
.
println
(
f
.
getAbsoluteFile
());
throw
new
RuntimeException
(
"视频文件不存在"
);
throw
new
RuntimeException
(
"视频文件不存在"
);
...
@@ -72,9 +72,9 @@ public class TestMediaHelper {
...
@@ -72,9 +72,9 @@ public class TestMediaHelper {
}
}
private
String
getTargetFile
()
{
private
String
getTargetFile
(
String
file
)
{
// 注意,路径应为文件在工程中的相对路径
// 注意,路径应为文件在工程中的相对路径
File
f
=
new
File
(
"target/100M.mp4"
);
File
f
=
new
File
(
file
);
return
f
.
getAbsolutePath
();
return
f
.
getAbsolutePath
();
}
}
...
@@ -83,8 +83,20 @@ public class TestMediaHelper {
...
@@ -83,8 +83,20 @@ public class TestMediaHelper {
if
(
isFirstImage
)
{
if
(
isFirstImage
)
{
return
;
return
;
}
}
String
file
=
getFile
();
String
file
=
getFile
(
"100M.mp4"
);
String
targetFile
=
getTargetFile
();
String
targetFile
=
getTargetFile
(
"target/100M.mp4"
);
MediaHelper
.
getVideoFirstImage
(
file
,
targetFile
+
".jpg"
);
isFirstImage
=
true
;
}
@Test
public
void
testVideoFirstImage1
()
throws
IOException
{
if
(
isFirstImage
)
{
return
;
}
String
file
=
getFile
(
"xuziming.mp4"
);
String
targetFile
=
getTargetFile
(
"target/xuziming.mp4"
);
MediaHelper
.
getVideoFirstImage
(
file
,
targetFile
+
".jpg"
);
MediaHelper
.
getVideoFirstImage
(
file
,
targetFile
+
".jpg"
);
isFirstImage
=
true
;
isFirstImage
=
true
;
}
}
...
@@ -116,8 +128,8 @@ public class TestMediaHelper {
...
@@ -116,8 +128,8 @@ public class TestMediaHelper {
}
}
private
void
testImageZip
(
float
size
,
float
quote
)
throws
IOException
{
private
void
testImageZip
(
float
size
,
float
quote
)
throws
IOException
{
String
file
=
getTargetFile
()
+
".jpg"
;
String
file
=
getTargetFile
(
"target/100M.mp4"
)
+
".jpg"
;
String
targetFile
=
getTargetFile
();
String
targetFile
=
getTargetFile
(
"target/100M.mp4"
);
String
toName
=
String
.
format
(
"%s.size_%d.quot_%d.jpg"
,
String
toName
=
String
.
format
(
"%s.size_%d.quot_%d.jpg"
,
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
String
toNameSystem
=
String
.
format
(
"%s.size_%d.quot_%d.system.jpg"
,
String
toNameSystem
=
String
.
format
(
"%s.size_%d.quot_%d.system.jpg"
,
...
@@ -151,8 +163,8 @@ public class TestMediaHelper {
...
@@ -151,8 +163,8 @@ public class TestMediaHelper {
}
}
private
void
testVideoZipFlv
(
float
size
,
float
quote
)
throws
EncoderException
{
private
void
testVideoZipFlv
(
float
size
,
float
quote
)
throws
EncoderException
{
String
file
=
getFile
();
String
file
=
getFile
(
"100M.mp4"
);
String
targetFile
=
getTargetFile
();
String
targetFile
=
getTargetFile
(
"target/100M.mp4"
);
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.flv"
,
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.flv"
,
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
MediaHelper
.
zipVideoFlv
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
MediaHelper
.
zipVideoFlv
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
...
@@ -188,8 +200,8 @@ public class TestMediaHelper {
...
@@ -188,8 +200,8 @@ public class TestMediaHelper {
}
}
private
void
testVideoZipMpeg
(
float
size
,
float
quote
)
throws
EncoderException
{
private
void
testVideoZipMpeg
(
float
size
,
float
quote
)
throws
EncoderException
{
String
file
=
getFile
();
String
file
=
getFile
(
"100M.mp4"
);
String
targetFile
=
getTargetFile
();
String
targetFile
=
getTargetFile
(
"target/100M.mp4"
);
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.mpeg.mp4"
,
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.mpeg.mp4"
,
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
MediaHelper
.
zipVideoMpeg
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
MediaHelper
.
zipVideoMpeg
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
...
@@ -218,8 +230,8 @@ public class TestMediaHelper {
...
@@ -218,8 +230,8 @@ public class TestMediaHelper {
}
}
private
void
testVideoZip3pg
(
float
size
,
float
quote
)
throws
EncoderException
{
private
void
testVideoZip3pg
(
float
size
,
float
quote
)
throws
EncoderException
{
String
file
=
getFile
();
String
file
=
getFile
(
"100M.mp4"
);
String
targetFile
=
getTargetFile
();
String
targetFile
=
getTargetFile
(
"target/100M.mp4"
);
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.3pg"
,
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.3pg"
,
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
MediaHelper
.
zipVideo3pg
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
MediaHelper
.
zipVideo3pg
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
...
@@ -255,8 +267,8 @@ public class TestMediaHelper {
...
@@ -255,8 +267,8 @@ public class TestMediaHelper {
}
}
private
void
testVideoZip
(
float
size
,
float
quote
)
throws
EncoderException
{
private
void
testVideoZip
(
float
size
,
float
quote
)
throws
EncoderException
{
String
file
=
getFile
();
String
file
=
getFile
(
"100M.mp4"
);
String
targetFile
=
getTargetFile
();
String
targetFile
=
getTargetFile
(
"target/100M.mp4"
);
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.mp4"
,
String
name
=
String
.
format
(
"%s.size_%d.quot_%d.mp4"
,
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
targetFile
,
(
int
)
(
size
*
100
),
(
int
)
(
quote
*
100
));
MediaHelper
.
zipVideo
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
MediaHelper
.
zipVideo
(
file
,
name
,
size
,
(
int
)
(
MediaHelper
.
DEFAULT_BIT_RATE
*
quote
));
...
...
yzg-util-image/src/test/java/helper/xuziming.mp4
0 → 100644
View file @
754ac705
File added
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