use of org.fagu.fmv.media.Media in project fmv by f-agu.
the class VolumeInfoFile method toLine.
/**
* @see org.fagu.fmv.mymedia.file.InfoFile#toLine(org.fagu.fmv.utils.file.FileFinder.FileFound,
* org.fagu.fmv.media.Media)
*/
@Override
public String toLine(FileFound fileFound, FileFinder<Media>.InfosFile infosFile) throws IOException {
Media main = infosFile.getMain();
MovieMetadatas metadatas = (MovieMetadatas) main.getMetadatas();
FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
builder.addMediaInputFile(fileFound.getFileFound());
VolumeDetect volumeDetect = VolumeDetect.build();
builder.filter(volumeDetect);
builder.addMediaOutput(NullMuxer.build()).overwrite();
FFExecutor<Object> executor = builder.build();
if (metadatas != null) {
OptionalInt countEstimateFrames = metadatas.getVideoStream().countEstimateFrames();
Progress progress = executor.getProgress();
if (countEstimateFrames.isPresent() && progress != null) {
try (TextProgressBar bar = FFMpegProgressBar.with(progress).byFrame(countEstimateFrames.getAsInt()).build().makeBar("Detect volume")) {
executor.execute();
}
System.out.println();
}
} else {
executor.execute();
}
VolumeDetected volumeDetected = volumeDetect.getDetected();
return volumeDetected.toString();
}
use of org.fagu.fmv.media.Media 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;
}
Aggregations