Question

I am making a page that transcodes videoes to different formats. My problem is that I want to skip transcoding mp4 files to mp4. So I have exploded the file extension and that works nicely. I am renaming the files I transcode with an added parameter - the file extension of the original. However when I try to create an if test like under it won't fire.

if ($format != "mp4")
{
  transcodeToMp4($file, $format);
}

This won't work. So I've been search for alternative ways of solving this:

if (strpos($format, "mp4") === FALSE) 
{
  transcodeToMp4($file, $format);
}

Anyone have any idea why this won't fire? I get the correct string for the extension in the filename though.

$format = strtolower(end(explode(".",$file)));
Était-ce utile?

La solution

Better use pathinfo to get the extension:

if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) != 'mp4') {
    transcodeToMp4($file);
}

Autres conseils

Try to use this function strstr($format, "mp4")

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top