Recherche avancée

Médias (91)

Autres articles (49)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

Sur d’autres sites (6389)

  • Making a lossless video from a sequence of png image buffers using ffmpeg and c++

    3 juillet 2013, par Ven

    I am trying to create a movie file form a sequence of png buffers.
    Can some one help me in understating how to create loss less mpeg4 video file from png buffers using ffmpeg and c++.
    I know we can do this by command line if you are using .png files but i would like implement using c++ as i am creating loss less png buffer from raw data.

  • Why frame->pts increases by 20, rather than by 1 ?

    19 mars 2013, par user1914692

    Following the exmaples of ffmpeg : decoding_encoding.c and filtering_video.c, I process one video file taken by iPhone. The video file : .mov, video dimensions ; 480x272, video Codec : H.264/AVC, 30 frames per second, bitrate : 605 kbps.

    I first extract each frame, which is YUV.
    I convert YUV to RGB24, and process the RGB24, then write the RGB24 to a .ppm file. It shows the .ppm file is correct.

    Then I plan to encode processed RGB24 frames to a video file.
    Since MPEG does not support RGB24 picture format, I used AV_CODEC_ID_HUFFYUV.
    But the output video file (showing 18.5 MB) does not play. Movie Player on Ubuntu claims an error : Could not determine type of stream.
    I also tried it on VCL. It simply does not work, without any error information.

    My second questions is :
    For each extracted fram from the input video file, I get its pts as follows according to filtering_video.c :

    frame->pts = av_frame_get_best_effort_timestamp(frame);

    I print out each frame's pts, and find that it increases by 20, like below :

    pFrameRGB_count: 0,  frame->pts: 0
    pFrameRGB_count: 1,  frame->pts: 20
    pFrameRGB_count: 2,  frame->pts: 40
    pFrameRGB_count: 3,  frame->pts: 60

    Where frame is the extracted frame from the input video, and pFrameRGB_count is the count for processed frame in RGB24 form.

    Why are they wrong ?

  • Video encoding and keyframes

    24 février 2013, par Tishu

    I am transcoding a video frame by frame and using x264+ffmpeg to encode. The original video plays fine, but the first few frames of my transcoded vide show grey artefacts. I understand this is because of time compression and these artefacts disappear after a few frames.

    See these two pictures which are the first and second frames. The third frame is normal (i.e. no grey artefact and not blurry like the second one)
    First frame
    Second frame

    How can I force the first frame to be a key frame (ie fully encoded in my output video) so that these artefacts do not show ?

    Edit - more details

    Here is what I am doing more in details. I used bit form differents tutorials to read a video frame by frame and reencode each frame to a new video. My encoding parameters are the following :

    avcodec_get_context_defaults3(c, *codec);
    c->codec_id = codec_id;
    c->bit_rate = output_bitrate;
    /* Resolution must be a multiple of two. */
    c->width    = output_width;
    c->height   = output_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. */
    st->r_frame_rate.num = output_framerate_num;
    st->r_frame_rate.den = output_framerate_den;
    c->time_base.den = output_timebase_den;
    c->time_base.num = output_timebase_num;
    c->gop_size      = 3; /* 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;
    }
    c->max_b_frames = 2;
    c->scenechange_threshold = 0;
    c->rc_buffer_size = 0;
    c->me_method = ME_ZERO;

    Then I process each frame, probably doing something wrong there. The decoding bit :

    while(av_read_frame(gFormatCtx, &packet)>=0) {
       // Is this a packet from the video stream?
       if(packet.stream_index==gVideoStreamIndex) {
           // Decode video frame
           avcodec_decode_video2(gVideoCodecCtx, pCurrentFrame, &frameFinished, &packet);
           // Did we get a video frame?
           if(frameFinished) {
               [...]
               if(firstPts == -999) /*Initial value*/
                   firstPts = packet.pts;
               deltaPts = packet.pts - firstPts;
               double seconds = deltaPts*av_q2d(gFormatCtx->streams[gVideoStreamIndex]->time_base);
               [...]
               muxing_writeVideoFrame(pCurrentFrame, packet.pts);
           }
       }
    }

    The actual writing :

    int muxing_writeVideoFrame(AVFrame *frame, int64_t pts)
    {
    frameCount = frameCount +1;
    if(frameCount > 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_st && audio_st && audio_pts < video_pts))
       {
           frame->pts = pts;//av_rescale_q(frame_count, video_st->codec->time_base, video_st->time_base);
           write_video_frame(oc, video_st, frame);
       }
    }

    return 0;
    }

    static int write_video_frame(AVFormatContext *oc, AVStream *st, AVFrame *frame)
    {
       int ret;
       static struct SwsContext *sws_ctx;
       //LOGI(10, frame_count);
       AVCodecContext *c = st->codec;

       /* encode the image */
       AVPacket pkt;
       int got_output;
       av_init_packet(&pkt);
       pkt.data = NULL;    // packet data will be allocated by the encoder
       pkt.size = 0;
    ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
    if (ret < 0) {
       fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
       exit(1);
    }
    /* If size is zero, it means the image was buffered. */
    if (got_output) {
       if (c->coded_frame->key_frame)
           pkt.flags |= AV_PKT_FLAG_KEY;
       pkt.stream_index = st->index;
       /* Write the compressed frame to the media file. */
       ret = av_interleaved_write_frame(oc, &pkt);
    } else {
       ret = 0;
    }

       if (ret != 0) {
           LOGI(10, av_err2str(ret));
           exit(1);
       }
       frame_count++;
       return got_output;
    }