Commit ae22eb78 authored by yanzg's avatar yanzg

压缩视频

parent b3326fdb
...@@ -26,6 +26,13 @@ public class TestMediaHelper { ...@@ -26,6 +26,13 @@ public class TestMediaHelper {
return f.getAbsolutePath(); return f.getAbsolutePath();
} }
private String getTargetFile() {
// 注意,路径应为文件在工程中的相对路径
File f = new File("target/100M.mp4");
return f.getAbsolutePath();
}
@Test @Test
public void testVideoFirstImage() throws IOException { public void testVideoFirstImage() throws IOException {
if (isFirstImage) { if (isFirstImage) {
...@@ -69,8 +76,9 @@ public class TestMediaHelper { ...@@ -69,8 +76,9 @@ 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();
String targetFile = getTargetFile();
String name = String.format("%s.size_%d.quot_%d.flv", String name = String.format("%s.size_%d.quot_%d.flv",
file, (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));
} }
...@@ -100,8 +108,9 @@ public class TestMediaHelper { ...@@ -100,8 +108,9 @@ 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();
String targetFile = getTargetFile();
String name = String.format("%s.size_%d.quot_%d.mpeg.mp4", String name = String.format("%s.size_%d.quot_%d.mpeg.mp4",
file, (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));
} }
...@@ -129,8 +138,9 @@ public class TestMediaHelper { ...@@ -129,8 +138,9 @@ 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();
String targetFile = getTargetFile();
String name = String.format("%s.size_%d.quot_%d.3pg", String name = String.format("%s.size_%d.quot_%d.3pg",
file, (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));
} }
} }
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