Recherche avancée

Médias (2)

Mot : - Tags -/kml

Autres articles (11)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • 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 (4794)

  • Revision 29746 : Gestion de la file d’attente

    8 juillet 2009, par kent1@… — Log

    Gestion de la file d’attente

  • How to open a .sw file using libav library in c language ?

    29 août 2018, par volatile

    I created a .sw(16 bit pcm) file by passing an audio file. Now I am trying to get back the original audio(.mp3) by passing the .sw file as an input to the following file.

    How can I read the .sw file content so that I can get back the mp3 file. Below is the code,

    #include
    #include
    #include

    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavformat></libavformat>avformat.h>

    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>common.h>
    #include <libavutil></libavutil>frame.h>
    #include <libavutil></libavutil>samplefmt.h>

    /* check that a given sample format is supported by the encoder */
    static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt)
    {
       const enum AVSampleFormat *p = codec->sample_fmts;

       while (*p != AV_SAMPLE_FMT_NONE) {
           if (*p == sample_fmt)
               return 1;
           p++;
       }
       return 0;
    }

    /* just pick the highest supported samplerate */
    static int select_sample_rate(const AVCodec *codec)
    {
       const int *p;
       int best_samplerate = 0;

       if (!codec->supported_samplerates)
           return 44100;

       p = codec->supported_samplerates;
       while (*p) {
           if (!best_samplerate || abs(44100 - *p) &lt; abs(44100 - best_samplerate))
               best_samplerate = *p;
           p++;
       }
       return best_samplerate;
    }

    /* select layout with the highest channel count */
    static int select_channel_layout(const AVCodec *codec)
    {
       const uint64_t *p;
       uint64_t best_ch_layout = 0;
       int best_nb_channels   = 0;

       if (!codec->channel_layouts)
           return AV_CH_LAYOUT_STEREO;

       p = codec->channel_layouts;
       while (*p) {
           int nb_channels = av_get_channel_layout_nb_channels(*p);

           if (nb_channels > best_nb_channels) {
               best_ch_layout    = *p;
               best_nb_channels = nb_channels;
           }
           p++;
       }
       return best_ch_layout;
    }

    static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt,
                      FILE *output)
    {
       int ret;

      /* send the frame for encoding */
      ret = avcodec_send_frame(ctx, frame);
      if (ret &lt; 0) {
          fprintf(stderr, "Error sending the frame to the encoder\n");
          exit(1);
      }

      /* read all the available output packets (in general there may be any
       * number of them */
      while (ret >= 0) {
          ret = avcodec_receive_packet(ctx, pkt);
          if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
              return;
          else if (ret &lt; 0) {
              fprintf(stderr, "Error encoding audio frame\n");
              exit(1);
          }

          fwrite(pkt->data, 1, pkt->size, output);
          av_packet_unref(pkt);
      }
    }

    int main(int argc, char **argv)
    {
      const char *filename;
      const AVCodec *codec;
      AVCodecContext *c= NULL;
      AVFrame *frame;
      AVPacket *pkt;
      int i, j, k, ret;
      FILE *f;
      uint16_t *samples;
      float t, tincr;

      av_register_all();
      avcodec_register_all();

      if (argc &lt;= 1) {
          fprintf(stderr, "Usage: %s <output file="file">\n", argv[0]);
          return 0;
      }
      filename = argv[1];

      /* find the MP2 encoder */
      codec = avcodec_find_encoder(AV_CODEC_ID_MP3);
      if (!codec) {
          fprintf(stderr, "Codec not found\n");
          exit(1);
      }

      c = avcodec_alloc_context3(codec);
      if (!c) {
          fprintf(stderr, "Could not allocate audio codec context\n");
          exit(1);
      }

      /* put sample parameters */
      c->bit_rate = 64000;

      /* check that the encoder supports s16 pcm input */
      c->sample_fmt = AV_SAMPLE_FMT_S16P;
      if (!check_sample_fmt(codec, c->sample_fmt)) {
          fprintf(stderr, "Encoder does not support sample format %s",
                  av_get_sample_fmt_name(c->sample_fmt));
          exit(1);
      }

      /* select other audio parameters supported by the encoder */
      c->sample_rate    = select_sample_rate(codec);
      c->channel_layout = select_channel_layout(codec);
      c->channels       = av_get_channel_layout_nb_channels(c->channel_layout);

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

      f = fopen(filename, "wb");
      if (!f) {
          fprintf(stderr, "Could not open %s\n", filename);
          exit(1);
      }

      /* packet for holding encoded output */
      pkt = av_packet_alloc();
      if (!pkt) {
          fprintf(stderr, "could not allocate the packet\n");
          exit(1);
      }

      /* frame containing input raw audio */
      frame = av_frame_alloc();
      if (!frame) {
          fprintf(stderr, "Could not allocate audio frame\n");
          exit(1);
      }

      frame->nb_samples     = c->frame_size;
      frame->format         = c->sample_fmt;
      frame->channel_layout = c->channel_layout;

      /* allocate the data buffers */
      ret = av_frame_get_buffer(frame, 0);
      if (ret &lt; 0) {
          fprintf(stderr, "Could not allocate audio data buffers\n");
          exit(1);
      }

      /* encode a single tone sound */
      t = 0;
      tincr = 2 * M_PI * 440.0 / c->sample_rate;
      for (i = 0; i &lt; 200; i++) {
          /* make sure the frame is writable -- makes a copy if the encoder
           * kept a reference internally */
          ret = av_frame_make_writable(frame);
          if (ret &lt; 0)
              exit(1);
          samples = (uint16_t*)frame->data[0];

          for (j = 0; j &lt; c->frame_size; j++) {
              samples[2*j] = (int)(sin(t) * 10000);

              for (k = 1; k &lt; c->channels; k++)
                  samples[2*j + k] = samples[2*j];
              t += tincr;
          }
          encode(c, frame, pkt, f);
      }

      /* flush the encoder */
      encode(c, NULL, pkt, f);

      fclose(f);

      av_frame_free(&amp;frame);
      av_packet_free(&amp;pkt);
      avcodec_free_context(&amp;c);

      return 0;
    }
    </output>

    I just want to know, where and how the .sw file is reading in the above audio encoding code ?

  • PHP-FFMpeg not converting (error with ffmpeg)

    13 août 2016, par Magurean Dan Sergiu

    I have installed ffmpeg server side with all the dependencies, updated it. And then installed PHP-FFMpeg with Composer. Tested that ffmpeg is instaled with a ssh conexion.

    root@host [/opt/ffmpeg]# ffmpeg
    ffmpeg version N-81322-ge8b355a Copyright (c) 2000-2016 the FFmpeg developers
    built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
    configuration: --disable-yasm
    libavutil      55. 28.100 / 55. 28.100
    libavcodec     57. 51.100 / 57. 51.100
    libavformat    57. 46.100 / 57. 46.100
    libavdevice    57.  0.102 / 57.  0.102
    libavfilter     6. 51.100 /  6. 51.100
    libswscale      4.  1.100 /  4.  1.100
    libswresample   2.  1.100 /  2.  1.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options]     outfile}...

    Use -h to get full help or, even better, run 'man ffmpeg'

    But when I try to convert a video file with a php script it throws me a very long error.
    PHP Code :

    &lt;?PHP
    include($_SERVER['DOCUMENT_ROOT']."/vendors/install/vendor/autoload.php");
    $ffmpeg = FFMpeg\FFMpeg::create();
    $video = $ffmpeg->open($_SERVER['DOCUMENT_ROOT'].'/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.wmv');
    $video
          ->filters()
          ->synchronize();
    $format = new FFMpeg\Format\Video\X264();
    $format->on('progress', function ($video, $format, $percentage) {
       echo "$percentage % transcoded";});
    $video
         ->save($format,$_SERVER['DOCUMENT_ROOT'].'/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.mp4');
    ?>

    Error displayed :

    <b>Fatal error</b>:  Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command '/usr/local/bin/ffmpeg' '-y' '-i' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.wmv' '-async' '1' '-metadata:s:v:0' 'start_time=0' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes57ad320a1b685j794u/pass-57ad320a1b716' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.mp4'' in /home/user/working/vendors/install/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100↵Stack trace:↵#0 /home/user/working/vendors/install/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner-&amp;gt;doExecutionFailure(''/usr/bin/ffmpe...')↵#1 / in <b>/home/user/working/vendors/install/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php</b> on line <b>168</b><br />↵"

    Then I have took the basic code displayed upwards and ran it directly through ssh.

    '/usr/local/bin/ffmpeg' '-y' '-i' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.wmv' '-async' '1' '-metadata:s:v:0' 'start_time=0' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes57ad320a1b685j794u/pass-57ad320a1b716' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.mp4'

    And this is the response I get :

    ffmpeg version N-81322-ge8b355a Copyright (c) 2000-2016 the FFmpeg developers
     built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
     configuration: --disable-yasm
     libavutil      55. 28.100 / 55. 28.100
     libavcodec     57. 51.100 / 57. 51.100
     libavformat    57. 46.100 / 57. 46.100
     libavdevice    57.  0.102 / 57.  0.102
     libavfilter     6. 51.100 /  6. 51.100
     libswscale      4.  1.100 /  4.  1.100
     libswresample   2.  1.100 /  2.  1.100
    Guessed Channel Layout for Input Stream #0.0 : stereo
    Input #0, asf, from '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.wmv':
     Metadata:
       SfOriginalFPS   : 299700
       WMFSDKVersion   : 11.0.6001.7000
       WMFSDKNeeded    : 0.0.0.0000
       comment         : Footage: Small World Productions, Inc; Tourism New Zealand | Producer: Gary F. Spradling | Music: Steve Ball
       title           : Wildlife in HD
       copyright       : © 2008 Microsoft Corporation
       IsVBR           : 0
       DeviceConformanceTemplate: AP@L3
     Duration: 00:00:30.09, start: 0.000000, bitrate: 6977 kb/s
       Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, 2 channels, fltp, 192 kb/s
       Stream #0:1(eng): Video: vc1 (Advanced) (WVC1 / 0x31435657), yuv420p, 1280x720, 5942 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc
    Unknown encoder 'libx264'

    My question is what to do next ? I have wasted 3 days to make this work and this is the furthest I have come. How can I test if libx264 is installed corectly ? And if it is not installed corectly how cand I reinstal or make it work ?