Search in sources :

Example 1 with Media

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();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) Progress(org.fagu.fmv.ffmpeg.operation.Progress) VolumeDetect(org.fagu.fmv.ffmpeg.filter.impl.VolumeDetect) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) Media(org.fagu.fmv.media.Media) OptionalInt(java.util.OptionalInt) TextProgressBar(org.fagu.fmv.textprogressbar.TextProgressBar) VolumeDetected(org.fagu.fmv.ffmpeg.filter.impl.VolumeDetected)

Example 2 with Media

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;
}
Also used : ArrayList(java.util.ArrayList) Media(org.fagu.fmv.media.Media) FileFinder(org.fagu.fmv.utils.file.FileFinder) File(java.io.File) SortedSet(java.util.SortedSet) MapSortedSet(org.fagu.fmv.utils.collection.MapSortedSet)

Aggregations

Media (org.fagu.fmv.media.Media)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 OptionalInt (java.util.OptionalInt)1 SortedSet (java.util.SortedSet)1 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)1 VolumeDetect (org.fagu.fmv.ffmpeg.filter.impl.VolumeDetect)1 VolumeDetected (org.fagu.fmv.ffmpeg.filter.impl.VolumeDetected)1 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)1 Progress (org.fagu.fmv.ffmpeg.operation.Progress)1 TextProgressBar (org.fagu.fmv.textprogressbar.TextProgressBar)1 MapSortedSet (org.fagu.fmv.utils.collection.MapSortedSet)1 FileFinder (org.fagu.fmv.utils.file.FileFinder)1