Converting uploaded audio files to mp3 using PHP/ffmpeg - php

I have limited experience of using PHP, but having done some searching around it would seem that it is possible to convert audio files that are uploaded through a web page to mp3 using ffmpeg. The audio files would be uploaded using the Uploadify script to subfolders that are named according to the user's login.
I would need the PHP script to be able to process all audio files that are either not in MP3 format, or are in MP3 format but greater than 192kbps, deleting the original file after the conversion. Am I right in thinking that this could be achieved using PHP, and if so, can anyone get me started with some code, or a link to a webpage with some code?
Also, I am currently using Hostpapa for hosting my website, and I understand that they don't include ffmpeg, and also don't allow ssh. I read on one website that I could still install a compiled version of ffmpeg on a shared server, but I am not sure if this means that it would work on Hostpapa, or whether I would need to change my host to get ffmpeg working.
Any advice on any of this would be welcome!
Thanks,
Nick

You would basically run ffmpeg from PHP or use an PHP-API for ffmpeg like this.
If you cannot access the server via ssh and they do not have ffmpeg installed, it might be possible to use a precompiled binary, but you might also not be allowed to run commands from PHP or install software.

Your best bet is to contact the host. If they cannot support ffmpeg you will need a new host. When choosing the host, ask them before you sign up if they can support ffmpeg and provide you with SSH access or a jail shell.

You have to install FFMpeg in your server, so that everyone can make avail of it. If you are about to install in your local, it's quite doubtful that the process works finer or not. Instead, you can move with the hosting provider. Rely on the web hosting provider who can support FFMpeg and provide you with SSH access.

Related

Can you use php without downloading it?

I am trying to use php on my website but I am wondering if I could use it without downloading it. I've already surfed the internet for a answer, but none of them had a clear answer. Please help!
To start using PHP, you can:
Find a web host with PHP and MySQL support OR
Install a web server on your own PC, and then install PHP and MySQL
If your server has activated support for PHP you do not need to do anything.
Just create some .php files, place them in your web directory, and the server will automatically parse them for you.
You do not need to compile anything or install any extra tools.
Because PHP is free, most web hosts offer PHP support.
Source: https://www.w3schools.com/php/php_install.asp

Installing PDFTK on a shared web server

My web sites are hosted on Total Choice Hosting using some kind of Linux (I don't know what precise variety) and Apache. I don't have command line access - I can run command line programs only via exec() in PHP, or via CRON jobs.
Can I install and use PDFTK on a system like this?
If so, what exactly do I have to do? Which files do I have to copy where? Do I have to rebuild PDFTK from source, or is there an executable version somewhere?
Since (as I understand it) PDFTK is based on iText, which is written in Java. Maybe I'd be better off using the original iText package?
Or is there a better way of doing what I want to do (which is basically to merge and flatten a PDF file (blank form) with a FDF file (field values) into a new PDF file (the completed form) and download it to the user)? Is there some native PHP or Python or Perl code to do this?
Thanks - Rowan
A quick glance reveals that the PDFTK source is C++ and it looks like they use GCJ to compile some 3rd party Java code to native code. If you find a pre-built version of PDFTK that matches your OS and architecture you should be able to just upload the binary to your system and run it from PHP using exec. There are some builds available on the install page.
There are some native PHP libraries available for creating and manipulating PDFs. Check out TCPDF, Zend_Pdf, and FPDF to see if any of those are usable. Each one should support what you want to do, its just a matter of choosing the right solution.
Using PDFTK may be the fastest option since it is compiled code, but it is the least portable option since it would require the server have that software installed on it, where the PHP solutions could be distributed with your code.
If you are on a shared host you cant install PDFtk because you don't have access to root to install anything. You need to have a host that has it preinstalled. I use bluehost.com but there up-time is not the best. It works for now but I am going to move to another host once my site is complete. I have had several outages that have lasted for over a day.

How can I convert sound files into a different format using php on a windows server?

My server admin says that on a shared windows server, 'exec()' cannot be used. I would use the exec() function to run SoX CMD Commands. What is the alternative? Funny that they say SoX is installed, but how do I use that without exec()? What I want to implement is that when a user uploads a .mp3 file, it is converted to .wav on the server itself.
If you need CPU intensive stuff like audio re-encoding, I suggest you move off shared hosting, onto a VPS.

How can I install xpdf on a Godaddy Linux shared hosting server?

I'm having trouble determining if it's possible, based on the amount of access I have to my Godaddy server, to install XPDF. Could someone shed some light on this?
Here's the link to XPDF.
And here is info about the GoDaddy server.
My goal is to convert PDF's to Plain Text automatically using a PHP script on the server. So far, other solutions like code posted in the comments of the PHP website have been insufficient. All research seems to point to XPDF.
From the information you give, it sounds like it is a shared hosting solution you are using. Typically, you will not be able to install system software on a shared hosting account. I doubt that Go Daddy will install this for you.
You would need to use a hosting solution that includes this software, or rather use a VPS(virtual private server) or dedicated server. Then you will have root access and install any software you like. Unmanaged VPS are not expensive, but you need to take care of backups and software upgrades. If you do not want to manage your server, then maybe find a hosting solution that includes the PHP extension and software you need.
The page you reference does not give detailed information on PHP (phpinfo). With this information, it is possible to determine if you can perhaps do what you are trying to do without xpdf. There is also pdf2text, IIRC.
I installed xpdf and it was a snap. Just followed the instructions that came with the binary distribution then copy the file to the directory of your choice. You can use the php exec() command to do anything that you would with a shell account.

How to upload PHP and MySQL into a webserver

I am developing a site in vertigoserver. Now I need to test the webpage in webserver.
I am using the webserver Host-Europe VirtualServer 3.0.
Now what are the steps I need to upload the PHP pages?
What is the software needed to upload MySQL queries?
Are there any tutorials or suggestions?
This seems like basic stuff, but I'll give you some pointers!
Upload the pages with an FTP client or similar. If you have shell access, tools like rsync can make this easier.
You've probably got some sort of web based front end for MySQL like phpMyAdmin - this will let you upload and restore a database dump. If you have shell access, or if the MySQL server is open to the Internet, you can pipe the dump into the MySQL command line client, for example,
mysql -h<hostname> -u<username> -p<password> mydatabase < dump.mysql
Okay, you got a virtual machine and don't know how to upload stuff? This has been discussed in Host-Europe forums for a while. If you don't know the basics you probably don't want to run a server on your own. If you don't know how to use Linux don't start with a machine which can get you in a lot of trouble. A hosting package is probably better you at the moment.
The problem I have is you didn't specify what OS you have. If you're using Linux with Plesk you want to activate FTP, etc. If you are using Linux without Plesk you want to upload the PHP files with WinSCP and over SSH (SCP).
If you are running Windows with Plesk use FTP. If not, you should install an FTP server on the machine.
Regarding the MySQL stuff you're probably best off installing a webfrontend for MySQL.
!DON'T FORGET TO SECURE IT!

Categories