ffmpeg4j icon indicating copy to clipboard operation
ffmpeg4j copied to clipboard

Error: Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000)

Open maxixcom opened this issue 6 months ago • 1 comments

I was trying to run your example for transcoding but got error:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x103007df0] stream 0, offset 0x30: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x103007df0] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(tv, bt709), 1920x960, 4215 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Assertion desc failed at libswscale/swscale_internal.h:725

Process finished with exit code 134 (interrupted by signal 6:SIGABRT)

Am I did something wrong? May be I can add some additional configuration for suggested parameters somehow?

You can find example project with media here: https://github.com/maxixcom/ffmpeg4j-issue

Source code:

public class Main {
    private void transcode(InputStream inputStream,
                           String inputFormatName,
                           SeekableByteChannel outputChannel,
                           String outputFormatName) {
        try (FFmpegSourceStream sourceStream = FFmpegIO.openInputStream(inputStream).open(inputFormatName);
             FFmpegTargetStream targetStream = FFmpegIO.openChannel(outputChannel).asOutput().open(outputFormatName)) {
            sourceStream.registerStreams();
            sourceStream.copyToTargetStream(targetStream);

            Transcoder.convert(sourceStream, targetStream, Double.MAX_VALUE);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private void run() throws IOException {
        Set<OpenOption> openOptions = Set.of(
                StandardOpenOption.CREATE,
                StandardOpenOption.WRITE,
                StandardOpenOption.TRUNCATE_EXISTING
        );
        try (
                FileInputStream inputStream = new FileInputStream("tmp/sample-0.mp4");
                SeekableByteChannel seekableByteChannel = Files.newByteChannel(Paths.get("tmp/output.ts"), openOptions);
        ) {
            transcode(inputStream,"mp4", seekableByteChannel, "mpegts");
        }
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}

maxixcom avatar Jan 05 '24 13:01 maxixcom