Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFmpeg's nearly unlimited output causes ffmpeg-sidecar to hang without a timeout #70

Closed
wikke opened this issue Dec 11, 2024 · 1 comment · Fixed by #71
Closed

FFmpeg's nearly unlimited output causes ffmpeg-sidecar to hang without a timeout #70

wikke opened this issue Dec 11, 2024 · 1 comment · Fixed by #71
Labels
bug Something isn't working

Comments

@wikke
Copy link

wikke commented Dec 11, 2024

I'm converting a video(with some strange .ts extension) to a 3-seconds gif using ffmpeg-sidecar. Command like

ffmpeg -loglevel level+warning -hide_banner -i "/path/to/bipbop-gear1-all.ts" -t 3 -an -vf "fps=10,scale=-1:200:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=164:stats_mode=diff[p];[s1][p]paletteuse=dither=floyd_steinberg:diff_mode=rectangle" -compression_level 9 -quality 85 -c:v gif -y "/path/to/thumbnail.gif"

However, ffmpeg cli output nearly unlimited lines of warning, like

[Parsed_palettegen_4 @ 0x600001574bb0] [warning] The input frame is not in sRGB, colors may be off
[Parsed_palettegen_4 @ 0x600001574bb0] [warning] The input frame is not in sRGB, colors may be off
...(tons of lines...)
[Parsed_palettegen_4 @ 0x600001574bb0] [warning] The input frame is not in sRGB, colors may be off
[Parsed_palettegen_4 @ 0x600001574bb0] [warning] The input frame is not in sRGB, colors may be off

but, ffmpeg cli just exits(not sure exit 0 or not 0) after about ~7 seconds, which I think reasonable.

When it comes to ffmpeg-sidecar in Rust

    let exit_status = FfmpegCommand::new()
        .args([
            "-loglevel", "level+warning",
            "-hide_banner",
            "-i", filepath,
            "-t", "3",
            "-an",
            "-vf", "fps=10,scale=-1:200:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=164:stats_mode=diff[p];[s1][p]paletteuse=dither=floyd_steinberg:diff_mode=rectangle",
            "-compression_level", "9",
            "-quality", "85",
            "-c:v", "gif",
            "-y",
            &thumbnail_path_buf.to_string_lossy()
        ])
        .spawn()?
        .wait()?;

    if exit_status.success() {
        Ok(...)
    } else {
        Err(...)
    }

FfmpegCommand(FfmpegChild maybe) thread just hangs at .wait()?

Maybe adding timeout parameter would be better? like the ffmpeg cli do internally? Or, I have to set a timer, and invoke handle FfmpegChild.quit/kill(maybe) when timeout, not very convenient.

You can download the test video at http://www.live555.com/liveMedia/public/h264-in-mp2t/bipbop-gear1-all.ts

@nathanbabcock nathanbabcock added the bug Something isn't working label Dec 11, 2024
@nathanbabcock
Copy link
Owner

Thanks for providing a test video, I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants