Recherche avancée

Médias (1)

Mot : - Tags -/copyleft

Autres articles (104)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

Sur d’autres sites (8032)

  • How can i create a portrait video using Android's MediaRecorder

    23 mars 2015, par urudroid

    I have an Android application which is able to record and play a videos in portrait mode, those features are working fine on Android phones.

    The issue comes up because this video is needed to be played also on iOS devices (after being shared through a server).

    iOS is not correctly showing the video as it looks "cropped", but videos recorded on iOS are played without issues.

    So, the main difference between videos created on Android and iOS’ is the size and the rotation.

    Im using CWAC-Camera library for preview and recording and ffmpeg to scale the video down to 320x568px (as this is the standard size for both Android and iOS apps).

    Here is the metadata from an video created from Android :

    General
    Complete name                            : android_video.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom
    File size                                : 447 KiB
    Duration                                 : 5s 596ms
    Overall bit rate                         : 654 Kbps
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00
    Writing application                      : Lavf56.4.101

    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L2.1
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 4 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 5s 406ms
    Bit rate                                 : 536 Kbps
    Width                                    : 568 pixels
    Height                                   : 320 pixels
    Display aspect ratio                     : 16:9
    Original display aspect ratio            : 16:9
    Rotation                                 : 270°
    Frame rate mode                          : Constant
    Frame rate                               : 14.985 fps
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.197
    Stream size                              : 354 KiB (79%)
    Writing library                          : x264 core 142
    Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=14 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Language                                 : English
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00

    Audio
    ID                                       : 2
    Format                                   : AAC
    Format/Info                              : Advanced Audio Codec
    Format profile                           : LC
    Codec ID                                 : 40
    Duration                                 : 5s 596ms
    Bit rate mode                            : Constant
    Bit rate                                 : 132 Kbps
    Channel(s)                               : 2 channels
    Channel(s)_Original                      : 1 channel
    Channel positions                        : Front: C
    Sampling rate                            : 44.1 KHz
    Compression mode                         : Lossy
    Stream size                              : 89.4 KiB (20%)
    Language                                 : English
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00

    And here is the metadata from the video created on iOS :

    General
    Complete name                            : ios_video.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media / Version 2
    Codec ID                                 : mp42
    File size                                : 673 KiB
    Duration                                 : 7s 38ms
    Overall bit rate                         : 783 Kbps
    Encoded date                             : UTC 2015-03-17 19:16:36
    Tagged date                              : UTC 2015-03-17 19:16:37

    Video
    ID                                       : 2
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : Main@L3.0
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 2 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 7s 33ms
    Bit rate                                 : 711 Kbps
    Width                                    : 320 pixels
    Height                                   : 568 pixels
    Display aspect ratio                     : 0.563
    Frame rate mode                          : Constant
    Frame rate                               : 30.000 fps
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.130
    Stream size                              : 610 KiB (91%)
    Title                                    : Core Media Video
    Encoded date                             : UTC 2015-03-17 19:16:36
    Tagged date                              : UTC 2015-03-17 19:16:37
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    Color range                              : Limited

    Audio
    ID                                       : 1
    Format                                   : AAC
    Format/Info                              : Advanced Audio Codec
    Format profile                           : LC
    Codec ID                                 : 40
    Duration                                 : 7s 38ms
    Source duration                          : 7s 105ms
    Bit rate mode                            : Constant
    Bit rate                                 : 64.0 Kbps
    Channel(s)                               : 2 channels
    Channel(s)_Original                      : 1 channel
    Channel positions                        : Front: C
    Sampling rate                            : 44.1 KHz
    Compression mode                         : Lossy
    Stream size                              : 56.8 KiB (8%)
    Source stream size                       : 57.2 KiB (9%)
    Title                                    : Core Media Audio
    Encoded date                             : UTC 2015-03-17 19:16:36
    Tagged date                              : UTC 2015-03-17 19:16:37

    The values width and height are inverted on Android, also the Rotation parameter is set to 270º (this is the rotation parameter for portrait videos).

    This is a sketch of how iOS’ videos look on iOS app :

    Videos recorded on iOS

    And this is how Android’s videos look on iOS app :

    enter image description here

    So, in order to get the videos correctly displayed both on iOS and Android i need to be able to set the width to 320 and height to 568 on Android. I tried it from several places (outside and inside CWAC-Camera library) but i always get a Camera.Parameters error.

    It is possible to do this on Android ?

    EDIT :

    This is the result i get when i set the rotation to 0 with ffmpeg :

    enter image description here

  • More Cinepak Madness

    20 octobre 2011, par Multimedia Mike — Codec Technology

    Fellow digital archaeologist Clone2727 found a possible fifth variant of the Cinepak video codec. He asked me if I cared to investigate the sample. I assured him I wouldn’t be able to die a happy multimedia nerd unless I have cataloged all possible Cinepak variants known to exist in the wild. I’m sure there are chemistry nerds out there who are ecstatic when another element is added to the periodic table. Well, that’s me, except with weird multimedia formats.

    Background
    Cinepak is a video codec that saw widespread use in the early days of digital multimedia. To date, we have cataloged 4 variants of Cinepak in the wild. This distinction is useful when trying to write and maintain an all-in-one decoder. The variants are :

    1. The standard type : Most Cinepak data falls into this category. It decodes to a modified/simplified YUV 4:2:0 planar colorspace and is often seen in AVI and QuickTime/MOV files.
    2. 8-bit greyscale : Essentially the same as the standard type but with only a Y plane. This has only been identified in AVI files and is distinguished by the file header’s video bits/pixel field being set to 8 instead of 24.
    3. 8-bit paletted : Again, this is identified by the video header specifying 8 bits/pixel for a Cinepak stream. There is essentially only a Y plane in the data, however, each 8-bit value is a palette index. The palette is transported along with the video header. To date, only one known sample of this format has even been spotted in the wild, and it’s classified as NSFW. It is also a QuickTime/MOV file.
    4. Sega/FILM CPK data : Sega Saturn games often used CPK files which stored a variant of Cinepak that, while very close the standard Cinepak, couldn’t be decoded with standard decoder components.

    So, a flexible Cinepak decoder has to identify if the file’s video header specified 8 bits/pixel. How does it distinguish between greyscale and paletted ? If a file is paletted, a custom palette should have been included with the video header. Thus, if video bits/pixel is 8 and a palette is present, use paletted ; else, use greyscale. Beyond that, the Cinepak decoder has a heuristic to determine how to handle the standard type of data, which might deviate slightly if it comes from a Sega CPK file.

    The Fifth Variant ?
    Now, regarding this fifth variant– the reason this issue came up is because of that aforementioned heuristic. Basically, a Cinepak chunk is supposed to store the length of the entire chunk in its header. The data from a Sega CPK file plays fast and loose with this chunk size and the discrepancy makes it easy to determine if the data requires special handling. However, a handful of files discovered on a Macintosh game called “The Journeyman Project : Pegasus Prime” have chunk lengths which are sometimes in disagreement with the lengths reported in the containing QuickTime file’s stsz atom. This trips the heuristic and tries to apply the CPK rules against Cinepak data which, aside from the weird chunk length, is perfectly compliant.

    Here are the first few chunk sizes, as reported by the file header (stsz atom) and the chunk :

    size from stsz = 7880 (0x1EC8) ; from header = 3940 (0xF64)
    size from stsz = 3940 (0xF64) ; from header = 3940 (0xF64)
    size from stsz = 15792 (0x3DB0) ; from header = 3948 (0xF6C)
    size from stsz = 11844 (0x2E44) ; from header = 3948 (0xF6C)
    

    Hey, there’s a pattern here. If they don’t match, then the stsz size is an even multiple of the chunk size (2x, 3x, or 4x in my observation). I suppose I could revise the heuristic to state that if the stsz size is 2x, 3x, 4x, or equal to the chunk header, qualify it as compliant Cinepak data.

    Of course it feels impure, but software engineering is rarely about programmatic purity. A decade of special cases in the FFmpeg / Libav codebases are a testament to that.

    What’s A Variant ?
    Suddenly, I find myself contemplating what truly constitutes a variant. Maybe this was just a broken encoder program making these files ? And for that, I assign it the designation of distinct variation, like some sort of special, unique showflake ?

    Then again, I documented Magic Carpet FLIC as being a distinct variant of the broader FLIC format (which has an enormous number of variants as well).

  • Custom buffer for FFMPEG

    3 décembre 2015, par nmarevic

    I have a question regarding buffer read with ffmpeg.
    Idea is as it follows : an outside module (can not change it) is providing me video stream in chunks of data and it is giving me input data and it’s size in bytes ("framfunction" function input parameters). I have to copy input data to a buffer and read it with ffmpeg (Zeranoe) and extract video frames. Each time I receive new data, my function "framfunction" will be called. All unprocessed data from a first run will be moved at the beginning of the buffer followed by a new data on the second run and so on. It is essentially based on source and Dranger tutorials. My current attempt is like this and just look at comments (I’ve left only ones regarding current buffer function) in code to get a picture what I want to do(I know it is messy and it works - sort of ; skipping some frames. Any suggestions around ffmpeg code and buffer design are welcome) :

    #include <iostream>
    #include <string>

    extern "C"
    {
    #include <libavformat></libavformat>avformat.h>
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libswscale></libswscale>swscale.h>
    #include <libavformat></libavformat>avio.h>
    #include <libavutil></libavutil>file.h>
    }
    struct buffer_data {
      uint8_t *ptr;
      size_t size;
    };

    static int read_packet(void *opaque, uint8_t *buf, int buf_size)
    {
      struct buffer_data *bd = (struct buffer_data *)opaque;
      buf_size = FFMIN(buf_size, bd->size);
      memcpy(buf, bd->ptr, buf_size);
      bd->ptr += buf_size;
      bd->size -= buf_size;
      return buf_size;
    }

    class videoclass
    {
    private:
      uint8_t* inputdatabuffer;
      size_t offset;

    public:
      videoclass();
      ~videoclass();
      int framfunction(uint8_t* inputbytes, int inputbytessize);
    };

    videoclass::videoclass()
      : inputdatabuffer(nullptr)
      , offset(0)
    {
      inputdatabuffer = new uint8_t[8388608]; //buffer where the input data will be stored
    }

    videoclass::~videoclass()
    {
      delete[] inputdatabuffer;
    }


    int videoclass::framfunction(uint8_t* inputbytes, int inputbytessize)
    {
      int i, videoStream, numBytes, frameFinished;
      AVFormatContext *pFormatCtx = NULL;
      AVCodecContext *pCodecCtx = NULL;
      AVIOContext   *avio_ctx = NULL;
      AVCodec   *pCodec = NULL;
      AVFrame   *pFrame = NULL;
      AVFrame   *pFrameRGB = NULL;
      AVPacket packet;
      uint8_t   *buffer = NULL;
      uint8_t   *avio_ctx_buffer = NULL;
      size_t   avio_ctx_buffer_size = 4096;
      size_t   bytes_processed = 0;
      struct buffer_data bd = { 0 };

      //if (av_file_map("sample.ts", &amp;inputbytes, &amp;inputbytessize, 0, NULL) &lt; 0)//
      //   return -1;

      memcpy(inputdatabuffer + offset, inputbytes, inputbytessize);//copy new data to buffer inputdatabuffer with offset calculated at the end of previous function run. In other words - cope new data after unprocessed data from a previous call
      offset += inputbytessize; //total number of bytes in buffer. Size of an unprocessed data from the last run + size of new data (inputbytessize)

      bd.ptr = inputdatabuffer;
      bd.size = offset;

      if (!(pFormatCtx = avformat_alloc_context()))
         return -1;
      avio_ctx_buffer = (uint8_t *)av_malloc(avio_ctx_buffer_size);
      avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size,0, &amp;bd, &amp;read_packet, NULL, NULL);
      pFormatCtx->pb = avio_ctx;

      av_register_all();
      avcodec_register_all();

      pFrame = av_frame_alloc();
      pFrameRGB = av_frame_alloc();

      if (avformat_open_input(&amp;pFormatCtx, NULL, NULL, NULL) != 0)
         return -2;
      if (avformat_find_stream_info(pFormatCtx, NULL) &lt; 0)
         return -3;

      videoStream = -1;
      for (i = 0; i &lt; pFormatCtx->nb_streams; i++)
         if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
            videoStream = i;
            break;
         }
      if (videoStream == -1)
         return -4;

      pCodecCtx = pFormatCtx->streams[videoStream]->codec;

      pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
      if (pCodec == NULL){
         std::cout &lt;&lt; "Unsupported codec" &lt;&lt; std::endl;
         return -5;
      }

      if (avcodec_open2(pCodecCtx, pCodec, NULL) &lt; 0)
         return -6;

      numBytes = avpicture_get_size(PIX_FMT_BGR24, pCodecCtx->width, pCodecCtx->height);
      buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

      avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_BGR24, pCodecCtx->width, pCodecCtx->height);

      while (av_read_frame(pFormatCtx, &amp;packet) >= 0){
         if (packet.stream_index == videoStream){
            avcodec_decode_video2(pCodecCtx, pFrame, &amp;frameFinished, &amp;packet);
            if (frameFinished){
               std::cout &lt;&lt; "Yaay, frame found" &lt;&lt; std::endl;
               }

         }
         av_free_packet(&amp;packet);

         bytes_processed = (size_t)pFormatCtx->pb->pos; //data which is processed so far (x bytes out of inputbytessize)??????????????????????????????
      }

      offset -= bytes_processed; //size of unprocessed data

      av_free(buffer);
      av_free(pFrameRGB);
      av_free(pFrame);

      avcodec_close(pCodecCtx);

      av_freep(&amp;avio_ctx->buffer);
      av_freep(&amp;avio_ctx);


      avformat_close_input(&amp;pFormatCtx);


      memmove(inputdatabuffer, inputdatabuffer + bytes_processed, offset);//move unprocessed data to begining of the main buffer

         return 0;
    }
    </string></iostream>

    Call of my function would be something like this

    WHILE(VIDEO_INPUT)
    {
       READ VIDEO DATA FROM INPUT BUFFER
       STORE DATA FROM INPUT BUFFER AND SIZE OP THAT DATA TO VARIABLES NEW_DATA AND NEW_DATA_SIZE
       CALL FUNCTION FRAMMUNCTION AND PASS NEW_DATA AND NEW_DATA_FUNCTION
       DO OTHER THINGS
    }

    What I would like to know is what is exact size of unprocessed data. Comments in code are showing my attempt but I think it is not good enough so I need some help with that issue.

    EDIT : magic question is how to get correct "bytes_processed" size. I’ve also made an pdf with explanation how my buffer should work pdf file
    Thanks