How to convert video with php without using ffmpeg?

Asked

Viewed 1,336 times

2

I was wondering if there is any way to convert videos in PHP without using ffmpeg, because my hosting doesn’t allow you to install anything.

If you can’t, someone knows of an API that can convert videos and audios for free. Something like

http://[host da api]/convert?target=[url para arquivo]&output=[nome do arquivo saída]

This by GET or by POST with AJAX or Curl.

  • Does your server not allow installing ffmpeg? Because if you do not allow it then you will hardly be able to use any alternative. How about going up to Youtube and using the API to grab the video feed and put in a custom player?

  • My server does not accept installing ffmpeg either through sources. The idea is to get rid of the video, I only want audio from it. The general idea is to extract the video from youtube which is ok on the local and remote server, and then grab the video and convert it to mp3. Some sites already do this, for example http://tubget.com/.

  • Unfortunately I don’t know any such service, I will edit the question why your problem is specific to audio. Questions should always be as objective as possible.

  • 1

    We are discussing this question and answer on META: Questions which the answer are third party software are in scope?

1 answer

6


Researching the only one I found that seems satisfactory was http://www.online-convert.com, follows links:

Brief documentation:

PHP:

Java

Limitations of the free version

  • Maximum limit of 30 conversions per day (every 24 hours)
  • Maximum upload limit per file is 100 Megabytes

(Really for something free it surprised me)

How to use

The process is done by REST using a JSON thus:

POST /jobs HTTP/1.1
Host: https://api2.online-convert.com
X-Oc-Api-Key: <sua chave da API key deve vir aqui>
Content-Type: application/json

{
    "input": [{
        "type": "remote",
        "source": "http:\/\/site\/arquivo"
    }],
    "conversion": [{
        "target": "wav"
    }]
}

Change <sua chave da API key deve vir aqui> by your access key (it is necessary to register in http://www.online-convert.com)

If you want to use PHP-ready classes do so (using onlineconvert-api-sdk-php):

<?php
define('API_KEY', 'sua chave da API key deve vir aqui');

require 'vendor/autoload.php';

$config = new \OnlineConvert\Configuration();
$config->setApiKey('main', API_KEY);
$client = new \OnlineConvert\Client\OnlineConvertClient($config, 'main');
$syncApi = new \OnlineConvert\Api($client);

The example is Sync, but it can also be async:

$asyncApi = new \OnlineConvert\Api($client, true);

Note that it uses autoload as the installation is done by composer, that is if you want to do "manually" it will be a little difficult because it is necessary to study and understand the composer and the autoload.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.