Recherche avancée

Médias (1)

Mot : - Tags -/biographie

Autres articles (38)

  • 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 ) (...)

  • 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

Sur d’autres sites (4831)

  • run time inconsistency DXVA hardware video decoding

    23 décembre 2015, par user5266278

    I am currently working on a project that involves using DXVA API and the FFmpeg framework to implement hardware-accelerated decoding of H264 video stream files.

    I have done some research on GPU decoding and constructed my code based on the hardware acceleration implementation in VLC. From my understanding, using DXVA in FFmpeg involves initializing the DirectXVideoDecoder and implementing several callback functions in AVCodecContext. The decoding process is done with the FFmpeg function avcodec_decode_video2() and each frame is parsed with av_read_frame(). The decoded frame is stored in the graphics memory and displayed using Direct3D.

    I tried to time each process with :GetTickCount() function and noticed that the execution time of the program for a 1550 frame video is 35000ms, with the display function taking 90% of the time and decoding function taking 6% of the time.

    However, when I tried to comment out the displaying process and execute the code only decoding each frame, the total decoding time surprisingly increased to 25,000ms for the same video, taking 94% of the total time.
    Here is the code for the decoding function :

    //record start time
    DWORD start_time = ::GetTickCount();
    //media file to be loaded
    const char *filename = "123.mkv";
    //time recording parameters
    unsigned frame_read_time_total = 0;
    unsigned decode_frame_time_total = 0;
    unsigned display_time_total = 0;
    unsigned setup_time_total = 0;

    /*********************Setup and Initialization Code*******************************/
    unsigned setup_time_start = ::GetTickCount();
    av_register_all();
    av_log_set_level(AV_LOG_DEBUG);
    int res;
    AVFormatContext *file = NULL;
    res = avformat_open_input(&file, filename, NULL, NULL);//´ò¿ªÎļþ
    if (res < 0) {
       printf("error %x in avformat_open_input\n", res);
       return 1;
    }
    res = avformat_find_stream_info(file, NULL);//È¡³öÁ÷ÐÅÏ¢
    if (res < 0)
    {
       printf("error %x in avformat_find_stream_info\n", res);
       return 1;
    }
    av_dump_format(file, 0, filename, 0);//ÁгöÊäÈëÎļþµÄÏà¹ØÁ÷ÐÅÏ¢
    int i;
    int videoindex = -1;
    int audioindex = -1;
    for (i = 0; i < file->nb_streams; i++){
       if (file->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO){
           videoindex = i;
       }
       if (file->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO){
           audioindex = i;
       }
    }
    if (videoindex == -1){
       av_log(NULL, AV_LOG_DEBUG, "can't find video stream\n");
       return 0;

    }
    AVCodec *codec = avcodec_find_decoder(file->streams[videoindex]->codec->codec_id);//¸ù¾ÝÁ÷ÐÅÏ¢ÕÒµ½½âÂëÆ÷
    if (!codec){
       printf("decoder not found\n");
       return 1;
    }
    AVCodecContext *codecctx = file->streams[videoindex]->codec;
    screen_width = codecctx->width;
    screen_height = codecctx->height;
    //Initialize Win API Window
    WNDCLASSEX window;
    ZeroMemory(&window, sizeof(window));
    window.cbSize = sizeof(window);
    window.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    window.lpfnWndProc = (WNDPROC)WindowProcess;
    window.lpszClassName = L"D3D";
    window.style = CS_HREDRAW | CS_VREDRAW;
    RegisterClassEx(&window);
    HWND hwnd_temp = CreateWindow(L"D3D", L"Player", WS_OVERLAPPEDWINDOW,
       0, 0, screen_width, screen_height, NULL, NULL, NULL, NULL);
    if (hwnd_temp == NULL){
       av_log(NULL, AV_LOG_ERROR, "Error: Cannot create window\n");
       system("pause");
    }
    hwnd.push_back(hwnd_temp);
    vlc_va_dxva2_t *dxva = vlc_va_NewDxva2(codecctx->codec_id);
    if (NULL == dxva){
       return 0;
    }
    res = Setup(dxva, &codecctx->hwaccel_context, &codecctx->pix_fmt, screen_width, screen_height);
    if (res < 0) {
       printf("error DXVA setup\n", res);
       return 1;
    }
    //Assign callback function
    codecctx->opaque = dxva;
    codecctx->get_format = ffmpeg_GetFormat;
    codecctx->get_buffer = ffmpeg_GetFrameBuf;
    codecctx->reget_buffer = ffmpeg_ReGetFrameBuf;
    codecctx->release_buffer = ffmpeg_ReleaseFrameBuf;
    codecctx->thread_count = 1;
    res = avcodec_open2(codecctx, codec, NULL);
    if (res < 0) {
       printf("error %x in avcodec_open2\n", res);
       return 1;
    }
    //Initialize Packet
    AVPacket pkt = { 0 };
    AVFrame *picture = avcodec_alloc_frame();
    DWORD wait_for_keyframe = 60;
    //initialize frame count
    int count = 0;
    ShowWindow(hwnd.at(0), SW_SHOWNORMAL);
    UpdateWindow(hwnd.at(0));
    RECT screen_size;
    screen_size.top = 0;
    screen_size.bottom = screen_height;
    screen_size.left = 0;
    screen_size.right = screen_width;

    unsigned setup_time_end = ::GetTickCount();
    setup_time_total = setup_time_end - setup_time_start;

    MSG msg;
    ZeroMemory(&msg, sizeof(msg));
    while(msg.message!=WM_QUIT)
    {
       if (PeekMessage(&msg, NULL, 0,0, PM_REMOVE)){
           TranslateMessage(&msg);
           DispatchMessage(&msg);
           continue;
       }
           int read_status;
           unsigned read_frame_start = ::GetTickCount();
           read_status = av_read_frame(file, &pkt);
           if (read_status < 0)
           {
               av_free_packet(&pkt);
               goto done;
           }

           unsigned read_frame_end = ::GetTickCount();
           frame_read_time_total += (read_frame_end - read_frame_start);
           int got_picture = 0;
           unsigned decode_start = ::GetTickCount();
           int bytes_used = avcodec_decode_video2(codecctx, picture, &got_picture, &pkt);
           unsigned decode_end = ::GetTickCount();
           decode_frame_time_total += (decode_end - decode_start);
           if (got_picture)
           {
               count++;
               unsigned display_start = ::GetTickCount();
               //display_frame((vlc_va_dxva2_t *)codecctx->opaque, picture, screen_size,0);
               unsigned display_end = ::GetTickCount();
               display_time_total += (display_end - display_start);
           }
           av_free_packet(&pkt);
    }
    done:
    UnregisterClass(L"D3D",0);
    printf("Frames = %d\n",count);
    unsigned stop_time = ::GetTickCount();
    unsigned total_time = stop_time - start_time;
    printf("total frame = %d\n", count);
    printf("time cost = %d\n", total_time);
    printf("total setup time = %d, %f %% total execution time\n", setup_time_total,(float) setup_time_total / total_time * 100);
    printf("total frame read time = %d, %f %% total execution time\n", frame_read_time_total, (float)frame_read_time_total / total_time*100);
    printf("total frame decode time = %d, %f %% total execution time\n", decode_frame_time_total, (float)decode_frame_time_total / total_time*100);
    printf("total display time = %d, %f %% of total execution time\n", display_time_total, (float)display_time_total / total_time*100);

    av_free(picture);
    av_close_input_file(file);
    system("pause");
    return 0;

    What could be the cause of this strange behavior ? My guess is that it may be the possible incorrect use of :GetTickCount() or may be it has to do with the DXVA hardware-accelerated decoding process. Sorry for the long post. Any input and suggestion is appreciated. Thanks in advance.

  • Deprecate obsolete XvMC hardware decoding support

    5 novembre 2013, par Diego Biurrun
    Deprecate obsolete XvMC hardware decoding support
    

    XvMC has long ago been superseded by newer acceleration APIs, such as
    VDPAU, and few downstreams still support it. Furthermore XvMC is not
    implemented within the hwaccel framework, but requires its own specific
    code in the MPEG-1/2 decoder, which is a maintenance burden.

    • [DH] doc/general.texi
    • [DH] libavcodec/allcodecs.c
    • [DH] libavcodec/avcodec.h
    • [DH] libavcodec/codec_desc.c
    • [DH] libavcodec/error_resilience.c
    • [DH] libavcodec/mpeg12.c
    • [DH] libavcodec/mpeg12dec.c
    • [DH] libavcodec/mpegvideo.c
    • [DH] libavcodec/mpegvideo_xvmc.c
    • [DH] libavcodec/options_table.h
    • [DH] libavcodec/version.h
    • [DH] libavcodec/x86/dsputil_init.c
    • [DH] libavcodec/xvmc.h
    • [DH] libavcodec/xvmc_internal.h
    • [DH] libavutil/old_pix_fmts.h
    • [DH] libavutil/pixdesc.c
    • [DH] libavutil/pixfmt.h
    • [DH] libavutil/version.h
  • ffmpeg Hardware decoding/encoding transcoding

    21 juillet 2020, par Michael McConnell

    I am running FFmpeg from the command line as below...

    


    ffmpeg -hwaccel_output_format cuda -c:v h264_cuvid -i rtmp://127.0.0.1:1935/live/$name -vcodec h264_nvenc -acodec aac -b:v 768k -b:a 96k -vf "scale=852:trunc(ow/a/2)*2" -tune zerolatency -crf 27 -f flv rtmp://localhost:1935/show/$name_480 -vcodec h264_nvenc -acodec aac -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -crf 27 -f flv rtmp://localhost:1935/show/$name_720 -c copy -f flv rtmp://localhost:1935/show/$name_src


    


    In theory, this should be decoding the source RTMP stream and then re-encoding to 480p and 720p (roughly) using the settings in the command, all on hardware. However, it seems that this is not the case as FFmpeg is still using roughly 50% CPU when running.

    


    the card being used is a Nvidia Quadro p2000

    


    ffmpeg has all of the options available :

    


    ffmpeg -hwaccels
ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
  configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Hardware acceleration methods:
vdpau
cuda
vaapi
drm
opencl
cuvid


    


    Output of -encoders

    


    ffmpeg -encoders |grep nvenc
ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
  configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
 V..... h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc                NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_h264           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_hevc           NVIDIA NVENC hevc encoder (codec hevc)
 V..... hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)


    


    Output of decoders :

    


    ffmpeg -decoders |grep cuvid
ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
  configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
 V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)
 V..... hevc_cuvid           Nvidia CUVID HEVC decoder (codec hevc)
 V..... mjpeg_cuvid          Nvidia CUVID MJPEG decoder (codec mjpeg)
 V..... mpeg1_cuvid          Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
 V..... mpeg2_cuvid          Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
 V..... mpeg4_cuvid          Nvidia CUVID MPEG4 decoder (codec mpeg4)
 V..... vc1_cuvid            Nvidia CUVID VC1 decoder (codec vc1)
 V..... vp8_cuvid            Nvidia CUVID VP8 decoder (codec vp8)
 V..... vp9_cuvid            Nvidia CUVID VP9 decoder (codec vp9)


    


    Could the CPU utilization be correlated to the audio transcoding or would that be handled in hardware as well ?

    


    Any ideas ?