Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#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 Randall)

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 Randall, 2 years ago

Description: modified (diff)

comment:2 by Randall, 2 years ago

Description: modified (diff)

comment:3 by Marton Balint, 2 years ago

Resolution: invalid
Status: newclosed

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.

in reply to:  3 comment:4 by Randall, 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.

Note: See TracTickets for help on using tickets.