Recherche avancée

Médias (0)

Mot : - Tags -/configuration

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

Autres articles (18)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Other interesting software

    13 avril 2011, par

    We don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
    The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
    We don’t know them, we didn’t try them, but you can take a peek.
    Videopress
    Website : http://videopress.com/
    License : GNU/GPL v2
    Source code : (...)

Sur d’autres sites (7152)

  • How to create a command – Introducing the Piwik Platform

    2 octobre 2014, par Thomas Steur — Development

    This is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to publish your plugin or theme on the Piwik Marketplace). This time you’ll learn how to create a new command. For this tutorial you will need to have basic knowledge of PHP.

    What is a command ?

    A command can execute any task on the command line. Piwik provides currently about 50 commands via the Piwik Console. These commands let you start the archiver, change the number of available custom variables, enable the developer mode, clear caches, run tests and more. You could write your own command to sync users or websites with another system for instance.

    Getting started

    In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.

    To summarize the things you have to do to get setup :

    • Install Piwik (for instance via git).
    • Activate the developer mode : ./console development:enable --full.
    • Generate a plugin : ./console generate:plugin --name="MyCommandPlugin". There should now be a folder plugins/MyCommandPlugin.
    • And activate the created plugin under Settings => Plugins.

    Let’s start creating a command

    We start by using the Piwik Console to create a new command. As you can see there is even a command that lets you easily create a new command :

    ./console generate:command

    The command will ask you to enter the name of the plugin the created command should belong to. I will simply use the above chosen plugin name “MyCommandPlugin”. It will ask you for a command name as well. I will use “SyncUsers” in this example. There should now be a file plugins/MyCommandPlugin/Commands/Syncusers.php which contains already an example to get you started easily :

    1. class Syncusers extends ConsoleCommand
    2. {
    3.     protected function configure()
    4.     {
    5.         $this->setName('mycommandplugin:syncusers');
    6.         $this->setDescription('MyCommandPlugin');
    7.         $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
    8.     }
    9.  
    10.     /**
    11.      * Execute command like: ./console mycommandplugin:syncusers --name="The Piwik Team"
    12.      */
    13.     protected function execute(InputInterface $input, OutputInterface $output)
    14.     {
    15.         $name    = $input->getOption('name');
    16.  
    17.         $message = sprintf('Syncusers: %s', $name);
    18.  
    19.         $output->writeln($message);
    20.     }
    21. }

    Télécharger

    Any command that is placed in the “Commands” folder of your plugin will be available on the command line automatically. Therefore, the newly created command can now be executed via ./console mycommandplugin:syncusers --name="The Piwik Team".

    The code template explained

    1. protected function configure()
    2. {
    3.     $this->setName('mycommandplugin:checkdatabase');
    4.     $this->setDescription('MyCommandPlugin');
    5.     $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
    6. }

    Télécharger

    As the name says the method configure lets you configure your command. You can define the name and description of your command as well as all the options and arguments you expect when executing it.

    1. protected function execute(InputInterface $input, OutputInterface $output)
    2. {
    3.     $name    = $input->getOption('name');
    4.     $message = sprintf('Syncusers: %s', $name);
    5.     $output->writeln($message);
    6. }

    Télécharger

    The actual task is defined in the execute method. There you can access any option or argument that was defined on the command line via $input and write anything to the console via $output argument.

    In case anything went wrong during the execution you should throw an exception to make sure the user will get a useful error message. Throwing an exception when an error occurs will make sure the command does exit with a status code different than 0 which can sometimes be important.

    Advanced features

    The Piwik Console is based on the powerful Symfony Console component. For instance you can ask a user for any interactive input, you can use different output color schemes and much more. If you are interested in learning more all those features have a look at the Symfony console website.

    How to test a command

    After you have created a command you are surely wondering how to test it. Ideally, the actual command is quite short as it acts like a controller. It should only receive the input values, execute the task by calling a method of another class and output any useful information. This allows you to easily create a unit or integration test for the classes behind the command. We will cover this topic in one of our future blog posts. Just one hint : You can use another command ./console generate:test to create a test. If you want to know how to test a command have a look at the Testing Commands documentation.

    Publishing your Plugin on the Marketplace

    In case you want to share your commands with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin and best practices when publishing a plugin.

    Isn’t it easy to create a command ? We never even created a file ! If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.

  • record and play file using wrapper ffmpeg

    3 septembre 2014, par user1541069

    I am using C# wrapper for ffmpeg from ffmpeg
    I want record rtsp stream and play it but I can not decoder frame from file

    using this code I write file test.avi

    unsafe
           {
               AVFormatContext* context = FFmpegInvoke.avformat_alloc_context();
               int video_stream_index=0;

               FFmpegInvoke.av_register_all();
               FFmpegInvoke.avcodec_register_all();
               FFmpegInvoke.avformat_network_init();

               //open rtsp
               if (FFmpegInvoke.avformat_open_input(&context, "rtsp://admin:admin@192.168.0.71:554", null, null) != 0)
               {
                   return ;
               }

               if (FFmpegInvoke.avformat_find_stream_info(context, null) < 0)
               {
                   return ;
               }

               //search video stream
               for (int i = 0; i < context->nb_streams; i++)
               {
                   if (context->streams[i]->codec->codec_type == AVMediaType.AVMEDIA_TYPE_VIDEO)
                       video_stream_index = i;
               }

               AVPacket packet;
               FFmpegInvoke.av_init_packet(&packet);

               //open output file
               AVOutputFormat* fmt = FFmpegInvoke.av_guess_format("h264", null, null);
               AVFormatContext* oc = FFmpegInvoke.avformat_alloc_context();
               oc->oformat = fmt;
               FFmpegInvoke.avio_open2(&oc->pb, "test.mkv", FFmpegInvoke.AVIO_FLAG_WRITE, null, null);

               AVStream* stream = null;
               int cnt = 0;
               //start reading packets from stream and write them to file

            ///   FFmpegInvoke.av_read_play(context);//play RTSP
               while (FFmpegInvoke.av_read_frame(context, &packet) >= 0 && cnt < 1000)
               {//read 100 frames


                   if (packet.stream_index == video_stream_index)
                   {//packet is video              
                       if (stream == null)
                       {//create stream in file

                           stream = FFmpegInvoke.avformat_new_stream(oc, context->streams[video_stream_index]->codec->codec);
                           FFmpegInvoke.avcodec_copy_context(stream->codec, context->streams[video_stream_index]->codec);
                           stream->sample_aspect_ratio = context->streams[video_stream_index]->codec->sample_aspect_ratio;
                           FFmpegInvoke.avformat_write_header(oc, null);
                       }
                       packet.stream_index = stream->id;
                       var p1 = new FileInfo("test.mkv").Length;
                       FFmpegInvoke.av_write_frame(oc, &packet);
                       cnt++;
                   }
                   FFmpegInvoke.av_free_packet(&packet);
                   FFmpegInvoke.av_init_packet(&packet);
               }
               FFmpegInvoke.av_read_pause(context);
               FFmpegInvoke.av_write_trailer(oc);
               FFmpegInvoke.avio_close(oc->pb);
               FFmpegInvoke.avformat_free_context(oc);
           }

    and using this code I want to play me file

    unsafe{


               string url = "test.mkv";

               FFmpegInvoke.av_register_all();
               FFmpegInvoke.avcodec_register_all();
               FFmpegInvoke.avformat_network_init();


               AVFormatContext* pFormatContext = FFmpegInvoke.avformat_alloc_context();
               if (FFmpegInvoke.avformat_open_input(&pFormatContext, url, null, null) != 0)
                   throw new Exception("Could not open file");

               if (FFmpegInvoke.avformat_find_stream_info(pFormatContext, null) != 0)
                   throw new Exception("Could not find stream info");
               AVStream* pStream = null;
               for (int i = 0; i < pFormatContext->nb_streams; i++)
               {
                   if (pFormatContext->streams[i]->codec->codec_type == AVMediaType.AVMEDIA_TYPE_VIDEO)
                   {
                       pStream = pFormatContext->streams[i];
                       break;
                   }
               }
               var packet = new AVPacket();
               AVPacket* pPacket = &packet;
               FFmpegInvoke.av_init_packet(pPacket);



               AVCodecContext codecContext = *(pStream->codec);
               int width = codecContext.width;
               int height = codecContext.height;
               AVPixelFormat sourcePixFmt = codecContext.pix_fmt;
               AVCodecID codecId = codecContext.codec_id;
               var convertToPixFmt = AVPixelFormat.PIX_FMT_BGR24;
               SwsContext* pConvertContext = FFmpegInvoke.sws_getContext(width, height, sourcePixFmt,
                                                                          width, height, convertToPixFmt,
                                                                          FFmpegInvoke.SWS_FAST_BILINEAR, null, null, null);
               if (pConvertContext == null)
                   throw new Exception("Could not initialize the conversion context");

               var pConvertedFrame = (AVPicture*)FFmpegInvoke.avcodec_alloc_frame();
               int convertedFrameBufferSize = FFmpegInvoke.avpicture_get_size(convertToPixFmt, width, height);
               var pConvertedFrameBuffer = (byte*)FFmpegInvoke.av_malloc((uint)convertedFrameBufferSize);
               FFmpegInvoke.avpicture_fill(pConvertedFrame, pConvertedFrameBuffer, convertToPixFmt, width, height);

               AVCodec* pCodec = FFmpegInvoke.avcodec_find_decoder(codecId);
               if (pCodec == null)
                   throw new Exception("Unsupported codec");

               // Reusing codec context from stream info,
               // as an alternative way it could look like this: (but it works not for all kind of codecs)
               // AVCodecContext* pCodecContext = FFmpegInvoke.avcodec_alloc_context3(pCodec);
               AVCodecContext* pCodecContext = &codecContext;

               if ((pCodec->capabilities & FFmpegInvoke.CODEC_CAP_TRUNCATED) == FFmpegInvoke.CODEC_CAP_TRUNCATED)
                   pCodecContext->flags |= FFmpegInvoke.CODEC_FLAG_TRUNCATED;

               AVFrame* pDecodedFrame = FFmpegInvoke.avcodec_alloc_frame();

               if (FFmpegInvoke.av_read_frame(pFormatContext, pPacket) < 0)
                   throw new System.IO.EndOfStreamException();
               int gotPicture = 0;
               int size = FFmpegInvoke.avcodec_decode_video2(pCodecContext, pDecodedFrame, &gotPicture, pPacket);
               if (size < 0)
                   throw new Exception(string.Format("Error while decoding frame "));

               if (gotPicture == 1)
               {

               }

    size =-22.Why ? what is wrong ?How play my file using ffmpeg ?

  • Anomalie #3325 : (array) n’est pas suffisant pour convertir l’objet récupéré par l’itérateur YQL

    29 octobre 2014, par Sylvain Lesage

    L’URL est mal écrite, c’est : http://core.spip.org/projects/spip/repository/entry/spip/ecrire/iterateur/data.php#L563.

    J’ai pas le dépôt SVN sous la main, mais le patch en gros pourrait être remplacer à la ligne 547

    /**
     * yql -> tableau
     * @throws Exception
     * @param  string $u
     * @return array|bool
     */
    function inc_yql_to_array_dist($u) 
        define(’_YQL_ENDPOINT’, ’http://query.yahooapis.com/v1/public/yql?&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=’) ;
        $v = recuperer_url($url = _YQL_ENDPOINT.urlencode($u).’&format=json’) ;
        if (!$v[’page’]
          OR !$w = json_decode($v[’page’],true)) 
            throw new Exception(’YQL : r&#233 ;ponse vide ou mal form&#233 ;e’) ;
        
        if (isset($w[’error’]))
            throw new Exception($w[’error’][’description’]) ;
        
        return (array) $w ;
    
    

    par

    /**
     *
     * Convert an object to an array
     *
     * @param    object  $object The object to convert
     * @return   array
     *
     */
    function inc_object_to_array( $object ) 
        if( !is_object( $object ) && !is_array( $object ) ) 
            return $object ;
        
        if( is_object( $object ) ) 
            $object = get_object_vars( $object ) ;
        
        return array_map( ’inc_object_to_array’, $object ) ;
    
    

    /**
    * yql -> tableau
    * @throws Exception
    * @param string $u
    * @return array|bool
    */
    function inc_yql_to_array($u)
    define(’_YQL_ENDPOINT’, ’http://query.yahooapis.com/v1/public/yql?&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=’) ;
    $v = recuperer_page($url = _YQL_ENDPOINT.urlencode($u).’&format=json’) ;
    $w = json_decode($v) ;
    if (!$w)
    throw new Exception(’YQL : r&#233 ;ponse vide ou mal form&#233 ;e’) ;
    return false ;

    return inc_object_to_array($w) ;