Search in sources :

Example 1 with ImageMetadatas

use of org.fagu.fmv.im.ImageMetadatas in project fmv by f-agu.

the class TimeOffsetImageComparatorTestCase method mockImage.

/**
 * @param time
 * @param device
 * @param model
 * @param fileName
 * @return
 */
private FileFinder<Image>.InfosFile mockImage(long time, String device, String model, String fileName) {
    Image image = mock(Image.class);
    ImageMetadatas imageMetadatas = mock(ImageMetadatas.class);
    File file = mock(File.class);
    doReturn(time).when(image).getTime();
    doReturn(imageMetadatas).when(image).getMetadatas();
    doReturn(new Date(time)).when(imageMetadatas).getDate();
    if (device != null) {
        doReturn(device).when(imageMetadatas).getDevice();
    }
    if (model != null) {
        doReturn(model).when(imageMetadatas).getDeviceModel();
    }
    FileFinder<Image>.InfosFile infosFile = mock(InfosFile.class);
    doReturn(image).when(infosFile).getMain();
    doReturn(file).when(image).getFile();
    doReturn(fileName).when(file).getName();
    return infosFile;
}
Also used : ImageMetadatas(org.fagu.fmv.im.ImageMetadatas) FileFinder(org.fagu.fmv.utils.file.FileFinder) Image(org.fagu.fmv.im.Image) File(java.io.File) InfosFile(org.fagu.fmv.utils.file.FileFinder.InfosFile) Date(java.util.Date)

Example 2 with ImageMetadatas

use of org.fagu.fmv.im.ImageMetadatas in project fmv by f-agu.

the class ConsoleOutput method forOutput.

/**
 * @param fileSource
 * @param fromFile
 * @return
 */
public static String forOutput(FileSource fileSource, File fromFile) {
    StringBuilder buf = new StringBuilder(100);
    buf.append(StringUtils.rightPad(Integer.toString(fileSource.getNumber()), 3)).append(' ').append(' ');
    FileType fileType = fileSource.getFileType();
    if (fileType != null) {
        buf.append(fileType.name().charAt(0)).append(' ');
    }
    String meta = null;
    if (fileSource.isImage()) {
        ImageMetadatas imageMetadatas = fileSource.getImageMetadatas();
        if (imageMetadatas != null) {
            meta = imageMetadatas.getDimension().toString();
        }
    }
    if (fileSource.isAudioOrVideo()) {
        MovieMetadatas videoMetadatas = fileSource.getVideoMetadatas();
        if (videoMetadatas != null) {
            AudioStream audioStream = videoMetadatas.getAudioStream();
            VideoStream videoStream = videoMetadatas.getVideoStream();
            if (videoStream != null) {
                Optional<Duration> duration = videoStream.duration();
                String sd = duration.isPresent() ? duration.get().toString() : "";
                meta = videoStream.size().toString() + " " + sd;
            } else if (audioStream != null) {
                Optional<Duration> duration = audioStream.duration();
                meta = duration.isPresent() ? duration.get().toString() : "";
            }
        }
    }
    String subPath = null;
    if (fromFile != null) {
        subPath = StringUtils.substringAfter(fileSource.getFile().getPath(), fromFile.getPath() + File.separator);
    } else {
        subPath = fileSource.getFile().getName();
    }
    buf.append(StringUtils.rightPad(meta, 25)).append(' ').append(' ').append(subPath);
    return buf.toString();
}
Also used : ImageMetadatas(org.fagu.fmv.im.ImageMetadatas) AudioStream(org.fagu.fmv.ffmpeg.metadatas.AudioStream) Optional(java.util.Optional) FileType(org.fagu.fmv.media.FileType) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) VideoStream(org.fagu.fmv.ffmpeg.metadatas.VideoStream) Duration(org.fagu.fmv.utils.time.Duration)

Aggregations

ImageMetadatas (org.fagu.fmv.im.ImageMetadatas)2 File (java.io.File)1 Date (java.util.Date)1 Optional (java.util.Optional)1 AudioStream (org.fagu.fmv.ffmpeg.metadatas.AudioStream)1 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)1 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)1 Image (org.fagu.fmv.im.Image)1 FileType (org.fagu.fmv.media.FileType)1 FileFinder (org.fagu.fmv.utils.file.FileFinder)1 InfosFile (org.fagu.fmv.utils.file.FileFinder.InfosFile)1 Duration (org.fagu.fmv.utils.time.Duration)1