Dienstag, 21. Oktober 2014

FFmpeg Build Script

After searching the whole internet for a Mac OSX binary built of ffmpeg with non free codecs included i finally gave up and wrote my own building script.

Since I wanted a statically compiled binary which also can be used on devices without Xcode installed, homebrew was not the perfect solution for me.

I started from scratch building a script that automatically downloads all dependencies and compiles all necessary libraries.

My final script can be found on github: https://github.com/markus-perl/ffmpeg-build-script

Samstag, 11. Oktober 2014

PHP CSV detect delimiter

/**
 * @param string $csvFile Path to CSV file
 * @return string
 */
public function detectDelimiter($csvFile)
{
        $delimiters = array(
            ';' => 0,
            ',' => 0,
            "\t" => 0,
            "|" => 0
        );

        $handle = fopen($csvFile, "r");
        $firstLine = fgets($handle);
        fclose($handle);

        foreach ($delimiters as $delimiter => &$count) {
            $count = count(str_getcsv($firstLine, $delimiter));
        }

        return array_search(max($delimiters), $delimiters);
}