Search in sources :

Example 26 with MovieMetadatas

use of org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas in project fmv by f-agu.

the class RipperTestCase method ffMPEGExecutorBuilder.

/**
 * @return
 * @throws IOException
 */
private FFMPEGExecutorBuilder ffMPEGExecutorBuilder() throws IOException {
    FFMPEGExecutorBuilder builder = mock(FFMPEGExecutorBuilder.class);
    doReturn(builder).when(builder).hideBanner();
    doReturn(builder).when(builder).noStats();
    InputProcessor inputProcessor = mock(InputProcessor.class);
    doReturn(inputProcessor).when(builder).addMediaInputFile(any(File.class));
    MovieMetadatas movieMetadatas = mock(MovieMetadatas.class);
    doReturn(movieMetadatas).when(inputProcessor).getMovieMetadatas();
    OutputProcessor outputProcessor = mock(OutputProcessor.class);
    doReturn(outputProcessor).when(builder).addMediaOutputFile(any(File.class));
    doReturn(outputProcessor).when(outputProcessor).codec(any(Coder.class));
    return builder;
}
Also used : Coder(org.fagu.fmv.ffmpeg.coder.Coder) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) OutputProcessor(org.fagu.fmv.ffmpeg.operation.OutputProcessor) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) File(java.io.File)

Example 27 with MovieMetadatas

use of org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas in project fmv by f-agu.

the class FFHelperTestCase method testOo_Rotate270.

/**
 * @throws Exception
 */
@Test
public void testOo_Rotate270() throws Exception {
    final MovieMetadatas movieMetadatas = mock(MovieMetadatas.class);
    VideoStream videoStream = mock(VideoStream.class);
    doReturn(videoStream).when(movieMetadatas).getVideoStream();
    doReturn(Rotation.R_270).when(videoStream).rotate();
    movieMetadatasSupplier = fileName -> movieMetadatas;
    File inFile = new File("in.mp4");
    File outFile = new File("out.mp4");
    FFHelper.oo(inFile, outFile);
    if (AutoRotate.isAutoRotateObsolete()) {
        assertCmd("-hide_banner -i in.mp4 -filter:a \"aresample=sample_rate=44100\" -filter:v \"scale=w='if(gt(dar,930/500),930,trunc(oh*dar/2)*2)':h='if(gt(dar,930/500),trunc(ow/dar/2)*2,500)',format=yuv420p\" -movflags +faststart -f mp4 -codec:v libx264 -preset medium -profile:v baseline -level 3.0 -crf 22 -pix_fmt yuv420p -codec:a aac -ac 2 -b:a 128000 -y -metadata:s:v:0 \"rotate=0\" out.mp4");
    } else {
        assertCmd("-hide_banner -i in.mp4 -filter:a \"aresample=sample_rate=44100\" -filter:v \"transpose=dir=cclock,scale=w='if(gt(dar,930/500),930,trunc(oh*dar/2)*2)':h='if(gt(dar,930/500),trunc(ow/dar/2)*2,500)',format=yuv420p\" -movflags +faststart -f mp4 -codec:v libx264 -preset medium -profile:v baseline -level 3.0 -crf 22 -pix_fmt yuv420p -codec:a aac -ac 2 -b:a 128000 -y -metadata:s:v:0 \"rotate=0\" out.mp4");
    }
}
Also used : MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) MockVideoStream(org.fagu.fmv.ffmpeg.MockMovieMetadatas.MockVideoStream) VideoStream(org.fagu.fmv.ffmpeg.metadatas.VideoStream) File(java.io.File) Test(org.junit.Test)

Example 28 with MovieMetadatas

use of org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas in project fmv by f-agu.

the class TSTest method test.

@Test
@Ignore
public void test() throws IOException {
    MovieMetadatas metadatas = MovieMetadatas.with(new File("d:\\tmp\\dvdout.ts")).extract();
    List<Stream> streams = metadatas.getStreams();
    System.out.println("count: " + streams.size());
    for (Stream stream : streams) {
        System.out.println(stream);
        if (stream.is(Type.VIDEO)) {
            VideoStream videoStream = (VideoStream) stream;
            System.out.println("   " + videoStream);
        } else if (stream.is(Type.AUDIO)) {
            AudioStream audioStream = (AudioStream) stream;
            System.out.println("   " + audioStream);
        }
    }
}
Also used : AudioStream(org.fagu.fmv.ffmpeg.metadatas.AudioStream) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) VideoStream(org.fagu.fmv.ffmpeg.metadatas.VideoStream) AudioStream(org.fagu.fmv.ffmpeg.metadatas.AudioStream) Stream(org.fagu.fmv.ffmpeg.metadatas.Stream) VideoStream(org.fagu.fmv.ffmpeg.metadatas.VideoStream) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with MovieMetadatas

