Recherche avancée

Médias (0)

Mot : - Tags -/metadatas

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (47)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (9023)

  • How to upload object to a bucket in Google Cloud Platform from Python script

    7 juillet 2016, par Bryan

    The goal of this script is to extract audio from a video file using ffmpeg and upload it into a bucket on Google Cloud Platform each time it is called. Eventually I will have to extract audio from a large list of videos, so ideally I would want my script to extract and subsequently upload it into the cloud.

    My confusion is how to use GCP API to upload my object into a bucket. Any advice would be greatly appreciated !

    Link for reference : https://cloud.google.com/storage/docs/json_api/v1/json-api-python-samples#setup-code

    import subprocess
    import sys
    import re

    fullVideo = sys.argv[1]
    title = re.findall('^([^.]*).*', fullVideo)
    title = str(title[0])
    subprocess.call('ffmpeg -i ' + fullVideo + ' -vn -ab 128k ' + title + '.flac', shell = True)

    def upload_object(bucket, filename, readers, owners):
       service = create_service()

       # This is the request body as specified:
       # http://g.co/cloud/storage/docs/json_api/v1/objects/insert#request
       body = {
           'name': filename,
       }

       # If specified, create the access control objects and add them to the
       # request body
       if readers or owners:
           body['acl'] = []

       for r in readers:
           body['acl'].append({
               'entity': 'user-%s' % r,
               'role': 'READER',
               'email': r
           })
       for o in owners:
           body['acl'].append({
               'entity': 'user-%s' % o,
               'role': 'OWNER',
               'email': o
           })

       # Now insert them into the specified bucket as a media insertion.
       # http://g.co/dev/resources/api-libraries/documentation/storage/v1/python/latest/storage_v1.objects.html#insert
       with open(filename, 'rb') as f:
           req = service.objects().insert(
               bucket=bucket, body=body,
               # You can also just set media_body=filename, but # for the sake of
               # demonstration, pass in the more generic file handle, which could
               # very well be a StringIO or similar.
               media_body=http.MediaIoBaseUpload(f, 'application/octet-stream'))
           resp = req.execute()

       return resp
  • Launch Symfony 4 command from controller works on dev but not in prod environment

    14 août 2019, par JoakDA

    When an application loads, I make 2 AJAX request to start 2 proccess needed for showing a RTSP video streaming on the website.

    It is working great in DEV environment but making some tests in PROD, it only works if the page is loaded on the server webbrowser (same host where the application is installed).

    If I use an external browser installed on another machine, it doesn’t launch the video.

    If I use an external browser installed on another machine, it doesn’t launch the video.

    /**
    * Start transcoding video.
    * @param Request $request
    * @return Response
    * @Route("devices/show/videotranscoding", name="start_video_transcoding", methods={"POST"})
    * @IsGranted("ROLE_OPERATOR")
    */
    public function startTranscodingVideo(Request $request)
    {
       $value = '';
       try {
           //Setup needed variables
           $this->initialize();

           $this->logger->info('Start Video transcoding: Ok. Video started successfully');

           //Get device id from POST data
           $deviceid = $request->request->get('deviceid');

           //Find device to show from system
           $deviceToShow = $this->repository->find($deviceid);

           if ($deviceToShow) {
               $this->logger->info('Start Video transcoding: . Device has been found. Delete it... Data: ' . $deviceToShow->__toString());

               $realHost = $this->getRealHost($_SERVER['HTTP_HOST']);

               $tcpHost = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$realHost}";

               //Launch transcoding command
               $transcodingCommand = 'php ' . $this->getParameter('kernel.project_dir') . '/bin/console device:videotranscoding ' .
                   'rtsp://' . $deviceToShow->getUsername() . ':' . $deviceToShow->getPassword() . '@' . str_replace('http://', '', $deviceToShow->getHost()) . ':' . $deviceToShow->getRTSPPort() . ' ' .
                   str_replace(' ', '', $deviceToShow->getName()) . ' ' . $tcpHost . ' ' . $deviceToShow->getVideoHTTPPort();

               $transcodingProcess = \Symfony\Component\Process\Process::fromShellCommandline($transcodingCommand);

               $transcodingProcess->start();

               $success = true;
               $message = '';

           } else {
               $message = $this->translator->trans('Device with identifier %deviceid% was not found.',
                   ['%deviceid%' => $deviceid]);
               $success = false;

               $this->addFlash('error', $message);

               $this->logger->error('Start Video transcoding: Ko. Device with identifier ' . $deviceid . ' was not found.');
           }
       } catch (Throwable $exception) {
           $message = $this->translator->trans('Error while executing action. Error detail: %detail%.',
               ['%detail%' => $exception->getMessage()]);

           $this->addFlash(
               'error', $message
           );
           $success = false;

           $this->logger->critical('Start Video transcoding: Ko. Exception catched. Error detail: ' . $exception->getMessage());
       }

       $this->logger->info('Start Video transcoding: Ok. Video started successfully');

       return new JsonResponse(array(
           'success' => $success,
           'message' => $message,
           'value' => $value
       ));
    }

    I have a nodejs script executing in background to listen o a specific port to broadcast the data on the TCP port to a websocket server.

    The ffmpeg command transcodes the RTSP stream and sent to port TCP 8102 and broadcast the data to a websocket server listening on port 8105.

    The transcoding command code :

    /**
    * @param InputInterface $input
    * @param OutputInterface $output
    * @return int|void|null
    * @throws \Exception
    */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
       try {
           $this->logger->info('Start video transcoding: Setup video transcoding...');
           $io = new SymfonyStyle($input, $output);
           $now = new \DateTime();
           $io->title('Start video transcoding at ' . $now->format('d-m-Y G:i:s') . '...');

           //Get input parameters
           $rtspUri = $input->getArgument('rtsp');
           $secret = $input->getArgument('secret');
           $portsString = $input->getArgument('tcp_port');
           $tcpHost = $input->getArgument('tcp_host');

           $this->logger->debug('Start video transcoding: RTSP: "' . $rtspUri . '". TCP Port: ' . $portsString);

           //Absolute path to logs
           $logPath = $this->path . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'log';
           $stdOutPath = $logPath . DIRECTORY_SEPARATOR . 'transcoding_out.log';
           $stdErrrorPath = $logPath . DIRECTORY_SEPARATOR . 'transcoding_error.log';

           //FFMPEG
           $arguments = '-nostdin -t 00:01:00 -rtsp_transport tcp -i ' . $rtspUri . ' -f mpegts -codec:v mpeg1video -s 1920x1080 -b:v 800k -r 30 -bf 0 ' . $tcpHost . ':' . $portsString . '/' . $secret . ' > '
           . $stdOutPath . ' 2> ' . $stdErrrorPath . ' &';
           $ffmpegParams = '/usr/bin/ffmpeg ' . $arguments;
           //$ffmpegProcess = new Process($ffmpegParams);
           $ffmpegProcess = \Symfony\Component\Process\Process::fromShellCommandline($ffmpegParams);
           $ffmpegProcess->setTimeout(60);
           $ffmpegProcess->setIdleTimeout(60);

           try {
               $ffmpegProcess->start();

               $this->logger->info('Start video transcoding: OK. Video streaming successfully started...');
               $io->success('Start video transcoding: OK. Video streaming successfully started...');
           }catch (ProcessTimedOutException $timedOutException){
               $ffmpegProcess->stop(3, SIGINT);
               $this->io->success('Start video transcoding: Ko. Transcoding finished with error.');
           }
       } catch (Throwable $exception) {
           $message = 'Start video transcoding: Ko. Exception catched. Error detail: ' . $exception->getMessage();
           $this->logger->critical($message);
           $io->error($message);
       }
    }

    The node.js code (got from here JSMpeg – MPEG1 Video & MP2 Audio Decoder in JavaScript :

    // Use the websocket-relay to serve a raw MPEG-TS over WebSockets. You can use
    // ffmpeg to feed the relay. ffmpeg -> websocket-relay -> browser
    // Example:
    // node websocket-relay yoursecret 8081 8082
    // ffmpeg -i <some input="input"> -f mpegts http://localhost:8081/yoursecret

    var fs = require('fs'),
       http = require('http'),
       WebSocket = require('ws');

    if (process.argv.length &lt; 3) {
       console.log(
           'Usage: \n' +
           'node websocket-relay.js <secret> [ ]'
       );

       console.log(process.cwd());

       process.exit();
    }

    var STREAM_SECRET = process.argv[2],
       STREAM_PORT = process.argv[3] || 8081,
       WEBSOCKET_PORT = process.argv[4] || 8082,
       RECORD_STREAM = false;

    // Websocket Server
    var socketServer = new WebSocket.Server({port: WEBSOCKET_PORT, perMessageDeflate: false});
    socketServer.connectionCount = 0;
    socketServer.on('connection', function(socket, upgradeReq) {
       socketServer.connectionCount++;
       console.log(
           'New WebSocket Connection: ',
           (upgradeReq || socket.upgradeReq).socket.remoteAddress,
           (upgradeReq || socket.upgradeReq).headers['user-agent'],
           '('+socketServer.connectionCount+' total)'
       );
       socket.on('close', function(code, message){
           socketServer.connectionCount--;
           console.log(
               'Disconnected WebSocket ('+socketServer.connectionCount+' total)'
           );
       });
    });
    socketServer.broadcast = function(data) {
       socketServer.clients.forEach(function each(client) {
           if (client.readyState === WebSocket.OPEN) {
               client.send(data);
           }
       });
    };

    // HTTP Server to accept incomming MPEG-TS Stream from ffmpeg
    var streamServer = http.createServer( function(request, response) {
       var params = request.url.substr(1).split('/');

       if (params[0] !== STREAM_SECRET) {
           console.log(
               'Failed Stream Connection: '+ request.socket.remoteAddress + ':' +
               request.socket.remotePort + ' - wrong secret.'
           );
           response.end();
       }

       response.connection.setTimeout(0);
       console.log(
           'Stream Connected: ' +
           request.socket.remoteAddress + ':' +
           request.socket.remotePort
       );
       request.on('data', function(data){
           socketServer.broadcast(data);
           if (request.socket.recording) {
               request.socket.recording.write(data);
           }
       });
       request.on('end',function(){
           console.log('close');
           if (request.socket.recording) {
               request.socket.recording.close();
           }
       });

       // Record the stream to a local file?
       if (RECORD_STREAM) {
           var path = 'recordings/' + Date.now() + '.ts';
           request.socket.recording = fs.createWriteStream(path);
       }
    }).listen(STREAM_PORT);

    console.log('Listening for incomming MPEG-TS Stream on http://127.0.0.1:'+STREAM_PORT+'/<secret>');
    console.log('Awaiting WebSocket connections on ws://127.0.0.1:'+WEBSOCKET_PORT+'/');
    </secret></secret></some>

    I am using PHP 7.3 and Symfony 4.3

    I am able to get a successfully response from the controller but I can’t watch the video streaming on an external computer.

    UPDATED : I don’t know if it may be related to the issue, but when I switch to DEV and then switch again to PROD using :

    composer dump-env prod

    If I try to clear the cache with :

    php bin/console cache:clear

    It appears :

    joaquin@dev-computer:/var/www/example.com/html$ composer dump-env prod
    Successfully dumped .env files in .env.local.php
    joaquin@dev-computer:/var/www/example.com/html$ php bin/console cache:clear
    09:15:07 ERROR     [console] Error thrown while running command "cache:clear". Message: "Failed to remove file "/var/www/example.com/html/var/cache/pro~/pools/WBCr1hDG8d/-/R/iW4Vq0vqfrjVsp2Gihwg": unlink(/var/www/example.com/html/var/cache/pro~/pools/WBCr1hDG8d/-/R/iW4Vq0vqfrjVsp2Gihwg): Permission denied." ["exception" => Symfony\Component\Filesystem\Exception\IOException]8;;file:///var/www/example.com/html/vendor/symfony/filesystem/Exception/IOException.php\^]8;;\ { …},"command" => "cache:clear","message" => "Failed to remove file "/var/www/example.com/html/var/cache/pro~/pools/WBCr1hDG8d/-/R/iW4Vq0vqfrjVsp2Gihwg": unlink(/var/www/example.com/html/var/cache/pro~/pools/WBCr1hDG8d/-/R/iW4Vq0vqfrjVsp2Gihwg): Permission denied."]

    In Filesystem.php line 184:

     Failed to remove file "/var/www/example.com/html/var/cache/pro~/pools/WBCr1hDG8d/-/R/iW4Vq0vqfrjVsp2Gihwg": unlink(/va  
    r/www/example.com/html/var/cache/pro~/pools/WBCr1hDG8d/-/R/iW4Vq0vqfrjVsp2Gihwg): Permission denied.                    


    cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
    </command>

    Thanks

  • Psychopy gives the ffmpeg error and does not play the videos

    17 août 2017, par I.Nuel

    I want to create an experiment with Psychopy in which I will present randomly video that participant will have to evaluate.

    I have created a routine with my MovieStim and my Rating response and a Loop with my conditions file (in which are my video files videoname.wmv).
    All my videos are in the same folder as my experiment.

    I have specified the MovieStim with a variable refering to my Loop’s column ($Stimulus).

    But when I run the experiment I have this message.

    Running: E:\Thèse ESPRIT\Approach_Aversion\Experience_AA\Approach_Aversion_lastrun.py
    pyo version 0.8.0 (uses single precision)
    WARNING:root:Warning: could not find imageio's ffmpeg executable:
    [Error 5] Accès refus: 'C:\\Program Files (x86)\\PsychoPy2\\lib\\site-packages\\imageio\\resources\\ffmpeg\\ffmpeg.win32.exe'
    Traceback (most recent call last):
     File "E:\Thèse ESPRIT\Approach_Aversion\Experience_AA\Approach_Aversion_lastrun.py", line 105, in <module>
       depth=0.0,
     File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\contrib\lazy_import.py", line 120, in __call__
       return obj(*args, **kwargs)
     File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\visual\movie3.py", line 124, in __init__
       self.loadMovie(self.filename)
     File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\visual\movie3.py", line 170, in loadMovie
       self._mov = VideoFileClip(filename, audio=(1 - self.noAudio))
     File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 55, in __init__
       reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
     File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 32, in __init__
       infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
     File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 237, in ffmpeg_parse_infos
       proc = sp.Popen(cmd, **popen_params)
     File "C:\Program Files (x86)\PsychoPy2\lib\subprocess.py", line 710, in __init__
       errread, errwrite)
     File "C:\Program Files (x86)\PsychoPy2\lib\subprocess.py", line 958, in _execute_child
       startupinfo)
    WindowsError: [Error 2] Le fichier spécifié est introuvable
    </module>

    It seems to be something wrong with the ffmpeg executable but I don’t understand what.

    Do you have any idea ?

    Thank you very much fo advance !

    Have a nice day.

    Ivane