use of org.fagu.fmv.utils.file.FileFinder in project fmv by f-agu.
the class Bootstrap method findMovie.
// ---------------------------------------------------
/**
*/
private MovieFinder findMovie(File saveFile, File... srcFiles) throws IOException {
MovieFinder movieFinder = new MovieFinder(saveFile);
movieFinder.addInfoFile(new VolumeInfoFile());
movieFinder.addListener(new FileFinderListener<Movie>() {
private int count;
/**
* @see org.fagu.fmv.utils.file.FileFinderListener#eventFindPre(org.fagu.fmv.utils.file.FileFinder.FileFound)
*/
@Override
public void eventFindPre(FileFound fileFound) {
System.out.println(count + ": " + fileFound.getFileFound().getName());
++count;
}
/**
* @see org.fagu.fmv.utils.file.FileFinderListener#eventFindPost(FileFound, java.lang.Object)
*/
@Override
public void eventFindPost(FileFound fileFound, FileFinder<Movie>.InfosFile infosFile) {
Movie movie = infosFile.getMain();
MovieMetadatas videoMetadatas = movie.getMetadatas();
// Format format = videoMetadatas.getFormat();
VideoStream videoStream = videoMetadatas.getVideoStream();
Rotation rotate = videoStream.rotate();
// System.out.println(count + ": " + file.getName() + " " + infos); // .getFormat().creationDate()
System.out.println(" " + rotate + ", " + videoStream.handlerName());
}
});
for (File srcFile : srcFiles) {
movieFinder.find(srcFile);
}
return movieFinder;
}
use of org.fagu.fmv.utils.file.FileFinder in project fmv by f-agu.
the class ByDayAndIndexClassifier method classify.
/**
* @see org.fagu.fmv.mymedia.classify.movie.image.mymedia.Classifier#classify()
*/
@Override
public List<File> classify(Converter<Movie> converter, ConverterListener<Movie> listener) throws IOException {
List<File> files = new ArrayList<>(100);
for (Entry<String, SortedSet<FileFinder<Movie>.InfosFile>> entry : map.entrySet()) {
int index = 0;
for (FileFinder<Movie>.InfosFile infosFile : entry.getValue()) {
Movie movie = infosFile.getMain();
String extension = FilenameUtils.getExtension(movie.getFile().getName());
StringBuilder buf = new StringBuilder();
buf.append(entry.getKey()).append(" (");
buf.append(StringUtils.leftPad(Integer.toString(++index), 2, '0')).append(") .");
buf.append(converter.getFormat(extension));
File destFile = new File(destFolder, buf.toString());
converter.convert(movie, infosFile, destFile, listener);
files.add(destFile);
}
}
return files;
}
use of org.fagu.fmv.utils.file.FileFinder in project fmv by f-agu.
the class TimeOffsetImageComparatorTestCase method testEmpty.
/**
*/
@Test
public void testEmpty() {
TimeOffsetImageComparator comparator = new TimeOffsetImageComparator();
FileFinder<Image>.InfosFile image1 = mockImage(1, "1");
FileFinder<Image>.InfosFile image2 = mockImage(2, "2");
FileFinder<Image>.InfosFile image1b = mockImage(1, "1b");
assertEquals(-1, comparator.compare(image1, image2));
assertEquals(1, comparator.compare(image2, image1));
assertEquals(1, comparator.compare(image1b, image1));
}
use of org.fagu.fmv.utils.file.FileFinder in project fmv by f-agu.
the class ByDayAndIndexClassifier method classify.
/**
* @see org.fagu.fmv.mymedia.classify.Classifier#classify(org.fagu.fmv.mymedia.classify.Converter)
*/
@Override
public List<File> classify(Converter<Media> converter, ConverterListener<Media> listener) throws IOException {
List<File> files = new ArrayList<>(100);
int idxLen = 1 + (int) Math.log10(map.sizeValues());
int index = 0;
for (Entry<String, SortedSet<FileFinder<Media>.InfosFile>> entry : map.entrySet()) {
File curFolder = new File(destFolder, entry.getKey());
if (!curFolder.exists()) {
curFolder.mkdirs();
}
for (FileFinder<Media>.InfosFile infosFile : entry.getValue()) {
Media media = infosFile.getMain();
File srcFile = media.getFile();
StringBuilder buf = new StringBuilder();
buf.append(StringUtils.leftPad(Integer.toString(++index), idxLen, '0')).append('.');
buf.append(FilenameUtils.getExtension(srcFile.getName()).toLowerCase());
File destFile = new File(curFolder, buf.toString());
converter.convert(media, infosFile, destFile, listener);
files.add(destFile);
}
}
return files;
}
use of org.fagu.fmv.utils.file.FileFinder in project fmv by f-agu.
the class FindDiffTime method main.
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
ImageFinder imagesFinder = Sources.load(new File("C:\\tmp\\july\\save"));
for (FileFinder<Image>.InfosFile infosFile : imagesFinder.getAll()) {
Image image = infosFile.getMain();
File file = image.getFile();
System.out.println(file.getParentFile().getName() + "/" + file.getName() + " : " + DATE_FORMAT.format(new Date(image.getTime())));
if ("GOPR0698.JPG".equals(file.getName())) {
Calendar calendar = Calendar.getInstance();
calendar.set(2014, Calendar.JULY, 10, 15, 30, 0);
System.out.println("############### " + (image.getTime() - calendar.getTimeInMillis()));
}
}
}
Aggregations