YouTube video to MP3 converter

Good afternoon. My question is how to implement “online youtube to mp3 converter” using php?


Answer 1, authority 100%

It’s usually done like this.
In php / python (another favorite language), a shell is written for uploading files. After uploading the file to the server, a special program on the server starts its conversion. And when the conversion is completed, the script shows a link to the download.

For conversions, ffmpeg is usually used, which is available in the repositories of almost every distribution. But you may have to build it yourself for best performance.

Here’s a starter example of how to extract the audio track:

ffmpeg -i vid.flv -acodec copy output.mp3

Why isn’t the script doing the conversion itself? but because scripts for the web should not work long and hard. And by default, Apache limits the script to 30 seconds.

General scheme of the system.
The user selected a file and uploaded it to the server. The script copied it to the directory for transformations. And also added a record to the database that such and such a file is assigned to such and such a user (you can use sessions or user registration).

The special program will be somewhere like this:

:
    ,     
     ,       
    :
          
           " "
         ffmpeg  .
           
             
                " "     
        :
               " "
          
        

After adding a file for processing, the web part simply starts updating the page with an interval of several seconds / minutes (here you need to pick it up), checks the status in the database and shows progress.