Heybuddy
Heybuddy

Reputation: 25

Exec through PHP. I cant get the output (stderr) into a file


When I run exec() through php, I fail to get the output (stderr) into a file.

I've included "2> my_out_put_file.txt" at the end of my command to accomplish this. But when I include this, the command is not executed. However, if I run the command without "2> my_out_put_file.txt" then it works.

The interesting thing is that the whole command, even with "2> my_out_put_file.txt" at the end of the command works if I run directly via shell/promt, but not when I run it through php / apache.


Does not work:

exec("C:/FFmpeg/bin/ffmpeg -i $new_path/$filename_with_ext -f mp4 -vcodec libx264 -preset ultrafast -profile:v main -acodec aac $new_path/$filename.mp4 2> out.txt", $a, $b);


Works:

exec("C:/FFmpeg/bin/ffmpeg -i $new_path/$filename_with_ext -f mp4 -vcodec libx264 -preset ultrafast -profile:v main -acodec aac $new_path/$filename.mp4", $a, $b);


Best regards
Neo

Upvotes: 0

Views: 60

Answers (1)

savvot
savvot

Reputation: 21

This worked for me:

... 2>&1 >> log.txt

Tested from exec too:

php -r "exec('ffmpeg -version 2>&1 >> log.txt');"

Upvotes: 0

Related Questions