MrFidge
MrFidge

Reputation: 2105

How to encode a video using PHP?

I'm interested in installing ffmpeg or somesuch on my server so I can upload files, automatically encode them to FLV and then serve up a embedded player to use on my pages.

The problem is that I don't know where to start. I don't want to have to spend days coding a web based encoding service, as I'm more interested in using an out of the box solution.

My research so far has led me to FFMPEG and possibly Gallery2: it has a ffmpeg integrated and the gallery 2 framework provides user accounts and FTP upload facilities.

Is anyone aware of other open source encoding solutions which you can install on Linux?

Upvotes: 0

Views: 7144

Answers (4)

raspi
raspi

Reputation: 6122

There is ffmpeg extension for PHP.

Upvotes: 1

Greg B
Greg B

Reputation: 14888

You should check out the docs for your chosen encoder, I have used ffmpeg successfully in the past. Then your workflow looks something like this.

  • Handle the file upload with PHP
  • Use exec() to shell out to your encoder and encode the video.
  • When exec() returns, you can then serve the video in your page

ffmpeg was really easy to get up and running with a couple of command line arguments.

Upvotes: 0

chrism1
chrism1

Reputation: 657

You could also have a look at VLC since it can transcode and act as a server for your FLV streams. The main application is a user interface to playback the video but it can be invoked from the command-line to do the serving - rather than playing.

Also there is libvlc which is the C library upon which VLC is written. VLC is based upon ffmpeg and might just make your life a little easier.

Upvotes: 0

Esteban Küber
Esteban Küber

Reputation: 36832

There is also memcoder, that does the same thing that ffmpeg does, but you will have to code the glue that binds ffmpeg/memcoder, PHP and the uploaded videos together.

The general workflow would be something like:

  • Present form to user with PHP
  • Upload file through post
  • Verify uploaded file is video both client and serverside
  • Store uploaded video in a known folder
  • From PHP, run a CLI command with all the desired parameters and store the file in another known location
  • Delete original file if success (optional)
  • Store in DB the path to the created file
  • Serve content
  • Profit!

Upvotes: 0

Related Questions