Download> Convert> Show with Flash

I want to convert and display a video uploaded by a user. I have a dedicated server and I am using php for programming. Where to begin? Thank you.

+2


source to share


2 answers


Perhaps it is, I would do this:

  • there is a PHP web page that adds a database entry to indicate that "this file needs to be processed" - this page is the one that receives the uploaded file
    • and displays a message to the user; something like "your file will be processed shortly"
  • In the CLI (since you have a dedicated server, you can use command line, install programs, ...), have a package that handles newly inserted files
    • first mark the entry as "processing"
    • do things of transformation; ffmpeg will probably be the right tool for this - I've seen quite a few posts on SO about this, so you can find some information about this part :-)
    • mark the file as "processed"
  • And, on some (other?) Web page, you can show the user what state his file is in:
    • if it hasn't been processed yet
    • if it is processed
    • or if it has been processed - you can give it a link to a new video file - or do what you need / need with it.


Here are some more notes:

  • On the day your application gets bigger, you can:
    • one "web server"
    • many "processing servers"; in your application, this is ffmpeg a thing that will consume a lot of CPU, not serving web pages; so being able to scale that part is good (this is another reason for "locking" files, labeling them as "processing" in the DB: this way you won't have multiple processing servers trying to process the same file).
  • You are only using PHP from the web server to create web pages, which is a web server error
    • Heavy / long processing is not the job of the web server!
    • The day you want to switch to something other than PHP for the "processing" part, it will be easier.


Your "processing script" should run every two minutes; you can use cron for this if you are on a Linux-like machine.


Of course, you can also call ffmpeg directly from the PHP page that the file is uploaded to ... But considering that this can take quite some CPU time, this may not always be the right solution ...

... even if it's a little simpler and will allow users to get the converted video faster (they won't have to wait for the cron job to complete)


(disclaimer: this answer is adapted from another one I made there )

+6


source


It's pretty easy. After downloading, you want to use exec()

to call the video converter. ffmpeg

- popular, free, open source.

In its simplest form:



exec('ffmpeg -i /path/to/video.avi /path/to/flash/video.flv');

+3


source







All Articles