Recherche avancée

Médias (91)

Autres articles (74)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

Sur d’autres sites (11641)

  • Covert opengl framebuffer into ffmpeg encoded mp4 c++ [closed]

    14 mai 2022, par user19068953

    I want to make a program that takes an mp4 file as an input and draws something on top of it then gives the new video as an output. So far I have a program that takes a file name, have ffmpeg decode it and draw whatever i want with opengl (I have followed this tutorial that draws on top of the video separately : https://gist.github.com/hradec/a8b8ae0bf82891a5d853b06619839d9d) and have an opengl framebuffer. My question is how do put opengl's framebuffer on top of ffmpeg frames and generate a new video with it then give a new file as an output ? The framebuffer is allocated in fbo, so i want to encode it to ffmpeg, something like

    


     av_write_frame(state->fmt_ctx, &fbo) 


    


    is there a function like this that allows me to write frame data into a newly created video ?

    


    Here is my encoder :

    


        int VideoDecoder::write_frame()
{
    // Find a way to write OpenGL Frames here.
    av_packet_rescale_ts(&state->packet, VideoSt.Ctx->time_base, VideoSt.Stream->time_base);
    state->packet.stream_index = VideoSt.Stream->index;
    return av_interleaved_write_frame(state->fmt_ctx, &state->packet);
}


bool VideoDecoder::encode_video()
{

    // TODO: This is horrible fix this function.

    state->packet = { nullptr };
    av_init_packet(&state->packet);

    fflush(stdout);

    IMG_Buffer.SetNum(ColorBuffer.Num() * 4);
    uint8* DestPtr = nullptr;
    for (auto i = 0; i < ColorBuffer.Num(); i++)
    {
        DestPtr = &IMG_Buffer[i * 4];
        auto SrcPtr = ColorBuffer[i];
        *DestPtr++ = SrcPtr.R;
        *DestPtr++ = SrcPtr.G;
        *DestPtr++ = SrcPtr.B;
        *DestPtr++ = SrcPtr.A;
    }

    uint8* inData[1] = { IMG_Buffer.GetData() };


    sws_scale(SwsCtx, inData, InLineSize, 0, VideoSt.Ctx->height, VideoSt.Frame->data, VideoSt.Frame->linesize);

    VideoSt.Frame->pts = VideoSt.NextPts++;
    if (FFmpegEncode(VideoSt.Frame) < 0)
        return false;

    auto ret = WriteFrame();

    if (ret < 0)
    {
        auto errstr = FString(av_err2str(ret));
    }
    av_packet_unref(&state->packet);


    GotOutput = 0;
    auto ret = avcodec_send_frame(VideoSt.Ctx, frame);
    if (ret < 0 && ret != AVERROR_EOF) {
        auto errstr = FString(av_err2str(ret));
        return -1;
    }

    ret = avcodec_receive_packet(VideoSt.Ctx, &Pkt);
    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
        return 0;

    if (ret < 0)
    {
        auto errstr = FString(av_make_error_string(ret).c_str());
        av_packet_unref(&Pkt);
        return -1;
    }

    GotOutput = 1;
    return 0;


    for (GotOutput = 1; GotOutput; count++)
    {
        fflush(stdout);

        FFmpegEncode(nullptr);

        if (GotOutput)
        {
            auto ret = WriteFrame(false);
            if (ret < 0)
            {
                auto errstr = FString(av_err2str(ret));
            }
            av_packet_unref(&Pkt);
        }
    }

    auto ret = av_write_trailer(FmtCtx);
    if (ret < 0)
    {
        auto errstr = FString(av_err2str(ret));
    }
}


    


    and here is my simple frame buffer :

    


    bool OpenGLRenderer::alloc_frame_buffer()
{
    unsigned int fbo;
    glGenFramebuffers(1, &fbo);

    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) return false;

    glBindFramebuffer(GL_FRAMEBUFFER, fbo);

    unsigned int texture;
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 800, 600, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
}


    


  • avcodec/mpegvideo_enc : Reduce stack usage

    18 mai, par Andreas Rheinhardt
    avcodec/mpegvideo_enc : Reduce stack usage
    

    Multiple PutBitContexts are used when encoding partitioned
    frames. When there are multiple candidates for macroblock types,
    multiple states (namely the state before encoding the current MB,
    the best state among the ones already tried and the current one)
    need to be kept ; duplicates of the PutBitContexts are among this
    state. The temporary buffers for them are kept on the stack
    in encode_thread() and their size is quite generous (MAX_MB_SIZE
    - 3000 bytes). This commit uses tighter bounds, bringing the
    size of the pb2 buffer down to 15 bytes.

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavcodec/mpeg4videoenc.h
    • [DH] libavcodec/mpegvideo_enc.c
  • fftools/ffmpeg_filter : do not assume av_buffersrc_get_nb_failed_requests()>0

    7 mars 2024, par Anton Khirnov
    fftools/ffmpeg_filter : do not assume av_buffersrc_get_nb_failed_requests()>0
    

    Apparently it can happen that avfilter_graph_request_oldest() returns
    EAGAIN, yet av_buffersrc_get_nb_failed_requests() returns 0 for every
    input.

    Works around #10795, though the root issue is most likely in the
    scale2ref filter.

    • [DH] fftools/ffmpeg_filter.c