Real time output like python

Hi, i ran this code in python and show me the output at real time from shell:

os.system('ffmpeg -i VIDEO.mp4 -n -f avi -r 24.00 -vcodec mpeg4 -vtag XVID -filter:v scale=w=480:h=360 -aspect 4:3 -b:v 520k -acodec libmp3lame -ar 44100 -b:a 128k -ac 2 VIDEO_OUTPUT.avi')

how do that in rust ? :slightly_smiling_face:

Thanks.

See examples in doc.

1 Like

You are looking for the std::process::Command struct. By default it will forward stdout and stderr to the parent's stdout and stderr (i.e. yout terminal) while the program is running.

Check out the API docs for some examples:

Something big to point out is that the Command struct doesn't let you pass a single command string that will be run by the shell. Instead, it tells the OS to start a program directly, so if you want to run a shell command you'll need to do that yourself (e.g. Command::new("sh").arg("-c").arg("ffmpeg -i VIDEO.mp4 ...")).

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.