prueba command conversion 1

parent c4f49b42
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use App\Entity\PluCancion;
use App\Entity\Audio;
use App\Entity\Album;
use App\Entity\Contenido;
use App\Utilities\Utiles;
class BackendPrepararVideoCommand extends Command {
protected static $defaultName = 'app:preparar-video';
const EXECUTION_TIME = 10; //Minutos
const DELAY_TIME = 2; // Minutos
private $em;
public function __construct($name = null, EntityManagerInterface $em) {
parent::__construct($name);
$this->em = $em;
}
protected function configure() {
$this
->setDescription('Comando de ejemplo que sirve para generar los archivos de un video')
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
$log = Utiles::setLog('App\Command::BackendPrepararVideoCommand', 'command/prepararVideo');
$io = new SymfonyStyle($input, $output);
$log->debug("Iniciando ejecucion de command BackendPrepararVideoCommand... ");
$executionTime = self::EXECUTION_TIME;
$executionClientTimeout = self::DELAY_TIME;
$outputMp4ToM3u8 = array();
$salidaMp4ToM3u8 = "";
$servidor = "/opt/sdp/hitsahora/www/web/uploads/contenidos";
$rutaPublica = Utiles::getPublicRoot() . "/videos";
$inicio = time();
$fin = $inicio + ($executionTime * 60) - ($executionClientTimeout * 60);
$io->warning('El comando inicio en la fecha y hora: ' . date('d/m/Y H:i:s', $inicio));
$io->warning('El comando debe terminar antes de la fecha y hora: ' . date('d/m/Y H:i:s', $fin));
$log->debug('El comando inicio en la fecha y hora: ' . date('d/m/Y H:i:s', $inicio));
$log->debug('El comando debe terminar antes de la fecha y hora: ' . date('d/m/Y H:i:s', $fin));
while ($inicio < $fin) {
//ruta de prueba con archivo mp4
$servidor = "/opt/sdp/hitsahora/www/web/uploads/contenidos/6/video/2016/42/video_92040.mp4";
$io->success("Procesando Video....");
$rutaArchivoVideoOriginal = "$servidor/";
$rutaArchivoVideoM3u8 = "$rutaPublica/0/video.m3u8";
if (!file_exists("$rutaPublica/0")) {
mkdir("$rutaPublica/0", 0777, true);
}
$argumentMp4ToM3u8 = "-y -i $rutaArchivoVideoOriginal -profile:v baseline -level 3.0 -s 1920x1080 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls $rutaArchivoVideoM3u8";
//ejecucion programa con ruta del padre
//conversion mp4 -> m3u8
exec("/opt/ffmpeg-listas/ffmpeg-3.3.4-64bit-static/ffmpeg $argumentMp4ToM3u8", $outputMp4ToM3u8, $salidaMp4ToM3u8);
if ($salidaMp4ToM3u8 == 0) {
$log->debug("se ha creado el archivo M3U8 en la ruta $rutaArchivoVideoM3u8");
} else {
$log->debug("error al crear el archivo M3U8 en la ruta $rutaArchivoVideoM3u8");
$this->rollback("$rutaPublica/0");
usleep(1000000);
}
$inicio = time();
}
$log->debug("Finalizando ejecucion de command BackendPrepararVideoCommand ... ");
$io->success('COMANDO PREPARACION VIDEOS EJECUTADO');
}
private function rollback($dir) {
array_map('unlink', glob("$dir/*.*"));
rmdir($dir);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment