Upload Video by PHP (only one part)

4

I have some .MP4 files

When I want to display them, I create a html video tav and point to this mp4.

Sometimes I would like to broadcast only part of the video.

Ex: The video has 10min. But I want to display in the player only the 9th minute until the 10th. After that the video ends.

Is there any way I can do this via PHP? Upload only part of it?

    
asked by anonymous 02.05.2017 / 06:02

1 answer

3

One suggestion is to generate a new video containing just the snippet of interest.

In the example below we used ffmpeg :

// Tempo em segundos
$ini = 540; // início (9 minutos)
$end = 600; // fim (10 minutos)

$original_file = '/local/arquivo/video.mp4';
$new_file = '/local/arquivo/video_short.mp4';

// Local do ffmpeg
$lib_path = '/usr/bin/ffmpeg';

// Formatando o comando
$cmd = $lib_path.' -i '.$original_file.' 
-ss '.$ini.' 
-t '.$end.'
 '.$new_file;

// Executa o comando
exec($cmd);
    
02.05.2017 / 08:43