need help for FFMPEG

Started on the old forum in January 2013 · view the original in the archive · old links redirect here

#ffmpeg #preview-of-videos

3 replies · 5,317 views · started 13 years ago · 1 min read

3 participants
cottonmouth Junior · 24 posts #1

i use this code for getting preview of videos in a directory/folder..but i m getting error

<?php
$dir = "/full path to directory/";
$thumb_dir = "/full path to directory for thumbnails/";
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
$file=str_replace(" ", "\ ", $file);
$file=str_replace("-", "\-", $file);
$file=str_replace("(", "\(", $file);
$file=str_replace(")", "\)", $file);
echo $file."<br/>";
//$file=str_replace("'", "\ ", $file);
            $ext = strtolower(end(explode('.', $file)));
            if($ext=='mp4')
               exec("/usr/local/bin/ffmpeg -itsoffset -105 -i ".$dir.$file."  -vcodec mjpeg -vframes 1 -an -f rawvideo -s 100x100 ".$thumb_dir.$file.".jpg");
        }
        closedir($dh);
    }
}
?>

error i m getting

Strict Standards: Only variables should be passed by reference in H:\xampp\htdocs\ffmpeg.php on line 13 ..

Strict Standards: Only variables should be passed by reference in H:\xampp\htdocs\ffmpeg.php on line 13

pls help....i want to generate thumbnails from videos with same name..i.e girl.mp4 to girl.mp4.jpg

kevk3v Senior · 332 posts #2
<?php
$dir = "/full path to directory/";
$thumb_dir = "/full path to directory for thumbnails/";
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
$file=str_replace(" ", "\ ", $file);
$file=str_replace("-", "\-", $file);
$file=str_replace("(", "\(", $file);
$file=str_replace(")", "\)", $file);
echo $file."<br/>";
//$file=str_replace("'", "\ ", $file);

            $ext = end(explode('.', $file));
            $ext = strtolower($ext);
///the problem was right at the top of this
            if($ext=='mp4')
               exec("/usr/local/bin/ffmpeg -itsoffset -105 -i ".$dir.$file."  -vcodec mjpeg -vframes 1 -an -f rawvideo -s 100x100 ".$thumb_dir.$file.".jpg");
        }
        closedir($dh);
    }
}
?>

Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

cottonmouth Junior · 24 posts #3

thanks bro but still m getting same error!!

s3nzo Developer · 156 posts #4

I'm not sure what you are trying to achieve by this line

$file=str_replace("'", "\ ", $file);

But the backslash escapes the double quotes. That line should be

$file=str_replace("'", "\"", $file);

or maybe

$file=str_replace("'", " ", $file);

depending on what you want to replace with

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close