Recherche avancée

Médias (91)

Autres articles (95)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (12382)

  • ffmpeg avformat / avcodec unexpected pts / dts values are written to output when encoding video

    2 août 2022, par ray_ray_ray

    I try to follow the examples for encoding video using ffmpeg C API given in https://ffmpeg.org/doxygen/trunk/transcoding_8c-example.html and https://ffmpeg.org/doxygen/trunk/encode_video_8c-example.html

    


    I put together the following code to do some very simple encoding

    


    void encode(AVFormatContext* fmt_ctx, AVCodecContext* enc_ctx, AVFrame *frame, AVPacket *pkt) {
    int ret = avcodec_send_frame(enc_ctx, frame);

    while (ret >= 0) {
        ret = avcodec_receive_packet(enc_ctx, pkt);
        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
            return;

        } else if (ret < 0) {
            std::printf("Error during encoding\n");
            exit(1);
        }

        std::printf("pts=%zd dts=%zd\n", pkt->pts, pkt->dts);
        av_interleaved_write_frame(fmt_ctx, pkt);
    }
}

int main() {
    av_log_set_level(AV_LOG_ERROR);

    AVFormatContext* fmt_ctx = nullptr;
    avformat_alloc_output_context2(&fmt_ctx, NULL, NULL, "f:/videoOut.mp4");
    AVStream* videoStream = avformat_new_stream(fmt_ctx, NULL);
    const AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_H264);
    AVCodecContext* codec_ctx = avcodec_alloc_context3(codec);

    int w = 100;
    int h = 100;
    codec_ctx->width = w;
    codec_ctx->height = h;
    codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
    codec_ctx->time_base = { 1, 10 };
    codec_ctx->framerate = { 10, 1 };
    codec_ctx->gop_size = 20;
    codec_ctx->max_b_frames = 4;

    avcodec_parameters_from_context(videoStream->codecpar, codec_ctx);
    avio_open(&fmt_ctx->pb, fmt_ctx->url, AVIO_FLAG_WRITE);
    avformat_write_header(fmt_ctx, NULL);

    AVPacket* videoPacket = av_packet_alloc();
    avcodec_open2(codec_ctx, codec, NULL);
    AVFrame* frame = av_frame_alloc();
    frame->format = codec_ctx->pix_fmt;
    frame->width = codec_ctx->width;
    frame->height = codec_ctx->height;

    av_frame_get_buffer(frame, 0);
    av_frame_make_writable(frame);

    for (int i = 0; i < 25; i++) {
        av_frame_make_writable(frame);

        for (int y = 0; y < codec_ctx->height; y++) {
            for (int x = 0; x < codec_ctx->width; x++) {
                frame->data[0][y * frame->linesize[0] + x] = i * 4;
            }
        }
        for (int y = 0; y < codec_ctx->height / 2; y++) {
            for (int x = 0; x < codec_ctx->width / 2; x++) {
                frame->data[1][y * frame->linesize[1] + x] = 20 + i * 2;
                frame->data[2][y * frame->linesize[2] + x] = 20 + i * 2;
            }
        }

        frame->pts = i;
        encode(fmt_ctx, codec_ctx, frame, videoPacket);
    }

    encode(fmt_ctx, codec_ctx, nullptr, videoPacket);
    
    av_write_trailer(fmt_ctx);
    avio_close(fmt_ctx->pb);

    av_packet_free(&videoPacket);
    avcodec_free_context(&codec_ctx);
    av_frame_free(&frame);
    avformat_free_context(fmt_ctx);
}


    


    this will output the following pts and dts values directly before handing over to av_interleaved_write

    


    pts=0 dts=-2
pts=5 dts=-1
pts=2 dts=0
pts=1 dts=1
pts=3 dts=2
pts=4 dts=3
pts=10 dts=4
pts=7 dts=5
pts=6 dts=6
pts=8 dts=7
pts=9 dts=8
pts=15 dts=9
pts=12 dts=10
pts=11 dts=11
pts=13 dts=12
pts=14 dts=13
pts=19 dts=14
pts=17 dts=15
pts=16 dts=16
pts=18 dts=17
pts=20 dts=18
pts=24 dts=19
pts=22 dts=20
pts=21 dts=21
pts=23 dts=22


    


    But when I afterwards examine the written file using the command ffprobe videoOut.mp4 -show_frames > frames.txt those values end up being identical for each frame, starting at pts=0 / pkt_dts=0 for the first frame, increasing for each frame, and the last two frames even end up having pts=23 / pkt_dts=N/A and pts=24 / pkt_dts=N/A respectively.

    


    This seems wrong to me ? These values should not be the same at least for B frames, right ? And there certainly are B frames in the written video. Why are these values reset at all somewhere inside the av_interleaved_write function ? Is there some setting I am missing ?

    


  • ffmpeg combining three images into a looped video

    28 juin 2018, par Armand

    So I have three images that I need to combine into a 10 second video, I have searched around and in the end I came up with the following command, it is generating a video but not what I expected.

    ffmpeg.exe -loop 1 -framerate 1 -i 20180627124135055101050.JPG -i 20180627124135056101051.JPG -i 20180627124135057101052.JPG -i 20180627124135056101051.JPG -vf framestep=4,setpts=N/FRAME_RATE/TB -c:v mpeg4 -t 10 video.mp4

    It is currently generating a video of 12 seconds in length, but it is also only showing the first image, I have played around with the framerate option and the framestep option values but all change that I can see is in the length of the video, it never actually shows the images in the order I need them to display. What I basically need as a result is a giff of the 3 images in the order image 1, image 2, image 3, image 2. But as a mp4 of 10 seconds long.

    Any assistance would be greatly appreciated

    EDIT 1

    So I have made some progress, I am now using the following command to get the correct video output, but now I need it to loop so the total video length can be 10 seconds

    ffmpeg -loop 1 -framerate 25 -t 0.25 -i 20180627124135055101050.JPG  -loop 1 -framerate 24 -t 0.25 -i 20180627124135056101051.JPG -loop 1 -framerate 24 -t 0.25 -i 20180627124135057101052.JPG -loop 1 -framerate 24 -t 0.25 -i 20180627124135056101051.JPG -filter_complex "[0][1][2][3]concat=n=4:v=1:a=0"  video.mp4
  • Corrupted output video from ffmpeg combining few videos

    22 février 2019, par David

    Ran ffmpeg on Windows 10 to concatanate 4 videos in this sequence :
    introduction.mp4 1.mp4 2.mp4 3.mp4
    to create combined.mp4

    1.mp4 2.mp4 and 3.mp4 were created identically by ffmpeg from a longer video

    When playing combined.mp4 the introduction.mp4 part was OK, but after that the video stopped.
    If I jumped forward got green and other color blank screen

    This was the ffmpeg command to concatenate :

    set parm=-probesize 1000 -analyzeduration 100000000 -fpsprobesize 1000
    c:/tools/ffmpeg64/bin/ffmpeg %parm% -loglevel warning -y -strict -2 -f concat -i videoList.txt -c copy combined.mp4

    This was the videoList.txt file :

    file introduction.mp4
    file 1.mp4
    file 2.mp4
    file 3.mp4

    The input files attributes are not the same

    introduction.mp4 1456x1028 25fps 111knps total 175kbps

    1.mp4 1280x720 29.97fpd 1107kbps total 1233kbps

    OUTPUT : combined.mp4 1456x1028 4.11 fps 1456kbps total 151kbps