Commit 9f7d9548 authored by yanzg's avatar yanzg

下载视频

parent 11549fde
......@@ -4,6 +4,8 @@ import com.yanzuoguang.media.HlsDownloader;
import com.yanzuoguang.media.MediaFirst;
import com.yanzuoguang.media.MediaReqVo;
import com.yanzuoguang.media.MediaResVo;
import com.yanzuoguang.util.MediaHelper;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.thread.ThreadHelper;
import org.junit.Test;
......@@ -15,6 +17,17 @@ public class MediaFirstTest {
private String getFile(String file) {
// 注意,路径应为文件在工程中的相对路径
File f = new File("src/test/java/helper/" + file);
if (!f.exists()) {
System.out.println(f.getAbsoluteFile());
throw YzgError.getRuntimeException("005");
}
return f.getAbsolutePath();
}
private String getTargetFile(String file) {
// 注意,路径应为文件在工程中的相对路径
File f = new File(file);
return f.getAbsolutePath();
}
......@@ -37,11 +50,14 @@ public class MediaFirstTest {
@Test
public void testHlsDown() throws Exception {
String targetFile = getTargetFile("target/downHls.mp4");
HlsDownloader downloader = new HlsDownloader("http://rtmp.tourbida.com/hls/0bfbec86-7a75-4b70-9318-dd32a3d59633.m3u8",
getFile("downHls.mp4"),
targetFile,
1,
1
);
downloader.download(true, true);
// 获取视频第一帧
MediaHelper.getVideoFirstImage(targetFile, targetFile + ".jpg");
}
}
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