use of org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas in project fmv by f-agu.

the class FFExceptionKnowAnalyzeTestCase method extractMetadatas.

// ****************************************************************
/**
 * @param resource
 * @param expectedMessage
 * @throws IOException
 */
private void extractMetadatas(String resource, String expectedMessage) throws IOException {
    File folder = new File(System.getProperty("java.io.tmpdir"), "ff-extractmetadatas-test");
    try {
        FileUtils.deleteDirectory(folder);
        folder.mkdirs();
        File file = resource != null ? ResourceUtils.extract(resource, folder) : folder;
        try {
            MovieMetadatas extract = MovieMetadatas.with(file).extract();
            fail(expectedMessage + ": " + extract.toJSON());
        } catch (FMVExecuteException e) {
            if (e.isKnown()) {
                assertEquals(expectedMessage, e.getExceptionKnown().toString());
            } else {
                throw e;
            }
        }
    } finally {
        FileUtils.deleteDirectory(folder);
    }
}
Also used : FMVExecuteException(org.fagu.fmv.soft.exec.exception.FMVExecuteException) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) File(java.io.File)

Example 30 with MovieMetadatas

use of org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas in project fmv by f-agu.

the class FFHelperTestCase method testOo_Rotate180.

/**
 * @throws Exception
 */
@Test
public void testOo_Rotate180() throws Exception {
    final MovieMetadatas movieMetadatas = mock(MovieMetadatas.class);
    VideoStream videoStream = mock(VideoStream.class);
    doReturn(videoStream).when(movieMetadatas).getVideoStream();
    doReturn(Rotation.R_180).when(videoStream).rotate();
    movieMetadatasSupplier = fileName -> movieMetadatas;
    File inFile = new File("in.mp4");
    File outFile = new File("out.mp4");
    FFHelper.oo(inFile, outFile);
    if (AutoRotate.isAutoRotateObsolete()) {
        assertCmd("-hide_banner -i in.mp4 -filter:a \"aresample=sample_rate=44100\" -filter:v \"scale=w='if(gt(dar,930/500),930,trunc(oh*dar/2)*2)':h='if(gt(dar,930/500),trunc(ow/dar/2)*2,500)',format=yuv420p\" -movflags +faststart -f mp4 -codec:v libx264 -preset medium -profile:v baseline -level 3.0 -crf 22 -pix_fmt yuv420p -codec:a aac -ac 2 -b:a 128000 -y -metadata:s:v:0 \"rotate=0\" out.mp4");
    } else {
        assertCmd("-hide_banner -i in.mp4 -filter:a \"aresample=sample_rate=44100\" -filter:v \"transpose=dir=clock,transpose=dir=clock,scale=w='if(gt(dar,930/500),930,trunc(oh*dar/2)*2)':h='if(gt(dar,930/500),trunc(ow/dar/2)*2,500)',format=yuv420p\" -movflags +faststart -f mp4 -codec:v libx264 -preset medium -profile:v baseline -level 3.0 -crf 22 -pix_fmt yuv420p -codec:a aac -ac 2 -b:a 128000 -y -metadata:s:v:0 \"rotate=0\" out.mp4");
    }
}
Also used : MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) MockVideoStream(org.fagu.fmv.ffmpeg.MockMovieMetadatas.MockVideoStream) VideoStream(org.fagu.fmv.ffmpeg.metadatas.VideoStream) File(java.io.File) Test(org.junit.Test)

Aggregations

MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)31 File (java.io.File)17 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)17 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)14 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)13 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)12 Stream (org.fagu.fmv.ffmpeg.metadatas.Stream)8 IOException (java.io.IOException)6 AudioStream (org.fagu.fmv.ffmpeg.metadatas.AudioStream)6 OptionalInt (java.util.OptionalInt)5 Size (org.fagu.fmv.utils.media.Size)5 StringJoiner (java.util.StringJoiner)4 SubtitleStream (org.fagu.fmv.ffmpeg.metadatas.SubtitleStream)4 Progress (org.fagu.fmv.ffmpeg.operation.Progress)4 Type (org.fagu.fmv.ffmpeg.operation.Type)4 Logger (org.fagu.fmv.mymedia.logger.Logger)4 Rotation (org.fagu.fmv.utils.media.Rotation)4 Optional (java.util.Optional)3 FilenameUtils (org.apache.commons.io.FilenameUtils)3 FFExecutor (org.fagu.fmv.ffmpeg.executor.FFExecutor)3