ffmpeg查找文件PHP exec

Having no success with ffmpeg. How do i check if a file even exists?

I have the file

$mp3 = $_SERVER['DOCUMENT_ROOT']."/wp-content/youtube_channels/major.mp3";

I've attempted to find the file with exec() but nothing is returned. How do i solve? I'm totally lost.

var_dump(exec("/usr/include/ffmpeg -i $mp3"));

All that is returned string(0) ""

when i check phpinfo ffmpeg is installed and when i type exec("whereis ffmpeg") what is returned is /usr/include/ffmpeg.

I've been stuck on this for 2 days, how do i solve this?

You're looking for file_exists($full_path_to_file)

See file_exists

In your case

if(file_exists($mp3)) {
    //exec....
}

EDIT as per comment below:

Try to output all the lines

$output = [];
exec("/usr/include/ffmpeg -i $mp3 2>&1", $output);

var_dump($output);

I'd start by making sure that php can execute ffmpeg using shell_exec;

$out=shell_exec("/usr/include/ffmpeg 2>&1 1> /dev/null");
echo $out;

If you get a string like this

ffmpeg version N-81373-gf84cff8 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609 configuration: --prefix=/home/ben/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ben/ffmpeg_build/include --extra-ldflags=- ... (etc)

then you're in business. Next try to run it with your file:

$out=shell_exec("/usr/include/ffmpeg -i $mp3 2>&1 1> /dev/null");
echo $out;

and see if it's pulling info about your file:

...Duration: 00:00:06.01, start: 0.000000, bitrate: 2317 kb/s Stream #0:0(und): Video: h264...(etc)