#9759 closed defect (invalid)
Output always goes to stderr even when there are no errors.
Reported by: | Randall | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | unspecified | Keywords: | stderr, error output |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description (last modified by )
Summary of the bug:
In my code (written in Rust) I'm running an ffmpeg command and checking if stderr contains text. But when I run a command successfully text is always output to stderr and nothing comes from stdout. Other command line tools I've used behave normally with regards to stdout and stderr that my code uses, so this appears to be a problem with ffmpeg rather than Rust.
How to reproduce:
I run this command to combine a video and audio file:
ffmpeg -i 'bruh_video.mp4' -i 'bruh_audio.mp4' -c:v copy -c:a aac 'bruh.mp4'
In Rust that code looks like
let output =
Command::new("sh") (Command is std::process::Command)
.arg("-c")
.arg(&format!("ffmpeg -i '{}' -i '{}' -c:v copy -c:a aac '{}'", video_filepath, audio_filepath, final_filepath))
.current_dir(&dl_folder)
.output()
.expect("failed to execute ffmpeg process");
let stdout = String::from_utf8(output.stdout).unwrap();
let stderr = String::from_utf8(output.stderr).unwrap();
The stdout will be empty but stderr will contain all the normal output text.
Change History (4)
comment:1 by , 2 years ago
Description: | modified (diff) |
---|
comment:2 by , 2 years ago
Description: | modified (diff) |
---|
follow-up: 4 comment:3 by , 2 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:4 by , 2 years ago
Replying to Marton Balint:
This is completely normal. Stderr is not just for errors, but for any additional information. Stdout is for the main output of the program, e.g. in case of ffmpeg you could use it to output video there. Stdout should never be cluttered with logging or runtime information, because in that case you would not be able to use stdout as the main output of the program.
To check if the program was run successfully you should check its exit code, not stdout/stderr output.
I see,thanks.
This is completely normal. Stderr is not just for errors, but for any additional information. Stdout is for the main output of the program, e.g. in case of ffmpeg you could use it to output video there. Stdout should never be cluttered with logging or runtime information, because in that case you would not be able to use stdout as the main output of the program.
To check if the program was run successfully you should check its exit code, not stdout/stderr output.