tags:

views:

37

answers:

2

i have lots of videos in my server and i use the following code to get the duration of the video and it works fine..

        ob_start();
        passthru("ffmpeg -i ".$srcfile." 2>&1");
        $duration = ob_get_contents();
        ob_end_clean();

But i could not get the duration for the files which has a space or any special characters like ( ' # % etc...

I cant rename the files as it is stored already and the names of those files are also stored in db and it would take a toll to change all in a live site..

So is there any method for accessing/reading the files with special characters?

+3  A: 

escapeshellarg

Incidentally, you should always use this for any shell arguments, less you want to make your application open to shell injection-attacks, which could be very dangerous.

troelskn
A: 

Quote the filename between single quotes:

    passthru("ffmpeg -i '".$srcfile."' 2>&1");
Sjoerd
Bad idea. What if $srcfile contains a single quote character?
telent