Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
musica_listas_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cristian Mauricio Diaz Canales
musica_listas_backend
Commits
a326f0ff
Commit
a326f0ff
authored
Aug 14, 2019
by
Cristian Mauricio Diaz Canales
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prueba command conversion 1
parent
c4f49b42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
src/Command/BackendPrepararVideoCommand.php
src/Command/BackendPrepararVideoCommand.php
+88
-0
No files found.
src/Command/BackendPrepararVideoCommand.php
0 → 100644
View file @
a326f0ff
<?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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment