Recherche avancée

Médias (3)

Mot : - Tags -/pdf

Autres articles (68)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

Sur d’autres sites (4995)

  • FFmpeg : Decoding AVPackets received from UDP socket

    8 août 2022, par strong_kobayashi

    I am trying to stream video frames encoded with FFmpeg from an Unity game to a client UI via UDP. To be specific, I am sending AVPackets (which contain the compressed frames, as far as I understand) from the server, which are then, on the client side, extracted as follows :

    



    inline UDPpacket* SDLGameClient::receiveData()
{
    if(SDLNet_UDP_Recv(socket, packet))
        return packet;
    else
        return NULL;
}

int main()
{
    ...
    // Initialize UDP
    ...
    UDPpacket *udpPacket;

    int i = 0;

    for(;;)
    {
        udpPacket = client->receiveData();

        if(udpPacket != nullptr)
        {
            i++;
            std::cout << "Packet " << i << " received!" << std::endl;

            AVPacket packet;
            av_init_packet(&packet);

            packet.data = new uint8_t[udpPacket->len];
            memcpy(packet.data, udpPacket->data, udpPacket->len);
            packet.size = udpPacket->len;

            ...


    



    To realize networking, I use the SDL_net library. Fragmenting, sending and receiving the packets seem to work without any problem. My question is, how do I decode the incoming AVPackets and stream the frames recorded in Unity to the client ?
I am aware that I need to use avcodec_send_packet and avcodec_receive_frame for decoding (since avcodec_decode_video2, that is used in many example decoding code, is deprecated), but when I do something like this :

    



    int ret = avcodec_send_packet(codecContext, &packet);
if(ret < 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
    std::cout << "avcodec_send_packet: " << ret << std::endl;
else
{
    while(ret >= 0)
    {
        ret = avcodec_receive_frame(codecContext, frame);
        if(ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
            std::cout << "avcodec_receive_frame: " << ret << std::endl;

        std::cout << "Frame: " << codecContext->frame_number << std::endl;
    }
}

av_packet_unref(packet);


    



    ret always returns a negative value (-22), so perhaps something is wrong with the AVPackets, or I'm sending the frames way too fast, I really have no clue :/

    



    Thanks in advance for any help !

    


  • FFMPEG and DirectX Capture in C++

    13 décembre 2016, par tankyx

    I have a system that allows me to capture a window and save it as a mp4, using ffmpeg. I use gdigrab to capture the frame, but it is fairly slow (60ms per av_read_frame calls)

    I know I can capture a game using the DirectX API, but I don’t know how to convert the resulting BMP to an AVFrame.

    The following code is the DirectX code I use to capture the frame

    extern void* pBits;
    extern IDirect3DDevice9* g_pd3dDevice;
    IDirect3DSurface9* pSurface;
    g_pd3dDevice->CreateOffscreenPlainSurface(ScreenWidth, ScreenHeight,
                                         D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH,
                                         &pSurface, NULL);
    g_pd3dDevice->GetFrontBufferData(0, pSurface);
    D3DLOCKED_RECT lockedRect;
    pSurface->LockRect(&lockedRect,NULL,
                  D3DLOCK_NO_DIRTY_UPDATE|
                  D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)));
    for( int i=0 ; i < ScreenHeight ; i++)
    {
       memcpy( (BYTE*) pBits + i * ScreenWidth * BITSPERPIXEL / 8 ,
            (BYTE*) lockedRect.pBits + i* lockedRect.Pitch ,
            ScreenWidth * BITSPERPIXEL / 8);
    }
    g_pSurface->UnlockRect();
    pSurface->Release();

    And here is my read loop :

    {
       while (1) {
       if (av_read_frame(pFormatCtx, &packet) < 0 || exit)
           break;
       if (packet.stream_index == videoindex) {
           // Decode video frame
           av_packet_rescale_ts(&packet, { 1, std::stoi(pParser->GetVal("video-fps")) }, pCodecCtx->time_base);
           avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);

           if (frameFinished) {
               pFrame->pts = i;
               i++;
               sws_scale(sws_ctx, (uint8_t const * const *)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);
               pFrameRGB->pts = pFrame->pts;
               enc.encodeFrame(pFrameRGB);

       }
       // Free the packet that was allocated by av_read_frame
       av_free_packet(&packet);
    }

    How can I create an AVFrame using the bmp I have, without using the av_read_frame ?

  • avcodec/amfenc : Implement async_depth option

    7 novembre 2024, par Cameron Gutman
    avcodec/amfenc : Implement async_depth option
    

    This option, which is also available on other FFmpeg hardware encoders,
    allows the user to trade throughput for reduced output latency. This is
    useful for ultra low latency applications like game streaming.

    Signed-off-by : Cameron Gutman <aicommander@gmail.com>

    • [DH] libavcodec/amfenc.c
    • [DH] libavcodec/amfenc_av1.c
    • [DH] libavcodec/amfenc_h264.c
    • [DH] libavcodec/amfenc_hevc.c