Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (37)

  • (Dés)Activation de fonctionnalités (plugins)

    18 février 2011, par

    Pour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
    SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
    Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
    MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...)

  • Activation de l’inscription des visiteurs

    12 avril 2011, par

    Il est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
    Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
    Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (5336)

  • arm : Add NEON optimizations for 10 and 12 bit vp9 MC

    8 décembre 2016, par Martin Storsjö
    arm : Add NEON optimizations for 10 and 12 bit vp9 MC
    

    This work is sponsored by, and copyright, Google.

    The plain pixel put/copy functions are used from the 8 bit version,
    for the double size (e.g. put16 uses ff_vp9_copy32_neon), and a new
    copy128 is added.

    Compared with the 8 bit version, the filters can no longer use the
    trick to accumulate in 16 bit with only saturation at the end, but now
    the accumulators need to be 32 bit. This avoids the need to keep track
    of which filter index is the largest though, reducing the size of the
    executable code for these filters.

    For the horizontal filters, we only do 4 or 8 pixels wide in parallel
    (while doing two rows at a time), since we don’t have enough register
    space to filter 16 pixels wide.

    For the vertical filters, we still do 4 and 8 pixels in parallel just
    as in the 8 bit case, but we need to store the output after every 2
    rows instead of after every 4 rows.

    Examples of relative speedup compared to the C version, from checkasm :
    Cortex A7 A8 A9 A53
    vp9_avg4_10bpp_neon : 2.25 2.44 3.05 2.16
    vp9_avg8_10bpp_neon : 3.66 8.48 3.86 3.50
    vp9_avg16_10bpp_neon : 3.39 8.26 3.37 2.72
    vp9_avg32_10bpp_neon : 4.03 10.20 4.07 3.42
    vp9_avg64_10bpp_neon : 4.15 10.01 4.13 3.70
    vp9_avg_8tap_smooth_4h_10bpp_neon : 3.38 6.22 3.41 4.75
    vp9_avg_8tap_smooth_4hv_10bpp_neon : 3.89 6.39 4.30 5.32
    vp9_avg_8tap_smooth_4v_10bpp_neon : 5.32 9.73 6.34 7.31
    vp9_avg_8tap_smooth_8h_10bpp_neon : 4.45 9.40 4.68 6.87
    vp9_avg_8tap_smooth_8hv_10bpp_neon : 4.64 8.91 5.44 6.47
    vp9_avg_8tap_smooth_8v_10bpp_neon : 6.44 13.42 8.68 8.79
    vp9_avg_8tap_smooth_64h_10bpp_neon : 4.66 9.02 4.84 7.71
    vp9_avg_8tap_smooth_64hv_10bpp_neon : 4.61 9.14 4.92 7.10
    vp9_avg_8tap_smooth_64v_10bpp_neon : 6.90 14.13 9.57 10.41
    vp9_put4_10bpp_neon : 1.33 1.46 2.09 1.33
    vp9_put8_10bpp_neon : 1.57 3.42 1.83 1.84
    vp9_put16_10bpp_neon : 1.55 4.78 2.17 1.89
    vp9_put32_10bpp_neon : 2.06 5.35 2.14 2.30
    vp9_put64_10bpp_neon : 3.00 2.41 1.95 1.66
    vp9_put_8tap_smooth_4h_10bpp_neon : 3.19 5.81 3.31 4.63
    vp9_put_8tap_smooth_4hv_10bpp_neon : 3.86 6.22 4.32 5.21
    vp9_put_8tap_smooth_4v_10bpp_neon : 5.40 9.77 6.08 7.21
    vp9_put_8tap_smooth_8h_10bpp_neon : 4.22 8.41 4.46 6.63
    vp9_put_8tap_smooth_8hv_10bpp_neon : 4.56 8.51 5.39 6.25
    vp9_put_8tap_smooth_8v_10bpp_neon : 6.60 12.43 8.17 8.89
    vp9_put_8tap_smooth_64h_10bpp_neon : 4.41 8.59 4.54 7.49
    vp9_put_8tap_smooth_64hv_10bpp_neon : 4.43 8.58 5.34 6.63
    vp9_put_8tap_smooth_64v_10bpp_neon : 7.26 13.92 9.27 10.92

    For the larger 8tap filters, the speedup vs C code is around 4-14x.

    Signed-off-by : Martin Storsjö <martin@martin.st>

    • [DH] libavcodec/arm/Makefile
    • [DH] libavcodec/arm/vp9dsp_init.h
    • [DH] libavcodec/arm/vp9dsp_init_10bpp_arm.c
    • [DH] libavcodec/arm/vp9dsp_init_12bpp_arm.c
    • [DH] libavcodec/arm/vp9dsp_init_16bpp_arm_template.c
    • [DH] libavcodec/arm/vp9dsp_init_arm.c
    • [DH] libavcodec/arm/vp9mc_16bpp_neon.S
  • Working on images asynchronously

    15 décembre 2013, par Mikko Koppanen — Imagick, PHP stuff

    To get my quota on buzzwords for the day we are going to look at using ZeroMQ and Imagick to create a simple asynchronous image processing system. Why asynchronous ? First of all, separating the image handling from a interactive PHP scripts allows us to scale the image processing separately from the web heads. For example we could do the image processing on separate servers, which have SSDs attached and more memory. In this example making the images available to all worker nodes is left to the reader.

    Secondly, separating the image processing from a web script can provide more responsive experience to the user. This doesn’t necessarily mean faster, but let’s say in a multiple image upload scenario this method allows the user to do something else on the site while we process the images in the background. This can be beneficial especially in cases where users upload hundreds of images at a time. To achieve a simple distributed image processing infrastructure we are going to use ZeroMQ for communicating between different components and Imagick to work on the images.

    The first part we are going to create is a simple “Worker” -process skeleton. Naturally for a live environment you would like to have more error handling and possibly use pcntl for process control, but for the sake of brewity the example is barebones :

    1. < ?php
    2.  
    3. define (’THUMBNAIL_ADDR’, ’tcp ://127.0.0.1:5000’) ;
    4. define (’COLLECTOR_ADDR’, ’tcp ://127.0.0.1:5001’) ;
    5.  
    6. class Worker {
    7.  
    8.   private $in ;
    9.   private $out ;
    10.  
    11.   public function __construct ($in_addr, $out_addr)
    12.   {
    13.     $context = new ZMQContext () ;
    14.  
    15.     $this->in = new ZMQSocket ($context, ZMQ: :SOCKET_PULL) ;
    16.     $this->in->bind ($in_addr) ;
    17.  
    18.     $this->out = new ZMQSocket ($context, ZMQ: :SOCKET_PUSH) ;
    19.     $this->out->connect ($out_addr) ;
    20.   }
    21.  
    22.   public function work () {
    23.     while ($command = $this->in->recvMulti ()) {
    24.       if (isset ($this->commands [$command [0]])) {
    25.         echo "Received work" . PHP_EOL ;
    26.  
    27.         $callback = $this->commands [$command [0]] ;
    28.  
    29.         array_shift ($command) ;
    30.         $response = call_user_func_array ($callback, $command) ;
    31.  
    32.         if (is_array ($response))
    33.           $this->out->sendMulti ($response) ;
    34.         else
    35.           $this->out->send ($response) ;
    36.       }
    37.       else {
    38.         error_log ("There is no registered worker for $command [0]") ;
    39.       }
    40.     }
    41.   }
    42.  
    43.   public function register ($command, $callback)
    44.   {
    45.     $this->commands [$command] = $callback ;
    46.   }
    47. }
    48.  ?>

    The Worker class allows us to register commands with callbacks associated with them. In our case the Worker class doesn’t actually care or know about the parameters being passed to the actual callback, it just blindly passes them on. We are using two separate sockets in this example, one for incoming work requests and one for passing the results onwards. This allows us to create a simple pipeline by adding more workers in the mix. For example we could first have a watermark worker, which takes the original image and composites a watermark on it, passes the file onwards to thumbnail worker, which then creates different sizes of thumbnails and passes the final results to event collector.

    The next part we are going to create a is a simple worker script that does the actual thumbnailing of the images :

    1. < ?php
    2. include __DIR__ . ’/common.php’ ;
    3.  
    4. // Create worker class and bind the inbound address to ’THUMBNAIL_ADDR’ and connect outbound to ’COLLECTOR_ADDR’
    5. $worker = new Worker (THUMBNAIL_ADDR, COLLECTOR_ADDR) ;
    6.  
    7. // Register our thumbnail callback, nothing special here
    8. $worker->register (’thumbnail’, function ($filename, $width, $height) {
    9.                   $info = pathinfo ($filename) ;
    10.  
    11.                   $out = sprintf ("%s/%s_%dx%d.%s",
    12.                           $info [’dirname’],
    13.                           $info [’filename’],
    14.                           $width,
    15.                           $height,
    16.                           $info [’extension’]) ;
    17.  
    18.                   $status = 1 ;
    19.                   $message = ’’ ;
    20.  
    21.                   try {
    22.                     $im = new Imagick ($filename) ;
    23.                     $im->thumbnailImage ($width, $height) ;
    24.                     $im->writeImage ($out) ;
    25.                   }
    26.                   catch (Exception $e) {
    27.                     $status = 0 ;
    28.                     $message = $e->getMessage () ;
    29.                   }
    30.  
    31.                   return array (
    32.                         ’status’  => $status,
    33.                         ’filename’ => $filename,
    34.                         ’thumbnail’ => $out,
    35.                         ’message’ => $message,
    36.                     ) ;
    37.                 }) ;
    38.  
    39. // Run the worker, will block
    40. echo "Running thumbnail worker.." . PHP_EOL ;
    41. $worker->work () ;

    As you can see from the code the thumbnail worker registers a callback for ‘thumbnail’ command. The callback does the thumbnailing based on input and returns the status, original filename and the thumbnail filename. We have connected our Workers “outbound” socket to event collector, which will receive the results from the thumbnail worker and do something with them. What the “something” is depends on you. For example you could push the response into a websocket to show immediate feeedback to the user or store the results into a database.

    Our example event collector will just do a var_dump on every event it receives from the thumbnailer :

    1. < ?php
    2. include __DIR__ . ’/common.php’ ;
    3.  
    4. $socket = new ZMQSocket (new ZMQContext (), ZMQ: :SOCKET_PULL) ;
    5. $socket->bind (COLLECTOR_ADDR) ;
    6.  
    7. echo "Waiting for events.." . PHP_EOL ;
    8. while (($message = $socket->recvMulti ())) {
    9.   var_dump ($message) ;
    10. }
    11.  ?>

    The final piece of the puzzle is the client that pumps messages into the pipeline. The client connects to the thumbnail worker, passes on filename and desired dimensions :

    1. < ?php
    2. include __DIR__ . ’/common.php’ ;
    3.  
    4. $socket = new ZMQSocket (new ZMQContext (), ZMQ: :SOCKET_PUSH) ;
    5. $socket->connect (THUMBNAIL_ADDR) ;
    6.  
    7. $socket->sendMulti (
    8.       array (
    9.         ’thumbnail’,
    10.         realpath (’./test.jpg’),
    11.         50,
    12.         50,
    13.       )
    14. ) ;
    15. echo "Sent request" . PHP_EOL ;
    16.  ?>

    After this our processing pipeline will look like this :

    simple-pipeline

    Now, if we notice that thumbnail workers or the event collectors can’t keep up with the rate of images we are pushing through we can start scaling the pipeline by adding more processes on each layer. ZeroMQ PUSH socket will automatically round-robin between all connected nodes, which makes adding more workers and event collectors simple. After adding more workers our pipeline will look like this :

    scaling-pipeline

    Using ZeroMQ also allows us to create more flexible architectures by adding forwarding devices in the middle, adding request-reply workers etc. So, the last thing to do is to run our pipeline and see the results :

    Let’s create our test image first :

    $ convert magick:rose test.jpg
    

    From the command-line run the thumbnail script :

    $ php thumbnail.php 
    Running thumbnail worker..
    

    In a separate terminal window run the event collector :

    $ php collector.php 
    Waiting for events..
    

    And finally run the client to send the thumbnail request :

    $ php client.php 
    Sent request
    $
    

    If everything went according to the plan you should now see the following output in the event collector window :

    array(4) 
      [0]=>
      string(1) "1"
      [1]=>
      string(56) "/test.jpg"
      [2]=>
      string(62) "/test_50x50.jpg"
      [3]=>
      string(0) ""
    
    

    Happy hacking !

  • mp3 decoding using ffmpeg API (Header missing)

    24 juin 2019, par WIN

    i have been trying to decode an MP3 file to pcm, using ffmpeg API, but i keep getting an error

    [mp3 @ 0x8553020]Header missing

    this is the code i use :

    #include
    #include
    #include

    #ifdef HAVE_AV_CONFIG_H
    #undef HAVE_AV_CONFIG_H
    #endif

    #include "libavcodec/avcodec.h"
    #include "libavutil/mathematics.h"

    #define INBUF_SIZE 4096
    #define AUDIO_INBUF_SIZE 20480
    #define AUDIO_REFILL_THRESH 4096


    static void audio_decode_example(const char *outfilename, const char *filename)
    {
       AVCodec *codec;
       AVCodecContext *c= NULL;
       int out_size, len;
       FILE *f, *outfile;
       uint8_t *outbuf;
       uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
       AVPacket avpkt;

       av_init_packet(&amp;avpkt);

       printf("Audio decoding\n");

       /* find the mpeg audio decoder */
       codec = avcodec_find_decoder(CODEC_ID_MP3ON4);
       if (!codec) {
       fprintf(stderr, "codec not found\n");
       exit(1);
       }

       c= avcodec_alloc_context();

       /* open it */
       if (avcodec_open(c, codec) &lt; 0) {
       fprintf(stderr, "could not open codec\n");
       exit(1);
       }

       outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);

       f = fopen(filename, "rb");
       if (!f) {
       fprintf(stderr, "could not open %s\n", filename);
       exit(1);
       }
       outfile = fopen(outfilename, "wb");
       if (!outfile) {
       av_free(c);
       exit(1);
       }

       /* decode until eof */
       avpkt.data = inbuf;
       avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);

       while (avpkt.size > 0) {
       out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
       len = avcodec_decode_audio3(c, (short *)outbuf, &amp;out_size, &amp;avpkt);
       if (len &lt; 0) {
           fprintf(stderr, "Error while decoding\n");
           exit(1);
       }
       if (out_size > 0) {
           /* if a frame has been decoded, output it */
           fwrite(outbuf, 1, out_size, outfile);
       }
       avpkt.size -= len;
       avpkt.data += len;
       if (avpkt.size &lt; AUDIO_REFILL_THRESH) {
           /* Refill the input buffer, to avoid trying to decode
            * incomplete frames. Instead of this, one could also use
            * a parser, or use a proper container format through
            * libavformat. */
           memmove(inbuf, avpkt.data, avpkt.size);
           avpkt.data = inbuf;
           len = fread(avpkt.data + avpkt.size, 1,
                       AUDIO_INBUF_SIZE - avpkt.size, f);
           if (len > 0)
               avpkt.size += len;
       }
       }

       fclose(outfile);
       fclose(f);
       free(outbuf);

       avcodec_close(c);
       av_free(c);
    }

    int main(int argc, char **argv)
    {
       const char *filename;

       /* must be called before using avcodec lib */
       avcodec_init();

       /* register all the codecs */
       avcodec_register_all();

       audio_decode_example("test.wav", argv[1]);

       return 0;
    }

    when i use the same code to directly play the sound, like this :

    if (out_size > 0) {
       /* if a frame has been decoded, output it *
       play_sound(outbuf, out_size);
    }

    i have no problem at all with some files, other mp3 files just gives an error without even starting ... is there any ideas ?

    PS : this code is from libavcodec/api-example.c , modified as needed