Recherche avancée

Médias (1)

Mot : - Tags -/publishing

Autres articles (30)

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

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

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

Sur d’autres sites (4687)

  • Convert raw yuv to mp4 crashed on android

    19 décembre 2013, par Sunderr

    Here is my steps :

    1. Decode a jpeg file to rgb565 ;(Success) ;

    2. Convert rgb565 to yuv420 ;(Not sure if it works, function "Bitmap2Yuv420")

    3. Convert yuv420 to mp4. (Crash when call avcodec_open2) ;

    And that is the codes :

    void ADKJpegDecoder::Bitmap2Yuv420(const char * outfilename) {
    unsigned char *destination = new unsigned char[m_Width * m_Height
           * m_BytesPerPixel / 2];
    unsigned char* rgb = m_RawImage;
    size_t image_size = m_Width * m_Height;
    size_t upos = image_size;
    size_t vpos = upos + upos / 4;
    size_t i = 0;

    for (size_t line = 0; line < m_Height; ++line) {
       if (!(line % 2)) {
           for (size_t x = 0; x < m_Width; x += 2) {
               char r = rgb[3 * i];
               char g = rgb[3 * i + 1];
               char b = rgb[3 * i + 2];

               destination[i++] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;

               destination[upos++] = ((-38 * r + -74 * g + 112 * b) >> 8)
                       + 128;
               destination[vpos++] = ((112 * r + -94 * g + -18 * b) >> 8)
                       + 128;

               r = rgb[3 * i];
               g = rgb[3 * i + 1];
               b = rgb[3 * i + 2];

               destination[i++] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;
           }
       } else {
           for (size_t x = 0; x < m_Width; x += 1) {
               char r = rgb[3 * i];
               char g = rgb[3 * i + 1];
               char b = rgb[3 * i + 2];

               destination[i++] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;
           }
       }
    }

    ADKVideoEncoder::getInstance()->startEncodeVideo(destination);
    delete[] destination;

    }

    void ADKVideoEncoder::startEncodeVideo(unsigned char* rawDatas) {
    AVFormatContext* oc;
    AVOutputFormat* fmt;
    AVStream* video_st;
    AVCodecContext* c;

    double video_pts;
    uint8_t* video_outbuf;
    AVFrame* picture;
    int size;
    int ret;
    int video_outbuf_size;

    const char* filename = "/sdcard/test.mpg";

    av_register_all();

    fmt = av_guess_format(NULL, filename, NULL);
    oc = avformat_alloc_context();
    oc->oformat = fmt;
    snprintf(oc->filename, sizeof(oc->filename), "%s", filename);

    video_st = NULL;
    if (fmt->video_codec != CODEC_ID_NONE) {
       video_st = av_new_stream(oc, 0);
       c = video_st->codec;
       c->codec_id = fmt->video_codec;
       c->codec_type = AVMEDIA_TYPE_VIDEO;
       c->bit_rate = 400000;
       c->width = 320;
       c->height = 480;
       c->time_base.num = 1;
       c->time_base.den = 1;
       c->gop_size = 12;
       c->pix_fmt = PIX_FMT_YUV420P;
       c->max_b_frames = 0;
       if (!strcmp(oc->oformat->name, "mp4")
               || !strcmp(oc->oformat->name, "mov")
               || !strcmp(oc->oformat->name, "3gp")) {
           c->flags |= CODEC_FLAG_GLOBAL_HEADER;
       }
    }

    av_dump_format(oc, 0, filename, 1);
    if (video_st) {
       AVCodec* codec = avcodec_find_encoder(c->codec_id);
       if (!codec) {
           return;
       }
       AVDictionary *optionsDict = NULL;
       if (avcodec_open2(c, codec, &optionsDict) < 0) {
           return;
       }
       if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
           video_outbuf_size = 20000;
           video_outbuf = (uint8_t*) av_malloc(video_outbuf_size);
       }
       picture = avcodec_alloc_frame();
       size = avpicture_get_size(c->pix_fmt, c->width, c->height);
       avpicture_fill((AVPicture*) picture, rawDatas, c->pix_fmt, c->width,
               c->height);
    }

    if (!(fmt->flags & AVFMT_NOFILE)) {
       if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
           return;
       }
    }
    avformat_write_header(oc, 0);

    if (video_st) {
       video_pts = (double) (video_st->pts.val * video_st->time_base.num
               / video_st->time_base.den);
    } else {
       video_pts = 0.0;
    }
    if (!video_st/* || video_pts >= 5.0*/) {
       return;
    }
    c = video_st->codec;
    size = c->width * c->height;

    picture->data[0] = rawDatas;
    picture->data[1] = rawDatas + size;
    picture->data[2] = rawDatas + size * 5 / 4;

    if (oc->oformat->flags & AVFMT_RAWPICTURE) {
       AVPacket pkt;
       av_init_packet(&pkt);
       pkt.flags |= AV_PKT_FLAG_KEY;
       pkt.stream_index = video_st->index;
       pkt.data = (uint8_t*) picture;
       pkt.size = sizeof(AVPicture);
       ret = av_write_frame(oc, &pkt);
    } else {
       int out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size,
               picture);
       if (out_size > 0) {
           AVPacket pkt;
           av_init_packet(&pkt);
           pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base,
                   video_st->time_base);
           if (c->coded_frame->key_frame) {
               pkt.flags |= AV_PKT_FLAG_KEY;
           }
           pkt.stream_index = video_st->index;
           pkt.data = video_outbuf;
           pkt.size = out_size;
           ret = av_write_frame(oc, &pkt);
       }
    }

    if (video_st) {
       avcodec_close(video_st->codec);
       av_free(picture);
       av_free(video_outbuf);
    }
    av_write_trailer(oc);
    for (int i = 0; i < oc->nb_streams; i++) {
       av_freep(&oc->streams[i]->codec);
       av_freep(&oc->streams[i]);
    }
    if (!(fmt->flags & AVFMT_NOFILE)) {
       avio_close(oc->pb);
    }
    av_free(oc);

    }

    So can anyone find out the problem ? Thanks very much ! ;

  • ffmpeg mysteriously adding start delay [migrated]

    13 janvier 2014, par swizzcheez

    When converting a mp4 to TS, I am observing ffmpeg adding a "start" delay that the input file did not seem to possess. For my input, ffprobe reveals :

    ffprobe version N-57943-g7b76976 Copyright (c) 2007-2013 the FFmpeg developers
     built on Nov  6 2013 14:00:40 with gcc 4.4.5 (Debian 4.4.5-8)
     configuration: --enable-libx264 --enable-gpl
     libavutil      52. 52.100 / 52. 52.100
     libavcodec     55. 41.100 / 55. 41.100
     libavformat    55. 21.100 / 55. 21.100
     libavdevice    55.  5.100 / 55.  5.100
     libavfilter     3. 90.102 /  3. 90.102
     libswscale      2.  5.101 /  2.  5.101
     libswresample   0. 17.104 /  0. 17.104
     libpostproc    52.  3.100 / 52.  3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4-in-7A8FEADA-5EA6-11E3-AD13-4DD2258FBC88.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42mp41
       creation_time   : 2013-11-08 15:15:12
     Duration: 00:00:11.56, start: 0.000000, bitrate: 2994 kb/s
       Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 2807 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
       Metadata:
         creation_time   : 2013-11-08 15:15:12
         handler_name    : ?Mainconcept Video Media Handler
       Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
       Metadata:
         creation_time   : 2013-11-08 15:15:12
         handler_name    : #Mainconcept MP4 Sound Media Handler

    But when processed using ffmpeg :

    ffmpeg -i '/tmp/test-no-qp.C2162DFC-6297-11E3-A68D-05E505A3FB93/output.mp4-in-7A8FEADA-5EA6-11E3-AD13-4DD2258FBC88.mp4' -s 1920x1080 -preset ultrafast -f mpegts -c:v libx264 -qp:v 18 `enter code here`

    I get an extra start delay :

    (Snipping the same headers from the input side)
    Input #0, mpegts, from 'output.mp4-out-7A8FEADA-5EA6-11E3-AD13-4DD2258FBC88.mp4':
     Duration: 00:00:11.55, start: 1.400000, bitrate: 1985 kb/s
     Program 1
       Metadata:
         service_name    : Service01
         service_provider: FFmpeg
       Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
       Stream #0:1[0x101](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s

    Duration seems to have been adjusted as well, but I didn't ask for the adjustment. How do I get rid of that ? What did I do that triggered that effect ? Is there something else about my ffmpeg line that looks off ?

    (ffmpeg version is the same as the ffprobe above.)

  • Error in video streaming using libavformat : VBV buffer size not set, muxing may fail

    15 janvier 2014, par Blue Sky

    I stream a video using libavformat as follows :

    static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,
                           enum AVCodecID codec_id)
    {
    AVCodecContext *c;
    AVStream *st;
    /* find the encoder */
    *codec = avcodec_find_encoder(codec_id);
    if (!(*codec)) {
       fprintf(stderr, "Could not find encoder for '%s'\n",
               avcodec_get_name(codec_id));
       exit(1);
    }
    st = avformat_new_stream(oc, *codec);
    if (!st) {
       fprintf(stderr, "Could not allocate stream\n");
       exit(1);
    }
    st->id = oc->nb_streams-1;
    c = st->codec;
    switch ((*codec)->type) {
    case AVMEDIA_TYPE_AUDIO:
       c->sample_fmt  = (*codec)->sample_fmts ?
           (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
       c->bit_rate    = 64000;
       c->sample_rate = 44100;
       c->channels    = 2;
       break;
    case AVMEDIA_TYPE_VIDEO:
       c->codec_id = codec_id;
       c->bit_rate = 400000;
       /* Resolution must be a multiple of two. */
       c->width    = outframe_width;
       c->height   = outframe_height;
       /* timebase: This is the fundamental unit of time (in seconds) in terms
        * of which frame timestamps are represented. For fixed-fps content,
        * timebase should be 1/framerate and timestamp increments should be
        * identical to 1. */
       c->time_base.den = STREAM_FRAME_RATE;
       c->time_base.num = 1;
       c->gop_size      = 12; /* emit one intra frame every twelve frames at most */
       c->pix_fmt       = STREAM_PIX_FMT;
       if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
           /* just for testing, we also add B frames */
           c->max_b_frames = 2;
       }
       if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
           /* Needed to avoid using macroblocks in which some coeffs overflow.
            * This does not happen with normal video, it just happens here as
            * the motion of the chroma plane does not match the luma plane. */
           c->mb_decision = 2;
       }
    break;
    default:
       break;
    }
    /* Some formats want stream headers to be separate. */
    if (oc->oformat->flags & AVFMT_GLOBALHEADER)
       c->flags |= CODEC_FLAG_GLOBAL_HEADER;
    return st;
    }

    But when I run this code, I get the following error/warning :

    [mpeg @ 01f3f040] VBV buffer size not set, muxing may fail

    Do you know how I can set the VBV buffer size in the code ? In fact, when I use ffplay to display the streamed video, ffplay doesn't show anything for short videos but for long videos, it start displaying the video immediately. So, it looks like ffplay needs a buffer to be filled up by some amount so that it can start displaying the stream. Am I right ?