Krzysztof Ożóg Example processing command

Created by Krzysztof Ożóg

class ProcessVideoQueueCommand extends ContainerAwareCommand

    protected $videoManager = null;
    protected $em = null;
    protected $videoRepository = null;
    protected $ffmpeg = null;

    protected function configure()
            ->setDescription('Run queue of video encoding')

    protected function execute(InputInterface $input, OutputInterface $output)
        $container = $this->getContainer();

        $this->videoManager = $container->get('VideoManager');
        $this->em = $container->get('doctrine.orm.entity_manager');
        $this->videoRepository = $this->em->getRepository('AppBundle:Video');
        $logger = $container->get('logger');

        $ffmprobe = FFMPEG/FFProbe::create()
        $this->ffmpeg =FFMPEG/FFMpeg::create();

        $videos = $this->videoRepository->getPendingVideos();

        $logger->info('Number of VIDEOS TO PROCCESS: '.count($videos));

        foreach ($videos as $video) {

    protected function encode($video)
        $container = $this->getContainer();
        $logger = $container->get('logger');
        $logger->info('Proccessing video: '.$video->getId());

        $video->setEncodingStarted(new \DateTime());

        $x264Format = new FFMpeg\Format\Video\X264();

        $formats = array($x264Format);

        try {

            // MP4
            $current = null;

            foreach ($formats as $format) {

                $current = $format;


            $video->setUpdated(new \DateTime('now'));
            $video->setEncodingFinished(new \DateTime('now'));

        } catch (\FFMpeg\Exception\RuntimeException $e) {

            $logger->info('MSG: '.$e->getMessage());

                'Format failed: '.get_class($current)


Comments (1)

  1. Zafer özkel

    O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O. O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O. O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O .O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O. O.O.O.O.O.O.O.O.O  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P


You can clone a snippet to your computer for local editing. Learn more.