Recherche avancée

Médias (2)

Mot : - Tags -/plugins

Autres articles (43)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Encodage et transformation en formats lisibles sur Internet

    10 avril 2011

    MediaSPIP transforme et ré-encode les documents mis en ligne afin de les rendre lisibles sur Internet et automatiquement utilisables sans intervention du créateur de contenu.
    Les vidéos sont automatiquement encodées dans les formats supportés par HTML5 : MP4, Ogv et WebM. La version "MP4" est également utilisée pour le lecteur flash de secours nécessaire aux anciens navigateurs.
    Les documents audios sont également ré-encodés dans les deux formats utilisables par HTML5 :MP3 et Ogg. La version "MP3" (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

Sur d’autres sites (4790)

  • FFMPEG and STB_Image Create awful Picture

    9 février 2023, par murage kibicho

    I was learning how to use the FFMPEG C api and I was trying to encode a jpeg into a MPEG file. I load the JPEG into (unsigned char *) using the stb-image library. Then I create a (uint8_t *) and copy my rgb values. Finally, I convert RGB to YUV420 using sws_scale. However, a portion of my image blurs out when I perform the encoding.Bad Image
/
This is the original imageoriginal image

    
Perhaps I allocate my frame buffer incorrectly ?

    


    ret = av_frame_get_buffer(frame, 0);


    


    
This is my entire program

    


    #define STB_IMAGE_IMPLEMENTATION&#xA;#include "stb_image.h"&#xA;#define STB_IMAGE_WRITE_IMPLEMENTATION&#xA;#include "stb_image_write.h"&#xA;#define STB_IMAGE_RESIZE_IMPLEMENTATION&#xA;#include "stb_image_resize.h"&#xA;#include &#xA;&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;//gcc stack.c -lm -o stack.o `pkg-config --cflags --libs libavformat libavcodec libswresample libswscale libavutil` &amp;&amp; ./stack.o&#xA;&#xA;/*&#xA;int i : pts of current frame&#xA;*/&#xA;void PictureToFrame(int i, AVFrame *frame, int height, int width)&#xA;{&#xA;    //Use stb image to get rgb values&#xA;        char *fileName = "profil.jpeg";&#xA;        int imageHeight = 0;&#xA;        int imageWidth = 0;&#xA;        int colorChannels = 0;&#xA;        int arrayLength = 0;&#xA;    unsigned char *image = stbi_load(fileName,&amp;imageWidth,&amp;imageHeight,&amp;colorChannels,0);&#xA;    &#xA;    printf("(height: %d, width: %d)\n",imageHeight, imageWidth);&#xA;    assert(colorChannels == 3 &amp;&amp; imageHeight == height &amp;&amp; imageWidth == width);&#xA;    &#xA;    //Convert unsigned char * to uint8_t *&#xA;    arrayLength = imageHeight * imageWidth * colorChannels;&#xA;    uint8_t *rgb = calloc(arrayLength, sizeof(uint8_t));&#xA;    int j = arrayLength-1;&#xA;    for(int i = 0; i &lt; arrayLength; i&#x2B;&#x2B;)&#xA;    {&#xA;        rgb[i] = (uint8_t) image[i];&#xA;        }&#xA;        &#xA;        //Use SwsContext to scale RGB to YUV420P and write to frame&#xA;        const int in_linesize[1] = { 3* imageWidth};&#xA;        struct SwsContext *sws_context = NULL;&#xA;        sws_context = sws_getCachedContext(sws_context,&#xA;            imageWidth, imageHeight, AV_PIX_FMT_RGB24,&#xA;            imageWidth, imageHeight, AV_PIX_FMT_YUV420P,&#xA;            0, 0, 0, 0);&#xA;        sws_scale(sws_context, (const uint8_t * const *)&amp;rgb, in_linesize, 0,&#xA;            imageHeight, frame->data, frame->linesize);&#xA;        //Save frame pts&#xA;        frame->pts = i;&#xA;        &#xA;        //Free alloc&#x27;d data&#xA;        stbi_image_free(image);&#xA;        sws_freeContext(sws_context);&#xA;        free(rgb);&#xA;}&#xA;static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, FILE *outfile)&#xA;{&#xA;    int returnValue;&#xA;    /* send the frame to the encoder */&#xA;    if(frame)&#xA;    {&#xA;        printf("Send frame %3"PRId64"\n", frame->pts);&#xA;    }&#xA;        returnValue = avcodec_send_frame(enc_ctx, frame);&#xA;    if(returnValue &lt; 0)&#xA;    {&#xA;        printf("Error sending a frame for encoding\n");&#xA;        return;&#xA;    }&#xA;    while(returnValue >= 0)&#xA;    {&#xA;        returnValue = avcodec_receive_packet(enc_ctx, pkt);&#xA;        if(returnValue == AVERROR(EAGAIN) || returnValue == AVERROR_EOF)&#xA;        {&#xA;            return;&#xA;        }&#xA;        else if(returnValue &lt; 0)&#xA;        {&#xA;            printf("Error during encoding\n");&#xA;            return;&#xA;        }&#xA;&#xA;        printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);&#xA;        fwrite(pkt->data, 1, pkt->size, outfile);&#xA;        av_packet_unref(pkt);&#xA;    }&#xA;}&#xA;&#xA;&#xA;int main(int argc, char **argv)&#xA;{&#xA;    const char *filename, *codec_name;&#xA;    const AVCodec *codec;&#xA;    AVCodecContext *c= NULL;&#xA;    int i, ret, x, y;&#xA;    FILE *f;&#xA;    AVFrame *frame;&#xA;    AVPacket *pkt;&#xA;    uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;&#xA;    filename = "outo.mp4";&#xA;    codec_name = "mpeg1video";//"mpeg1video";//"libx264";&#xA;&#xA;&#xA;    /* find the mpeg1video encoder */&#xA;    codec = avcodec_find_encoder_by_name(codec_name);&#xA;    if(!codec)&#xA;    {&#xA;        printf("Error finding codec\n");&#xA;    return 0;&#xA;    }&#xA;&#xA;    c = avcodec_alloc_context3(codec);&#xA;    if(!c)&#xA;    {&#xA;        printf("Error allocating c\n");&#xA;    return 0;&#xA;    }&#xA;&#xA;    pkt = av_packet_alloc();&#xA;    if(!pkt)&#xA;    {&#xA;        printf("Error allocating pkt\n");&#xA;    return 0;&#xA;    }&#xA;&#xA;    /* put sample parameters */&#xA;    c->bit_rate = 400000;&#xA;    /* resolution must be a multiple of two */&#xA;    c->width = 800;&#xA;    c->height = 800;&#xA;    /* frames per second */&#xA;    c->time_base = (AVRational){1, 25};&#xA;    c->framerate = (AVRational){25, 1};&#xA;    c->gop_size = 10;&#xA;    c->max_b_frames = 1;&#xA;    c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;&#xA;    if(codec->id == AV_CODEC_ID_H264)&#xA;    {&#xA;        av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;    }&#xA;        &#xA;&#xA;    /* open it */&#xA;    ret = avcodec_open2(c, codec, NULL);&#xA;    if(ret &lt; 0) &#xA;    {&#xA;        printf("Error opening codec\n");&#xA;    return 0;&#xA;    }&#xA;&#xA;    f = fopen(filename, "wb");&#xA;    if(!f)&#xA;    {&#xA;         printf("Error opening file\n");&#xA;     return 0;&#xA;    }&#xA;&#xA;    frame = av_frame_alloc();&#xA;    if(!frame)&#xA;    {&#xA;        printf("Error allocating frame\n");&#xA;    return 0;&#xA;    }&#xA;    frame->format = c->pix_fmt;&#xA;    frame->width  = c->width;&#xA;    frame->height = c->height;&#xA;&#xA;    //I suspect this is the problem&#xA;    ret = av_frame_get_buffer(frame, 0);&#xA;    if(ret &lt; 0)&#xA;    {&#xA;        fprintf(stderr, "Could not allocate the video frame data\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* encode 25 frames*/&#xA;    for(i = 0; i &lt; 25; i&#x2B;&#x2B;) &#xA;    {&#xA;&#xA;        /* make sure the frame data is writable */&#xA;        ret = av_frame_make_writable(frame);&#xA;        if(ret &lt; 0)&#xA;        {&#xA;            return 0;&#xA;        }&#xA;        //FIll Frame with picture data&#xA;        PictureToFrame(i, frame, c->height, c->width);&#xA;&#xA;        /* encode the image */&#xA;        encode(c, frame, pkt, f);&#xA;    }&#xA;&#xA;    /* flush the encoder */&#xA;    encode(c, NULL, pkt, f);&#xA;&#xA;    /* add sequence end code to have a real MPEG file */&#xA;    if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)&#xA;        fwrite(endcode, 1, sizeof(endcode), f);&#xA;    fclose(f);&#xA;&#xA;    avcodec_free_context(&amp;c);&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_free(&amp;pkt);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;

    &#xA;

  • AC3 decoding throws error number -16976906 ... vlc plays well

    23 décembre 2022, par user1940163

    I have got a mpeg ts file with following composition (shown by ffprobe)

    &#xA;

    ffprobe version N-109444-geef763c705 Copyright (c) 2007-2022 the FFmpeg developers&#xA;  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)&#xA;  configuration: --enable-openssl&#xA;  libavutil      57. 43.100 / 57. 43.100&#xA;  libavcodec     59. 55.103 / 59. 55.103&#xA;  libavformat    59. 34.102 / 59. 34.102&#xA;  libavdevice    59.  8.101 / 59.  8.101&#xA;  libavfilter     8. 53.100 /  8. 53.100&#xA;  libswscale      6.  8.112 /  6.  8.112&#xA;  libswresample   4.  9.100 /  4.  9.100&#xA;[mpegts @ 0x56201c2c1cc0] Could not find codec parameters for stream 1 (Audio: ac3 ([129][0][0][0] / 0x0081), stereo, fltp): unspecified sample rate&#xA;Consider increasing the value for the &#x27;analyzeduration&#x27; (0) and &#x27;probesize&#x27; (5000000) options&#xA;Input #0, mpegts, from &#x27;ff_vlc.ts&#x27;:&#xA;  Duration: 00:10:00.02, start: 1.400000, bitrate: 1839 kb/s&#xA;  Program 1&#xA;    Metadata:&#xA;      service_name    : Service01&#xA;      service_provider: FFmpeg&#xA;  Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 856x480 [SAR 320:321 DAR 16:9], 30 fps, 59.94 tbr, 90k tbn&#xA;  Stream #0:1[0x101](spa): Audio: ac3 ([129][0][0][0] / 0x0081), stereo, fltp&#xA;

    &#xA;


    &#xA;

    I intend to transcode this so that I copy the video as it is but the audio will be encoded to aac ...so that I can play it in the browser.

    &#xA;

    I use the following ffmpeg command to attempt that

    &#xA;

    ffmpeg -i ff_vlc.ts -vcodec copy -acodec aac -map 0:v:0 -map 0:a:0 ff_vlc_2.ts&#xA;

    &#xA;

    this throws errors with -16976906 as follows..........( I have clipped the repetitive excessively long output)

    &#xA;

    ffmpeg -i ff_vlc.ts -vcodec copy -acodec aac -map 0:v:0 -map 0:a:0 ff_vlc_2.ts&#xA;ffmpeg version N-109444-geef763c705 Copyright (c) 2000-2022 the FFmpeg developers&#xA;  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)&#xA;  configuration: --enable-openssl&#xA;  libavutil      57. 43.100 / 57. 43.100&#xA;  libavcodec     59. 55.103 / 59. 55.103&#xA;  libavformat    59. 34.102 / 59. 34.102&#xA;  libavdevice    59.  8.101 / 59.  8.101&#xA;  libavfilter     8. 53.100 /  8. 53.100&#xA;  libswscale      6.  8.112 /  6.  8.112&#xA;  libswresample   4.  9.100 /  4.  9.100&#xA;[mpegts @ 0x55b4369b2440] Could not find codec parameters for stream 1 (Audio: ac3 ([129][0][0][0] / 0x0081), stereo, fltp): unspecified sample rate&#xA;Consider increasing the value for the &#x27;analyzeduration&#x27; (0) and &#x27;probesize&#x27; (5000000) options&#xA;Input #0, mpegts, from &#x27;ff_vlc.ts&#x27;:&#xA;  Duration: 00:10:00.02, start: 1.400000, bitrate: 1839 kb/s&#xA;  Program 1&#xA;    Metadata:&#xA;      service_name    : Service01&#xA;      service_provider: FFmpeg&#xA;  Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 856x480 [SAR 320:321 DAR 16:9], 30 fps, 59.94 tbr, 90k tbn&#xA;  Stream #0:1[0x101](spa): Audio: ac3 ([129][0][0][0] / 0x0081), stereo, fltp&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (copy)&#xA;  Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))&#xA;Press [q] to stop, [?] for help&#xA;Error while decoding stream #0:1: Error number -16976906 occurred&#xA;    Last message repeated 17065 times&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Error while decoding stream #0:1: Error number -16976906 occurred&#xA;    Last message repeated 2 times&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Error while decoding stream #0:1: Error number -16976906 occurred&#xA;    Last message repeated 2 times&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Error while decoding stream #0:1: Error number -16976906 occurred&#xA;    Last message repeated 2 times&#xA;....&#xA;....&#xA;....(repetitive output clipped and removed)&#xA;....&#xA;....&#xA;    Last message repeated 2 times&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Error while decoding stream #0:1: Error number -16976906 occurred&#xA;    Last message repeated 2 times&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Error while decoding stream #0:1: Error number -16976906 occurred&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;Too many packets buffered for output stream 0:0.&#xA;Error submitting a packet to the muxer for output stream #0:0.&#xA;[abuffer @ 0x56289e5ab100] Value inf for parameter &#x27;time_base&#x27; out of range [0 - 2.14748e&#x2B;09]&#xA;    Last message repeated 1 times&#xA;[abuffer @ 0x56289e5ab100] Error setting option time_base to value 1/0.&#xA;[graph_0_in_0_1 @ 0x5628a3f5e800] Error applying options to the filter.&#xA;Error reinitializing filters!&#xA;Error while filtering: Numerical result out of range&#xA;Finishing stream 0:1 without any data written to it.&#xA;[abuffer @ 0x56289b2b89c0] Value inf for parameter &#x27;time_base&#x27; out of range [0 - 2.14748e&#x2B;09]&#xA;    Last message repeated 1 times&#xA;[abuffer @ 0x56289b2b89c0] Error setting option time_base to value 1/0.&#xA;[graph_0_in_0_1 @ 0x56289a63e780] Error applying options to the filter.&#xA;Error configuring filter graph&#xA;Conversion failed!&#xA;

    &#xA;


    &#xA;

    I tried the above even with this command

    &#xA;

    ffmpeg -analyzeduration 2147483647 -probesize 2147483647 -i ff_vlc.ts -vcodec copy -acodec aac -map 0:v:0 -map 0:a:0 ff_vlc_2.ts&#xA;

    &#xA;

    Still get the same errors. Only changed lines in the output are

    &#xA;

    [mpegts @ 0x55e1b757d580] Failed to allocate buffers for seekback&#xA;[mpegts @ 0x55e1b757d580] Could not find codec parameters for stream 1 (Audio: ac3 ([129][0][0][0] / 0x0081), stereo, fltp): unspecified sample rate&#xA;Consider increasing the value for the &#x27;analyzeduration&#x27; (2147483647) and &#x27;probesize&#x27; (2147483647) options&#xA;

    &#xA;


    &#xA;

    VLC player has no problems in playing this audio ... only ffmpeg cannot decode.

    &#xA;

    How do I fix this ?

    &#xA;

    Please help&#xA;Thanks

    &#xA;

  • Error submitting the frame for encoding when submitting NV12 texture

    6 mai 2022, par Caio Augusto

    I'm trying to encode D3D11 NV12 Texture on QSV encoder but getting [h264_qsv @ 00000244ce6f50c0] Error submitting the frame for encoding.

    &#xA;

    Main :

    &#xA;

    int width = 1920;&#xA;int height = 1080;&#xA;FILE* outfile;&#xA;&#xA;fopen_s(&amp;outfile, "D:\\Sources\\D3D11QSV\\x64\\Debug\\outfile.264", "wb");&#xA;&#xA;const AVCodec* codec = avcodec_find_encoder_by_name("h264_qsv");&#xA;AVCodecContext* ctx = avcodec_alloc_context3(codec);&#xA;&#xA;ctx->width = width;&#xA;ctx->height = height;&#xA;ctx->time_base = AVRational{ 1, 60 };&#xA;ctx->framerate = AVRational{ 60, 1 };&#xA;ctx->slices = 1;&#xA;&#xA;ctx->sw_pix_fmt = AV_PIX_FMT_NV12;&#xA;ctx->pix_fmt = AV_PIX_FMT_NV12;&#xA;ctx->bit_rate = 400000;&#xA;ctx->gop_size = 10;&#xA;ctx->max_b_frames = 1;&#xA;&#xA;auto status = avcodec_open2(ctx, codec, NULL);&#xA;if (status &lt; 0) {&#xA;    std::cout &lt;&lt; "Open codec error!\n";&#xA;}&#xA;&#xA;AVFrame* sw_frame = av_frame_alloc();&#xA;sw_frame->format = ctx->sw_pix_fmt;&#xA;sw_frame->width = ctx->width;&#xA;sw_frame->height = ctx->height;&#xA;status = av_frame_get_buffer(sw_frame, 0);&#xA;&#xA;fill_frame(sw_frame, ctx);&#xA;

    &#xA;

    Filling the frame :

    &#xA;

    auto ret = 0;&#xA;&#xA;if (ret &lt; 0) {&#xA;    fprintf(stderr, "Could not allocate the video frame data\n");&#xA;    exit(1);&#xA;}&#xA;&#xA;int i, y, x, c = 0;&#xA;for (i = 0; i &lt; 60; i&#x2B;&#x2B;) {&#xA;    fflush(stdout);&#xA;&#xA;    ret = av_frame_make_writable(frame);&#xA;    &#xA;    auto texture = create_texture();&#xA;    auto desc = (AVD3D11FrameDescriptor*)frame->buf[0]->data;&#xA;    desc->texture = (ID3D11Texture2D*)texture;&#xA;    desc->index = 0;&#xA;&#xA;    frame->data[0] = (std::uint8_t*)texture;&#xA;    frame->data[1] = 0;&#xA;    frame->linesize[0] = width * 4;&#xA;&#xA;    frame->pts = i;&#xA;&#xA;    encode(frame, ctx);&#xA;}&#xA;

    &#xA;

    Creating Texture :

    &#xA;

    D3D11_TEXTURE2D_DESC const desc = CD3D11_TEXTURE2D_DESC(&#xA;    DXGI_FORMAT_NV12,           // HoloLens PV camera format, common for video sources&#xA;    width,                    // Width of the video frames&#xA;    height,                   // Height of the video frames&#xA;    1,                          // Number of textures in the array&#xA;    1,                          // Number of miplevels in each texture&#xA;    D3D11_BIND_SHADER_RESOURCE, // We read from this texture in the shader&#xA;    D3D11_USAGE_DYNAMIC,        // Because we&#x27;ll be copying from CPU memory&#xA;    D3D11_CPU_ACCESS_WRITE      // We only need to write into the texture&#xA;);&#xA;&#xA;ID3D11Device* pd3dDevice = create_d3d11_device();&#xA;&#xA;ID3D11Texture2D* pTexture = NULL;&#xA;HRESULT err = pd3dDevice->CreateTexture2D(&amp;desc, nullptr, &amp;pTexture);&#xA;&#xA;&#xA;if (SUCCEEDED(err)) {&#xA;    D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = CD3D11_SHADER_RESOURCE_VIEW_DESC(&#xA;        pTexture,&#xA;        D3D11_SRV_DIMENSION_TEXTURE2D,&#xA;        DXGI_FORMAT_R8_UNORM&#xA;    );&#xA;&#xA;    ID3D11ShaderResourceView* texSRV = NULL;&#xA;&#xA;    err = pd3dDevice->CreateShaderResourceView(pTexture,&#xA;        &amp;SRVDesc, &amp;texSRV);&#xA;&#xA;    D3D11_SHADER_RESOURCE_VIEW_DESC const chrominancePlaneDesc = CD3D11_SHADER_RESOURCE_VIEW_DESC(&#xA;        pTexture,&#xA;        D3D11_SRV_DIMENSION_TEXTURE2D,&#xA;        DXGI_FORMAT_R8G8_UNORM&#xA;    );&#xA;&#xA;    ID3D11ShaderResourceView* m_chrominanceView = NULL;&#xA;&#xA;    err = pd3dDevice->CreateShaderResourceView(pTexture,&#xA;        &amp;chrominancePlaneDesc, &amp;m_chrominanceView);&#xA;&#xA;}&#xA;&#xA;if (FAILED(err))&#xA;{&#xA;    fprintf(stderr, "Error creating texture\n");&#xA;    exit(1);&#xA;}&#xA;&#xA;return pTexture;&#xA;

    &#xA;

    Creating D3D11 device :

    &#xA;

        ID3D11Device* dev11 = NULL;&#xA;    ID3D11DeviceContext* devcon11 = NULL;&#xA;&#xA;    D3D_FEATURE_LEVEL featureLevels[]{&#xA;   D3D_FEATURE_LEVEL_11_1,&#xA;   D3D_FEATURE_LEVEL_11_0,&#xA;   D3D_FEATURE_LEVEL_10_1,&#xA;   D3D_FEATURE_LEVEL_10_0,&#xA;   D3D_FEATURE_LEVEL_9_3,&#xA;   D3D_FEATURE_LEVEL_9_2,&#xA;   D3D_FEATURE_LEVEL_9_1&#xA;    };&#xA;&#xA;&#xA;    int err = D3D11CreateDevice(&#xA;        nullptr,&#xA;        D3D_DRIVER_TYPE_HARDWARE,&#xA;        nullptr,&#xA;        D3D11_CREATE_DEVICE_VIDEO_SUPPORT,&#xA;        featureLevels, sizeof(featureLevels) / sizeof(D3D_FEATURE_LEVEL),&#xA;        D3D11_SDK_VERSION,&#xA;        &amp;dev11,&#xA;        nullptr,&#xA;        &amp;devcon11);&#xA;&#xA;    return dev11;&#xA;

    &#xA;

    Encoding :

    &#xA;

    auto status = 0;&#xA;&#xA;status = avcodec_send_frame(ctx, frame); //error happening here&#xA;&#xA;AVPacket* pkt;&#xA;&#xA;pkt = av_packet_alloc();&#xA;&#xA;if (status &lt; 0) {&#xA;    fprintf(stderr, "Error sending a frame for encoding\n");&#xA;    exit(1);&#xA;}&#xA;&#xA;while (status >= 0) {&#xA;    status = avcodec_receive_packet(ctx, pkt);&#xA;    if (status == AVERROR(EAGAIN) || status == AVERROR_EOF)&#xA;        return;&#xA;    else if (status &lt; 0) {&#xA;        fprintf(stderr, "Error during encoding\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    printf("Write packet \n", pkt->pts, pkt->size);&#xA;    fwrite(pkt->data, 1, pkt->size, outfile);&#xA;    av_packet_unref(pkt);&#xA;}&#xA;

    &#xA;

    Everything runs well until encoding the frame. I have tried sending a dummy nv12 data (not a d3d11 texture) and it works well.

    &#xA;