+ MediaInfoTest
This commit is contained in:
parent
84ac74ca1a
commit
4ff16a9f52
@ -8,29 +8,28 @@ import java.net.URL;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.filebot.Cache;
|
|
||||||
import net.filebot.CacheType;
|
|
||||||
import net.filebot.mediainfo.MediaInfo.StreamKind;
|
import net.filebot.mediainfo.MediaInfo.StreamKind;
|
||||||
|
|
||||||
public class MediaInfoTest {
|
public class MediaInfoTest {
|
||||||
|
|
||||||
private static File getSampleFile(String name) throws Exception {
|
File getSampleFile(String name) throws Exception {
|
||||||
File folder = new File(FileUtils.getTempDirectory(), MediaInfoTest.class.getName());
|
File tmpdir = new File(FileUtils.getTempDirectory(), getClass().getName());
|
||||||
File file = new File(folder, name + ".mp4");
|
File sample = new File(tmpdir, "big_buck_bunny_720p_1mb.mp4");
|
||||||
|
URL data = new URL("http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4");
|
||||||
|
|
||||||
|
if (!sample.exists()) {
|
||||||
|
FileUtils.copyURLToFile(data, sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(tmpdir, name + ".mp4");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
byte[] bytes = Cache.getCache(folder.getName(), CacheType.Persistent).bytes("video/mp4/720/big_buck_bunny_720p_1mb.mp4", n -> {
|
FileUtils.copyFile(sample, file);
|
||||||
return new URL("http://www.sample-videos.com/" + n);
|
|
||||||
}).get();
|
|
||||||
|
|
||||||
FileUtils.forceMkdir(folder);
|
|
||||||
FileUtils.writeByteArrayToFile(file, bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testSampleFile(String name) throws Exception {
|
void testSampleFile(String name) throws Exception {
|
||||||
MediaInfo mi = new MediaInfo().open(getSampleFile(name));
|
MediaInfo mi = new MediaInfo().open(getSampleFile(name));
|
||||||
|
|
||||||
assertEquals("MPEG-4", mi.get(StreamKind.General, 0, "Format"));
|
assertEquals("MPEG-4", mi.get(StreamKind.General, 0, "Format"));
|
||||||
|
Loading…
Reference in New Issue
Block a user