Problem with files consists of spaces and single quotes?

Posted by Vijay on Stack Overflow See other posts from Stack Overflow or by Vijay
Published on 2010-03-22T09:47:08Z Indexed on 2010/03/22 9:51 UTC
Read the original article Hit count: 272

Filed under:
|
|

I'using the following code to create thumbnails using ffmpeg but it was working fine for the files which have no spaces or any quotes..

But when the file has a space (like 'sachin knock.flv') or files which have quotes (like sachin's_double_cent.mp4) it doesn't work..

What can i do to get those files work accurately? One restriction is that i can't rename files as they are lump some..

My code is

<?php
    error_reporting(E_ALL);
    extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
    $link = mysql_connect('localhost', 'root', '');
    if (!$link) {
        die('Not connected : ' . mysql_error());
    }
    $db_selected = mysql_select_db('db', $link);

    $max_width  = 120;
    $max_height = 72;
    $path ="/home/rootuser/public_html/temp/";
    $qry="select id, input_file, output_file from videos where thumbnail='' or thumbnail is null;";
    $res=mysql_query($qry);
    while($row = mysql_fetch_array($res,MYSQL_ASSOC))
    {
        $orig_str = array(" ");
        $rep_str  = array("\ ");
        $outfile  = $row[output_file];
//      $infile   = $row[input_file];
        $infile1  = str_replace($orig_str, $rep_str, $outfile);

        $tmp      = explode(".",$infile1);
        $tmp_name = $tmp[0];
        $imgname  = $tmp_name.".png";
        $srcfile  = "/home/rootuser/public_html/uploaded_vids/".$outfile;
            echo exec("ffmpeg -i ".$srcfile." -r 1 -ss 00:00:05 -f image2 -s 120x72 ".$path.$imgname);
        $nname = "./temp/".$imgname;
        $fileo = fopen($nname,"rb");
        if($fileo)
        {
        $imgData = addslashes(file_get_contents($nname));
        echo $imgdata;
        $qryy="update videos set thumbnail='{$imgData}' where input_file='$outfile'"; 
        $ress=mysql_query($qryy);
        }
        else
            echo "Could not open<br><br>";
        unlink('$nname');    
    }
?>

© Stack Overflow or respective owner

Related posts about ffmpeg

  • how to install ffmpeg in cpanel

    as seen on Super User - Search for 'Super User'
    i'm using dedicated server(linux) so i need to install ffmpeg in cpanel so here ffmpeg i found in Main Software Install a Perl Module but i writing script in php so how can i install ffmpeg phpperl when i'am trying to install ffmpeg in perl module i get this response Checking C compiler… >>> More

  • FFMpeg-PHP Installation Error

    as seen on Server Fault - Search for 'Server Fault'
    While installing FFmpeg-PHP, I got this interesting error: /usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c: In function 'zim_ffmpeg_movie_getAudioStreamId': /usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1051: error: 'CODEC_TYPE_AUDIO' undeclared (first use in this function) /usr/downloads/ffmpeg-php-0… >>> More

  • git problems installing stuff [closed]

    as seen on Super User - Search for 'Super User'
    root@Frenzen:~# cd root@Frenzen:~# git clone --depth 1 git://source.ffmpeg.org/ffmpeg Initialized empty Git repository in /root/ffmpeg/.git/ root@Frenzen:~# cd root@Frenzen:~# git clone --depth 1 git://source.ffmpeg.org/ffmpeg Initialized empty Git repository in /root/ffmpeg/.git/ root@Frenzen:~#… >>> More

  • Unable to install ffmpeg-php

    as seen on Server Fault - Search for 'Server Fault'
    I followed the instructions on http://www.mysql-apache-php.com/ffmpeg-install.htm but ffmpeg-php does not show up in my phpinfo() The commands I ran (in order) #yum install ffmpeg ffmpeg-devel ... Public key for faac-1.26-1.el5.rf.x86_64.rpm is not installed #rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0… >>> More

  • Unable to install ffmpeg-php

    as seen on Server Fault - Search for 'Server Fault'
    Hi, I followed the instructions on http://www.mysql-apache-php.com/ffmpeg-install.htm but ffmpeg-php does not show up in my phpinfo() The commands I ran (in order) #yum install ffmpeg ffmpeg-devel ... Public key for faac-1.26-1.el5.rf.x86_64.rpm is not installed #rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0… >>> More

Related posts about files