Recherche avancée

Médias (1)

Mot : - Tags -/censure

Autres articles (31)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (4458)

  • Programming in C : Opening, Reading and Transcoding of Live TV with libavcodec. libavformat etc

    19 décembre 2011, par mmoment

    I'm currently developing a live streaming Software for my University Project.

    I am supposed to open a Live Video Stream from a USB Stick( I am using the Hauppauge WinTV-HVR 950Q under Linux) and read the Stream.
    Then I'm supposed to transcode it to h246. and send it to some devices in the Network.

    My Problem


    I can use the v4l API to access the USB Stick, but transcoding does currently not work as far as I know, therefore I want to use the libav to do so. I know that using the command line tools transcoding of live streams with ffmpeg is not a big deal, but doing so in C seems to be more of a problem.

    1. Here's how I open some static Video File :

      static char* path = "./video.mpeg" ;
      AVFormatContext *pFormatCtx ;

      av_register_all() ;

      if(av_open_input_file(&pFormatCtx, path, NULL, 0, NULL) !=0)

      printf("Opening file \"%s\" failed", path) ;
      return -1 ;
      else printf("Opening the file \"%s\" succeeded", path) ;

    2. Here's how I understand to how open a Live Feed

      static char* path = "/dev/dvb/adapter0/dvr0" ;
      AVFormatContext *pFormatCtx ;

      av_register_all() ;
      avdevice_register_all() ;

      if(avformat_open_input(&pFormatCtx, path, NULL, NULL) != 0)

      perror("avformat_open_input") ;
      return -1 ;
      else printf("Yay") ;

    3. Here's how I understand to how open a Live Feed

      if(av_find_stream_info(pFormatCtx)<0)

      printf("Could not find any Stream Information the file \"%s\"", path) ;
      return -1 ;

      // Dump information about file onto standard error
      dump_format(pFormatCtx, 0, path, 0) ;
      AVCodecContext *pCodecCtx ;

      // Find the first video stream
      int videoStream=-1 ;
      for(i=0 ; inb_streams ; i++)

      if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
      {
         videoStream=i;
         break;
      }

      if(videoStream==-1) return -1 ; // Didn't find a video stream

      // Get a pointer to the codec context for the video stream
      pCodecCtx=pFormatCtx->streams[videoStream]->codec ;

      AVCodec *pCodec ;

      // Find the decoder for the video stream
      pCodec=avcodec_find_decoder(pCodecCtx->codec_id) ;
      if(pCodec==NULL)

      fprintf(stderr, "Unsupported codec !\n") ;
      return -1 ; // Codec not found

      //Open codec
      if(avcodec_open(pCodecCtx, pCodec)<0)

      printf("Could not open the Codec") ;
      return -1 ; // Could not open codec

    So now how can you help me ?

    I would really appreciate it if anyone knew how to open a live stream and could give me a good example.

  • How to create a scheduled task – Introducing the Piwik Platform

    28 août 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 create a custom theme in Piwik). This time you’ll learn how to execute scheduled tasks in the background, for instance sending a daily email. For this tutorial you will need to have basic knowledge of PHP.

    What can you do with scheduled tasks ?

    Scheduled tasks let you execute tasks regularly (hourly, weekly, …). For instance you can :

    • create and send custom reports or summaries
    • sync users and websites with other systems
    • clear any caches
    • import third-party data into Piwik
    • monitor your Piwik instance
    • execute any other task you can think of

    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="MyTasksPlugin". There should now be a folder plugins/MyTasksPlugin.
    • And activate the created plugin under Settings => Plugins.

    Let’s start creating a scheduled task

    We start by using the Piwik Console to create a tasks template :

    ./console generate:scheduledtask

    The command will ask you to enter the name of the plugin the task should belong to. I will simply use the above generated plugin name “MyTasksPlugin”. There should now be a file plugins/MyTasksPlugin/Tasks.php which contains some examples to get you started easily :

    class Tasks extends \Piwik\Plugin\Tasks
    {
       public function schedule()
       {
           $this-&gt;hourly('myTask');  // method will be executed once every hour
           $this-&gt;daily('myTask');   // method will be executed once every day
           $this-&gt;weekly('myTask');  // method will be executed once every week
           $this-&gt;monthly('myTask'); // method will be executed once every month

           // pass a parameter to the task
           $this-&gt;weekly('myTaskWithParam', 'anystring');

           // specify a different priority
           $this-&gt;monthly('myTask', null, self::LOWEST_PRIORITY);
           $this-&gt;monthly('myTaskWithParam', 'anystring', self::HIGH_PRIORITY);
       }

       public function myTask()
       {
           // do something
       }

       public function myTaskWithParam($param)
       {
           // do something
       }
    }

    A simple example

    As you can see in the generated template you can execute tasks hourly, daily, weekly and monthly by registering a method which represents the actual task :

    public function schedule()
    {
       // register method remindMeToLogIn to be executed once every day
       $this-&gt;daily('remindMeToLogIn');  
    }

    public function remindMeToLogIn()
    {
       $mail = new \Piwik\Mail();
       $mail-&gt;addTo('me@example.com');
       $mail-&gt;setSubject('Check stats');
       $mail-&gt;setBodyText('Log into your Piwik instance and check your stats!');
       $mail-&gt;send();
    }

    This example sends you an email once a day to remind you to log into your Piwik daily. The Piwik platform makes sure to execute the method remindMeToLogIn exactly once every day.

    How to pass a parameter to a task

    Sometimes you want to pass a parameter to a task method. This is useful if you want to register for instance one task for each user or for each website. You can achieve this by specifying a second parameter when registering the method to execute.

    public function schedule()
    {
       foreach (\Piwik\Site::getSites() as $site) {
           // create one task for each site and pass the URL of each site to the task
           $this-&gt;hourly('pingSite', $site['main_url']);
       }
    }

    public function pingSite($siteMainUrl)
    {
       file_get_contents($siteMainUrl);
    }

    How to test scheduled tasks

    After you have created your task you are surely wondering how to test it. First, you should write a unit or integration test which we will cover in one of our future blog posts. Just one hint : You can use the command ./console generate:test to create a test. To manually execute all scheduled tasks you can execute the API method CoreAdminHome.runScheduledTasks by opening the following URL in your browser :

    http://piwik.example.com/index.php?module=API&amp;method=CoreAdminHome.runScheduledTasks&amp;token_auth=YOUR_API_TOKEN

    Don’t forget to replace the domain and the token_auth URL parameter.

    There is one problem with executing the scheduled tasks : The platform makes sure they will be executed only once an hour, a day, etc. This means you can’t simply reload the URL and test the method again and again as you would have to wait for the next hour or day. The proper solution is to set the constant DEBUG_FORCE_SCHEDULED_TASKS to true within the file Core/TaskScheduler.php. Don’t forget to set it back to false again once you have finished testing it.

    Starting from Piwik 2.6.0 you can alternatively execute the following command :

    ./console core:run-scheduled-tasks --force --token-auth=YOUR_TOKEN_AUTH

    The option “–force” will make sure to execute even tasks that are not due to run at this time. So you won’t have to modify any files.

    Which tasks are registered and when is the next execution time of my task ?

    The TasksTimetable plugin from the Marketplace can answer this question for you. Simply install and activate the plugin with one click by going to Settings => Marketplace => Get new functionality. It’ll add a new admin menu item under Settings named Scheduled Tasks.

    Publishing your Plugin on the Marketplace

    In case you want to share your task(s) 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.

    Advanced features

    Isn’t it easy to create scheduled tasks ? We never even created a file ! Of course, based on our API design principle “The complexity of our API should never exceed the complexity of your use case.” you can accomplish more if you want. For instance, you can define priorities, you can directly register methods from different objects and classes, you can specify at which time of a day a task should run and more.

    Would you like to know more about tasks ? Go to our Tasks class reference in the Piwik Developer Zone.

    If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.

  • How to create a scheduled task – Introducing the Piwik Platform

    28 août 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 create a custom theme in Piwik). This time you’ll learn how to execute scheduled tasks in the background, for instance sending a daily email. For this tutorial you will need to have basic knowledge of PHP.

    What can you do with scheduled tasks ?

    Scheduled tasks let you execute tasks regularly (hourly, weekly, …). For instance you can :

    • create and send custom reports or summaries
    • sync users and websites with other systems
    • clear any caches
    • import third-party data into Piwik
    • monitor your Piwik instance
    • execute any other task you can think of

    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="MyTasksPlugin". There should now be a folder plugins/MyTasksPlugin.
    • And activate the created plugin under Settings => Plugins.

    Let’s start creating a scheduled task

    We start by using the Piwik Console to create a tasks template :

    ./console generate:scheduledtask

    The command will ask you to enter the name of the plugin the task should belong to. I will simply use the above generated plugin name “MyTasksPlugin”. There should now be a file plugins/MyTasksPlugin/Tasks.php which contains some examples to get you started easily :

    class Tasks extends \Piwik\Plugin\Tasks
    {
       public function schedule()
       {
           $this-&gt;hourly('myTask');  // method will be executed once every hour
           $this-&gt;daily('myTask');   // method will be executed once every day
           $this-&gt;weekly('myTask');  // method will be executed once every week
           $this-&gt;monthly('myTask'); // method will be executed once every month

           // pass a parameter to the task
           $this-&gt;weekly('myTaskWithParam', 'anystring');

           // specify a different priority
           $this-&gt;monthly('myTask', null, self::LOWEST_PRIORITY);
           $this-&gt;monthly('myTaskWithParam', 'anystring', self::HIGH_PRIORITY);
       }

       public function myTask()
       {
           // do something
       }

       public function myTaskWithParam($param)
       {
           // do something
       }
    }

    A simple example

    As you can see in the generated template you can execute tasks hourly, daily, weekly and monthly by registering a method which represents the actual task :

    public function schedule()
    {
       // register method remindMeToLogIn to be executed once every day
       $this-&gt;daily('remindMeToLogIn');  
    }

    public function remindMeToLogIn()
    {
       $mail = new \Piwik\Mail();
       $mail-&gt;addTo('me@example.com');
       $mail-&gt;setSubject('Check stats');
       $mail-&gt;setBodyText('Log into your Piwik instance and check your stats!');
       $mail-&gt;send();
    }

    This example sends you an email once a day to remind you to log into your Piwik daily. The Piwik platform makes sure to execute the method remindMeToLogIn exactly once every day.

    How to pass a parameter to a task

    Sometimes you want to pass a parameter to a task method. This is useful if you want to register for instance one task for each user or for each website. You can achieve this by specifying a second parameter when registering the method to execute.

    public function schedule()
    {
       foreach (\Piwik\Site::getSites() as $site) {
           // create one task for each site and pass the URL of each site to the task
           $this-&gt;hourly('pingSite', $site['main_url']);
       }
    }

    public function pingSite($siteMainUrl)
    {
       file_get_contents($siteMainUrl);
    }

    How to test scheduled tasks

    After you have created your task you are surely wondering how to test it. First, you should write a unit or integration test which we will cover in one of our future blog posts. Just one hint : You can use the command ./console generate:test to create a test. To manually execute all scheduled tasks you can execute the API method CoreAdminHome.runScheduledTasks by opening the following URL in your browser :

    http://piwik.example.com/index.php?module=API&amp;method=CoreAdminHome.runScheduledTasks&amp;token_auth=YOUR_API_TOKEN

    Don’t forget to replace the domain and the token_auth URL parameter.

    There is one problem with executing the scheduled tasks : The platform makes sure they will be executed only once an hour, a day, etc. This means you can’t simply reload the URL and test the method again and again as you would have to wait for the next hour or day. The proper solution is to set the constant DEBUG_FORCE_SCHEDULED_TASKS to true within the file Core/TaskScheduler.php. Don’t forget to set it back to false again once you have finished testing it.

    Starting from Piwik 2.6.0 you can alternatively execute the following command :

    ./console core:run-scheduled-tasks --force --token-auth=YOUR_TOKEN_AUTH

    The option “–force” will make sure to execute even tasks that are not due to run at this time. So you won’t have to modify any files.

    Which tasks are registered and when is the next execution time of my task ?

    The TasksTimetable plugin from the Marketplace can answer this question for you. Simply install and activate the plugin with one click by going to Settings => Marketplace => Get new functionality. It’ll add a new admin menu item under Settings named Scheduled Tasks.

    Publishing your Plugin on the Marketplace

    In case you want to share your task(s) 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.

    Advanced features

    Isn’t it easy to create scheduled tasks ? We never even created a file ! Of course, based on our API design principle “The complexity of our API should never exceed the complexity of your use case.” you can accomplish more if you want. For instance, you can define priorities, you can directly register methods from different objects and classes, you can specify at which time of a day a task should run and more.

    Would you like to know more about tasks ? Go to our Tasks class reference in the Piwik Developer Zone.

    If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.