Commit 754ac705 authored by yanzg's avatar yanzg

打印模板处理

parent 712b38e2
...@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment