1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-02 00:15:02 -04:00

+ MediaInfoTest

This commit is contained in:
Reinhard Pointner 2016-07-29 17:52:30 +08:00
parent 84ac74ca1a
commit 4ff16a9f52

View File

@ -8,29 +8,28 @@ import java.net.URL;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
import net.filebot.Cache;
import net.filebot.CacheType;
import net.filebot.mediainfo.MediaInfo.StreamKind;
public class MediaInfoTest {
private static File getSampleFile(String name) throws Exception {
File folder = new File(FileUtils.getTempDirectory(), MediaInfoTest.class.getName());
File file = new File(folder, name + ".mp4");
File getSampleFile(String name) throws Exception {
File tmpdir = new File(FileUtils.getTempDirectory(), getClass().getName());
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()) {
byte[] bytes = Cache.getCache(folder.getName(), CacheType.Persistent).bytes("video/mp4/720/big_buck_bunny_720p_1mb.mp4", n -> {
return new URL("http://www.sample-videos.com/" + n);
}).get();
FileUtils.forceMkdir(folder);
FileUtils.writeByteArrayToFile(file, bytes);
FileUtils.copyFile(sample, file);
}
return file;
}
private static void testSampleFile(String name) throws Exception {
void testSampleFile(String name) throws Exception {
MediaInfo mi = new MediaInfo().open(getSampleFile(name));
assertEquals("MPEG-4", mi.get(StreamKind.General, 0, "Format"));