bramp / ffmpeg-cli-wrapper

Java wrapper around the FFmpeg command line tool
BSD 2-Clause "Simplified" License
1.71k stars 412 forks source link

ProgressListener nerver trigered but the video is in converting #332

Open peihuanhuan opened 3 months ago

peihuanhuan commented 3 months ago

Describe the bug

ProgressListener nerver trigered but the video is in converting.

found the error log: Error closing progress log, loss of information possible: Broken pipe

image

To Reproduce

fun ffmpeg(inputPath: String, outputPath: String, byteRate: Long) {
    val ffmpeg = FFmpeg("ffmpeg")
    val ffprobe = FFprobe("ffprobe")

    val inputProbe = ffprobe.probe(inputPath)

    val builder = FFmpegBuilder()
        .setInput(inputPath) // Filename, or a FFmpegProbeResult
        .overrideOutputFiles(true) // Override the output if it exists
        .addOutput(outputPath) // Filename for the destination
        .setAudioBitRate(byteRate * 1024) // at 32 kbit/s
        .done()

    val executor = FFmpegExecutor(ffmpeg, ffprobe)

    executor.createJob(builder) { progress ->
        val duration_ns: Double = inputProbe.getFormat().duration * TimeUnit.SECONDS.toNanos(1)

        val percentage = progress.out_time_ns / duration_ns

        log.info(String.format(
            "[%.0f%%] time:%s ms status:%s frame:%d fps:%.0f speed:%.2fx",
            percentage * 100,
            FFmpegUtils.toTimecode(progress.out_time_ns, TimeUnit.NANOSECONDS),
            progress.status,
            progress.frame,
            progress.fps,
            progress.speed
        ));

    }.run()

}

Expected behavior A clear and concise description of what you expected to happen.

Version (if applicable):

Additional context my dockerfile:

FROM ubuntu

RUN apt-get update -y

RUN apt-get install ffmpeg -y
Euklios commented 3 months ago

Thank you for the report! This might be fixed by #315, but that one sadly hasn't been released yet

If possible, could you share some information about the file you're encoding? Especially the duration would be interesting.

peihuanhuan commented 3 months ago

Thank you @Euklios , do we have a plan to release it? I'm converting .m4s to .mp3 file. It's a minute or two mostly, up to a couple hours, but they all have this problem.

Euklios commented 3 months ago

That's a hard question. There is #319, which is technically ready, but releasing is a responsibility of @bramp . The cleanest option would be going through him.

Alternatively: I used to be doing unofficial snapshot releases, I think I could get that back up for you

peihuanhuan commented 3 months ago

Thank you @Euklios ! let's wait @bramp 's feedback first.

Euklios commented 3 months ago

Fine by me. I don't know how fast you need this fixed.

I just tried to create a test based on the code you provided, but couldn't re-create the issue. Could you please try your code using the big_buck_bunny_720p_1mb.mp4 file from this repository?

peihuanhuan commented 3 months ago

it's not a urgent ticket, let me have a try. but i think it will occur, it should be a ffmpeg version issue.

peihuanhuan commented 3 months ago

for the big_buck_bunny_720p_1mb.mp4, there is no closing progress log, loss of information possible: Broken pipe error log or any other log, this video seems to short.

image