hello all i have successfully installed ffmpeg to my computer i can check it by checking ffmpeg-version it returns something logical.
which means the ffmpeg is running successfully on my pac but when i run this code by php i get error in ffmpeg loading
<?php
extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
// Determine the full path for our video
$vid = realpath('./test/Sample.mp4');
// Create the ffmpeg instance and then display the information about the video clip.
$ffmpegInstance = new ffmpeg_movie($vid);
echo "getDuration: " . $ffmpegInstance->getDuration() . "<br />".
"getFrameCount: " . $ffmpegInstance->getFrameCount() . "<br />".
"getFrameRate: " . $ffmpegInstance->getFrameRate() . "<br />".
"getFilename: " . $ffmpegInstance->getFilename() . "<br />".
"getComment: " . $ffmpegInstance->getComment() . "<br />".
"getTitle: " . $ffmpegInstance->getTitle() . "<br />".
"getAuthor: " . $ffmpegInstance->getAuthor() . "<br />".
"getCopyright: " . $ffmpegInstance->getCopyright() . "<br />".
"getArtist: " . $ffmpegInstance->getArtist() . "<br />".
"getGenre: " . $ffmpegInstance->getGenre() . "<br />".
"getTrackNumber: " . $ffmpegInstance->getTrackNumber() . "<br />".
"getYear: " . $ffmpegInstance->getYear() . "<br />".
"getFrameHeight: " . $ffmpegInstance->getFrameHeight() . "<br />".
"getAudioChannels: " . $ffmpegInstance->getAudioChannels() . "<br />".
"hasAudio: " . $ffmpegInstance->hasAudio();
?>
please tell me where i am doing wrong
looks like ffmpeg-php module is not installed
Related
I am using wamp and 5.5.12 php version
Download php_ffmpeg.dll from somewhere and copied in C:\wamp\bin\php\php5.5.12\ext
restarted wamp and computer as well.
but it says php_ffmpeg.dll is missing any help ?
I am using 64bit system any offical place to look for php_ffmpeg.dll 64bit version
?
the code:
/**
* FFMPEG-PHP Test Script
*
*/
echo "GD: ", extension_loaded('gd') ? 'OK' : 'MISSING', '<br>';
echo "XML: ", extension_loaded('xml') ? 'OK' : 'MISSING', '<br>';
echo "zip: ", extension_loaded('zip') ? 'OK' : 'MISSING', '<br>';
echo "ffmpeg: ", extension_loaded('ffmpeg') ? 'OK' : 'MISSING', '<br>';
// Check if the ffmpeg-php extension is loaded first
// extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
// Determine the full path for our video
// $vid = realpath('./vid2.avi');
$vid = realpath('input.flv');
// d then display the information about the video clip.
$ffmpegInstance = new ffmpeg_movie($vid);
echo "getDuration: " . $ffmpegInstance->getDuration() . "<br />".
"getFrameCount: " . $ffmpegInstance->getFrameCount() . "<br />".
"getFrameRate: " . $ffmpegInstance->getFrameRate() . "<br />".
"getFilename: " . $ffmpegInstance->getFilename() . "<br />".
"getComment: " . $ffmpegInstance->getComment() . "<br />".
"getTitle: " . $ffmpegInstance->getTitle() . "<br />".
"getAuthor: " . $ffmpegInstance->getAuthor() . "<br />".
"getCopyright: " . $ffmpegInstance->getCopyright() . "<br />".
"hasAudio: " . $ffmpegInstance->hasAudio();
Putting a compiled PHP extension in the extension directory is not sufficient. Additionally, the extension has to be declared in php.ini extension directive, e.g. extension=php_ffmpeg.dll.
I am using 64bit system any offical place to look for php_ffmpeg.dll 64bit version ?
There is http://ffmpeg-php.sourceforge.net/, but this project is abandoned, so you're probably out of luck. See https://trac.ffmpeg.org/wiki/PHP for alternative ways to use ffmepg from PHP.
I am trying to connect to MikroTik RouterOS through External Remote IP but I am not able to connect as I can see that I can successfully connect to API through Localhost but can't connect through my hosted file at my site..!
Here is link to file :
http://huntedhunter.com/router-api/examples/example1.php
Besides strange thing is that 8728 port is open on my IP and still it's not connecting...!
I am using this API to connect :
https://github.com/BenMenking/routeros-api
<pre>
<?php
require('../routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = true;
if ($API->connect('39.33.4.164', 'test', 'test')) {
$ARRAY = $API->comm("/system/resource/print");
$first = $ARRAY['0'];
$memperc = ($first['free-memory']/$first['total-memory']);
$hddperc = ($first['free-hdd-space']/$first['total-hdd-space']);
$mem = ($memperc*100);
$hdd = ($hddperc*100);
echo "Mikrotik RouterOs 4.16 Resources";
echo "<br />";
echo "<table width=550 border=0 align=center>";
echo "<tr><td>Platform, board name and Ros version is:</td><td>" . $first['platform'] . " - " . $first['board-name'] . " - " . $first['version'] . " - " . $first['architecture-name'] . "</td></tr><br />";
echo "<tr><td>Cpu and available cores:</td><td>" . $first['cpu'] . " at " . $first['cpu-frequency'] . " Mhz with " . $first['cpu-count'] . " core(s) " . "</td></tr><br />";
echo "<tr><td>Uptime is:</td><td>" . $first['uptime'] . " (hh/mm/ss)" . "</td></tr><br />";
echo "<tr><td>Cpu Load is:</td><td>" . $first['cpu-load'] . " %" . "</td></tr><br />";
echo "<tr><td>Total,free memory and memory % is:</td><td>" . $first['total-memory'] . "Kb - " . $first['free-memory'] . "Kb - " . number_format($mem,3) . "% </td></tr><br />";
echo "<tr><td>Total,free disk and disk % is:</td><td>" . $first['total-hdd-space'] . "Kb - " . $first['free-hdd-space'] . "Kb - " . number_format($hdd,3) . "% </td></tr><br />";
echo "<tr><td>Sectors (write,since reboot,bad blocks):</td><td>" . $first['write-sect-total'] . " - " . $first['write-sect-since-reboot'] . " - " . $first['bad-blocks'] . "% </td></tr><br />";
echo "</table>";
echo "<br />";
echo "<br />";
echo "<br />";
echo "<br />Debug:";
echo "<br />";
$API->disconnect();
}
?>
</pre>
First check if api service is enabled in routeros
[admin#mikrotik] > /ip service print
Flags: X - disabled, I - invalid
# NAME PORT ADDRESS CERTIFICATE
0 XI telnet 23
1 XI ftp 21
2 XI www 8989
3 ssh 22
4 XI www-ssl 443 none
5 XI api 8728
6 winbox 8291
7 XI api-ssl 8729 none
XI flag near service name - the service is desabled
Second check your firewall filter table. Chain "input"
You need allow input access to api service port. Api service port you can check at first point in this answer
The problem is simple. Running a php file in browser vs command line produces very different results and I can't for the life of me figure out why. Any php/psexec experts out there run into this before?
<?php
echo '<pre>';
$output = shell_exec("psexec -accepteula \\\mypcname -u mypcname\\accountname -p xxxxxxx ipconfig /all 2>&1");
var_dump($output);
echo '</pre>';
Produces this output in a browser window...
string(350) "
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
Windows IP Configuration
Connecting to admin-pc...
Starting PSEXESVC service on admin-pc...
Connecting with PsExec service on admin-pc...
Starting ipconfig on admin-pc...
ipconfig exited on admin-pc with error code 0.
Instead of this, which is the output I get when running the same php file via command line.
C:\MAMP\bin\php\php5.5.12>php-cgi c:\mamp\htdocs\go.php
X-Powered-By: PHP/5.5.12
Content-type: text/html
hi<pre>string(5113) "
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
Windows IP Configuration
Host Name . . . . . . . . . . . . : mypcname
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : home
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : home
Description . . . . . . . . . . . : Intel(R) 82567LM-2 Gigabit Network Connec
tion
Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.1.4(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Thursday, October 09, 2014 4:36:43 PM
Lease Expires . . . . . . . . . . : Tuesday, October 14, 2014 4:16:04 PM
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DNS Servers . . . . . . . . . . . : 8.8.8.8
8.8.4.4
NetBIOS over Tcpip. . . . . . . . : Enabled
"
</pre>
C:\MAMP\bin\php\php5.5.12>
I have a script in php that is used to upload files to a server. It was working first but i dont know why its not working again. It shows no error but the file is not still uploaded to the directory that i assigned to hold all uploaded files. Here is the part that takes care of the upload:
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Uploaded: " . basename($_FILES["file"]["name"]) . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
//by default the size of the file is in bytes so u need to divide by 1024 in order to bring it to KB
echo "Temporarily stored in: " . $_FILES["file"]["tmp_name"] . "<br />";
$target="/file/" . basename($_FILES["file"]["name"]) . "<br />";
}
if(move_uploaded_file($_FILES["file"]["tmp_name"], $target))
{
echo "<h2>" . "The file has been stored on the server" . "<br />" . "<h2 />";
echo "New storage location is : " . '<a href="/public/files/" >' . $target . '</a>';
?>
<html>
<body>
<div align="right"><a href="/public/files/" >Uploaded files</a></div>
<br />
</body>
</html>
<?php
}
else
{
echo "<h2>" . "Error while saving the file to the server." . "<br />" . "File wont be found in the uploaded files directory" . "<br />" . "<h2 />";
echo "The error says: " . $_FILE["file"]["error"] . " What do we do now?" ;
echo"<pre>".print_r($_FILES,true)."</pre>";
?>
<?
/file/ is a directory in the root of your server's filesystem, which almost certainly doesn't exist. move_uploaded_file() works at the filesystem level and has absolutely NO awareness of your site's URI structure. You probably want something more like:
move_uploaded_file(...,. $_SERVER['DOCUMENT_ROOT'] . '/file/');
^^^^^^^^^^^^^^^^^^^^^^^^^^^---- add this
so that the file gets moved to a /file subdir of your site's root directory.
I have a MySQL db with a table, that has the following field:
txtProductBowlImage: example " C:\BowlPhotos\Thumbs\MapleTi07-030tmb.jpg"
I want to use the data in that field to produce an image that I can print to a text file.
I read the data then try to echo it to the screen...and I see a small icon, but no image.
Here's the code:
<?php
$con = mysql_connect("localhost","xxxxxxx","zzzzzzzzzzzzzzz");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("scwdb", $con);
$result = mysql_query("SELECT * FROM tblsplintersbowlinventory WHERE txtVenue = 'Shoreline'");
while($row = mysql_fetch_array($result))
{
echo $row['intProductID'] . " " . $row['txtProductBowlCode'] . " " . $row['txtProductBowlImage'] . "]";
echo "<br />";
echo "<br />";
echo 'txtProductBowlImage: ' . $row['txtProductBowlImage'];
echo "<br />";
$img = $row['txtProductBowlImage'];
echo '...............$img: ' . $img;
echo "<br />";
echo "<img src=" . $img . ">";
echo "<img src='C://BowlPhotos//Thumbs//Ash07-013_btmb.jpg'>";
echo "<img src='Ash07-013_btmb.jpg'>";
echo "<br />";
echo "==================";
echo "<br />";
}
mysql_close($con);
?>
Note that I try 3 times to show an image:
1: using the url from the db and putting it in an echo statement
this url uses the '\' separater in the data.
2: imbedding a sample of the actual text path and filename in an echo statement
this url uses the '/' separater in the url.
3: imbedding only the filename, no path, in an echo statement
When I run this, I get the following output:
Echo #1 & #2 produce the icon, echo #3 shows a local copy of the image in the same folder as the php.
From this it appears that it is the path that is not being used, either with the '\' or '/' separater.
I assume the '\' may be seen as an escape, but why doesn't the url with the '/' work?
All below is wrong seeing as "Linking to local resources is disabled in all modern browsers due to security restrictions"
To link to a local image you use the format
<img src='file:///C:/path/to/image/pic.jpg'>
You can replace the backslashes with forward slashes using
$img = str_replace('\\', '/', $row['txtProductBowlImage']);
Now you can add the file:/// and the single quotes around the path
like so
echo "<img src='file:///" . $img . "'>";
With double quotes you could skip the dot operator to append strings
and use
echo "<img src='file:///$img'>";
The dollar $img will be recognized as a variable
It seams your trying to get a file from your local computer. So you have to run a webserver that hadle php
You might be trying to read an image where the server dont have acess.
try to place the file with your html or php file
OK, with JonOsterman's greatly appreciated aid, the final working code is:
<?php
$con = mysql_connect("localhost","root","Madge1938");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("scwdb", $con);
$result = mysql_query("SELECT * FROM tblsplintersbowlinventory WHERE txtVenue = 'Shoreline'");
while($row = mysql_fetch_array($result))
{
echo $row;
echo "<span>" . $row['intProductID'] . " " . $row['txtProductBowlCode'] . " " . $row['txtProductBowlImage'] . "</span>";
echo "<br />";
$img = $row['txtProductBowlImage'];
echo "<span> Original img: " . $img . " </span>";
$img = str_replace('\\', '/', $img);
echo "<br />";
$img = str_replace('C:/BowlPhotos/Thumbs/', 'Thumbs/', $img);
echo "<span>Folder img: " . $img . " </span>";
echo '<img src="' . $img . '">';
echo "<br />";
$img = str_replace('Thumbs/', '', $img);
echo "<span>Local img: " . $img . " </span>";
echo '<img src="' . $img . '">';
echo "<br />";
echo "<span>done</span><br />";
}
mysql_close($con);
?
There were a number of changes, but the biggest surprise was that the php could not open a folder not in the same folder or a sub folder of the php file! When I moved the entire folder to a sub of the php folder, the code above runs!
Also, as seen above, the HTML does not need a "file:///" for a local file...
And I should mention, this is intended to run only on my local server - not on the web. It is just for my own use to keep track of the wood bowls I make and sell.
Again, many thanks to Jon...