Recherche avancée

Médias (91)

Autres articles (12)

  • MediaSPIP Init et Diogène : types de publications de MediaSPIP

    11 novembre 2010, par

    À l’installation d’un site MediaSPIP, le plugin MediaSPIP Init réalise certaines opérations dont la principale consiste à créer quatre rubriques principales dans le site et de créer cinq templates de formulaire pour Diogène.
    Ces quatre rubriques principales (aussi appelées secteurs) sont : Medias ; Sites ; Editos ; Actualités ;
    Pour chacune de ces rubriques est créé un template de formulaire spécifique éponyme. Pour la rubrique "Medias" un second template "catégorie" est créé permettant d’ajouter (...)

  • MediaSPIP Player : les contrôles

    26 mai 2010, par

    Les contrôles à la souris du lecteur
    En plus des actions au click sur les boutons visibles de l’interface du lecteur, il est également possible d’effectuer d’autres actions grâce à la souris : Click : en cliquant sur la vidéo ou sur le logo du son, celui ci se mettra en lecture ou en pause en fonction de son état actuel ; Molette (roulement) : en plaçant la souris sur l’espace utilisé par le média (hover), la molette de la souris n’exerce plus l’effet habituel de scroll de la page, mais diminue ou (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (515)

  • FFMPEG libav gdigrab capturing with wrong colors

    7 mars 2018, par user1496491

    I’m capturing screen with code below, and it gets me the picture with wrong colors.

    Screenshot

    The picture on left is raw data which I assumed in ARGB the picture in right is encoded as YUV. I’ve tried different formats, the pictures slighly changing, but it’s never looks ow it should be. In what format gdigrab gives its output ? What’s the right way to encode it ?

    #include "MainWindow.h"

    #include <qguiapplication>
    #include <qlabel>
    #include <qscreen>
    #include <qtimer>
    #include <qlayout>
    #include <qimage>
    #include <qtconcurrent></qtconcurrent>QtConcurrent>
    #include <qthreadpool>

    #include "ScreenCapture.h"

    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
    {
       resize(800, 600);

       label = new QLabel();
       label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

       auto layout = new QHBoxLayout();
       layout->addWidget(label);

       auto widget = new QWidget();
       widget->setLayout(layout);
       setCentralWidget(widget);

       init();
       initOutFile();
       collectFrame();
    }

    MainWindow::~MainWindow()
    {
       avformat_close_input(&amp;inputFormatContext);
       avformat_free_context(inputFormatContext);

       QThreadPool::globalInstance()->waitForDone();
    }

    void MainWindow::init()
    {

       av_register_all();
       avcodec_register_all();
       avdevice_register_all();

       auto screen = QGuiApplication::screens()[1];
       QRect geometry = screen->geometry();

       inputFormatContext = avformat_alloc_context();

       AVDictionary* options = NULL;
       av_dict_set(&amp;options, "framerate", "30", NULL);
       av_dict_set(&amp;options, "offset_x", QString::number(geometry.x()).toLatin1().data(), NULL);
       av_dict_set(&amp;options, "offset_y", QString::number(geometry.y()).toLatin1().data(), NULL);
       av_dict_set(&amp;options, "preset", "ultrafast", NULL);
       av_dict_set(&amp;options, "probesize", "10MB", NULL);
       av_dict_set(&amp;options, "pix_fmt", "yuv420p", NULL);
       av_dict_set(&amp;options, "video_size", QString(QString::number(geometry.width()) + "x" + QString::number(geometry.height())).toLatin1().data(), NULL);

       AVInputFormat* inputFormat = av_find_input_format("gdigrab");
       avformat_open_input(&amp;inputFormatContext, "desktop", inputFormat, &amp;options);

    //    AVDictionary* options = NULL;
    //    av_dict_set(&amp;options, "framerate", "30", NULL);
    //    av_dict_set(&amp;options, "preset", "ultrafast", NULL);
    //    av_dict_set(&amp;options, "vcodec", "h264", NULL);
    //    av_dict_set(&amp;options, "s", "1280x720", NULL);
    //    av_dict_set(&amp;options, "crf", "0", NULL);
    //    av_dict_set(&amp;options, "rtbufsize", "100M", NULL);

    //    AVInputFormat *format = av_find_input_format("dshow");
    //    avformat_open_input(&amp;inputFormatContext, "video=screen-capture-recorder", format, &amp;options);

       av_dict_free(&amp;options);
       avformat_find_stream_info(inputFormatContext, NULL);

       videoStreamIndex = av_find_best_stream(inputFormatContext, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);

       inputCodec = avcodec_find_decoder(inputFormatContext->streams[videoStreamIndex]->codecpar->codec_id);
       if(!inputCodec) qDebug() &lt;&lt; "Не найден кодек входящего потока!";

       inputCodecContext = avcodec_alloc_context3(inputCodec);
       inputCodecContext->codec_id = inputCodec->id;

       avcodec_parameters_to_context(inputCodecContext, inputFormatContext->streams[videoStreamIndex]->codecpar);

       if(avcodec_open2(inputCodecContext, inputCodec, NULL)) qDebug() &lt;&lt; "Не удалось открыть входной кодек!";
    }

    void MainWindow::initOutFile()
    {
       const char* filename = "C:/Temp/output.mp4";

       if(avformat_alloc_output_context2(&amp;outFormatContext, NULL, NULL, filename) &lt; 0) qDebug() &lt;&lt; "Не удалось создать выходной контекст!";

       outCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);
       if(!outCodec) qDebug() &lt;&lt; "Не удалось найти кодек!";

       videoStream = avformat_new_stream(outFormatContext, outCodec);
       videoStream->time_base = {1, 30};

       const AVPixelFormat* pixelFormat = outCodec->pix_fmts;
       while (*pixelFormat != AV_PIX_FMT_NONE)
       {
           qDebug() &lt;&lt; "OUT_FORMAT" &lt;&lt; av_get_pix_fmt_name(*pixelFormat);
           ++pixelFormat;
       }

       outCodecContext = videoStream->codec;
       outCodecContext->bit_rate = 400000;
       outCodecContext->width = inputCodecContext->width;
       outCodecContext->height = inputCodecContext->height;
       outCodecContext->time_base = videoStream->time_base;
       outCodecContext->gop_size = 10;
       outCodecContext->max_b_frames = 1;
       outCodecContext->pix_fmt = AV_PIX_FMT_YUV420P;

       if (outFormatContext->oformat->flags &amp; AVFMT_GLOBALHEADER) outCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;

       if(avcodec_open2(outCodecContext, outCodec, NULL)) qDebug() &lt;&lt; "Не удалось открыть выходной кодек!";

       swsContext = sws_getContext(inputCodecContext->width,
                                   inputCodecContext->height,
    //                                inputCodecContext->pix_fmt,
                                   AV_PIX_FMT_ABGR,
                                   outCodecContext->width,
                                   outCodecContext->height,
                                   outCodecContext->pix_fmt,
                                   SWS_BICUBIC, NULL, NULL, NULL);

       if(avio_open(&amp;outFormatContext->pb, filename, AVIO_FLAG_WRITE) &lt; 0) qDebug() &lt;&lt; "Не удалось открыть файл!";
       if(avformat_write_header(outFormatContext, NULL) &lt; 0) qDebug() &lt;&lt; "Не удалось записать заголовок!";
    }

    void MainWindow::collectFrame()
    {
       AVFrame* inFrame = av_frame_alloc();
       inFrame->format = inputCodecContext->pix_fmt;
       inFrame->width = inputCodecContext->width;
       inFrame->height = inputCodecContext->height;

       int size = av_image_alloc(inFrame->data, inFrame->linesize, inFrame->width, inFrame->height, inputCodecContext->pix_fmt, 1);
       qDebug() &lt;&lt; size;

       AVFrame* outFrame = av_frame_alloc();
       outFrame->format = outCodecContext->pix_fmt;
       outFrame->width = outCodecContext->width;
       outFrame->height = outCodecContext->height;

       qDebug() &lt;&lt; av_image_alloc(outFrame->data, outFrame->linesize, outFrame->width, outFrame->height, outCodecContext->pix_fmt, 1);

       AVPacket packet;
       av_init_packet(&amp;packet);

       av_read_frame(inputFormatContext, &amp;packet);
    //    while(av_read_frame(inputFormatContext, &amp;packet) >= 0)
    //    {
           if(packet.stream_index == videoStream->index)
           {

               memcpy(inFrame->data[0], packet.data, size);

               sws_scale(swsContext, inFrame->data, inFrame->linesize, 0, inputCodecContext->height, outFrame->data, outFrame->linesize);

               QImage image(inFrame->data[0], inFrame->width, inFrame->height, QImage::Format_ARGB32);
               label->setPixmap(QPixmap::fromImage(image).scaled(label->size(), Qt::KeepAspectRatio));

               AVPacket outPacket;
               av_init_packet(&amp;outPacket);

               int encodeResult = avcodec_receive_packet(outCodecContext, &amp;outPacket);
               while(encodeResult == AVERROR(EAGAIN))
               {
                   if(avcodec_send_frame(outCodecContext, outFrame)) qDebug() &lt;&lt; "Ошибка отправки фрейма на кодирование!";

                   encodeResult = avcodec_receive_packet(outCodecContext, &amp;outPacket);
               }
               if(encodeResult != 0) qDebug() &lt;&lt; "Ошибка во время кодирования!" &lt;&lt; encodeResult;

               if(outPacket.pts != AV_NOPTS_VALUE) outPacket.pts = av_rescale_q(outPacket.pts, videoStream->codec->time_base, videoStream->time_base);
               if(outPacket.dts != AV_NOPTS_VALUE) outPacket.dts = av_rescale_q(outPacket.dts, videoStream->codec->time_base, videoStream->time_base);

               av_write_frame(outFormatContext, &amp;outPacket);

               av_packet_unref(&amp;outPacket);
           }
    //    }

       av_packet_unref(&amp;packet);

       av_write_trailer(outFormatContext);
       avio_close(outFormatContext->pb);
    }
    </qthreadpool></qimage></qlayout></qtimer></qscreen></qlabel></qguiapplication>
  • FFMPEG how to use gdigrab to capture with codec h264 at mp4 extension ?

    12 décembre 2017, par Gomi Odabaşıoğlu

    I am trying to use FFMPEG console tools effectively. I successfully recorded a video but my mind is mixed since doc. has too many provided information. I have no idea which one to read. I use following option to capture a video :

    C:\Users\{--USERNAME HERE-}\Desktop\ffmpeg.exe -f gdigrab -show_region 1 -framerate 60 -i desktop C:\Users\{--USERNAME HERE-}\Desktop\out.mp4

    Here I used gdigrab that provided good quality and speed. I do not know if there are better options about screen recording for windows. Now, my purpose is to record a video with codec h264 at 60fps as mp4 file quality is 80 of 100 type. What should I do to acieve this ?

  • Using GDIgrab in FFmpeg with dshow Audio produces black screen

    16 mars 2016, par Spreadys

    here is my command :

    ffmpeg -f gdigrab -framerate 25 -offset_x 10 -offset_y 10 -show_region 1 -draw_mouse 1 -video_size 1280x720 -i desktop -f dshow -i audio="Microphone (2- ATR USB microphone)" -r 25 -threads 4 -c:v libx264 -pix_fmt yuv422p -preset superfast -tune fastdecode -x264opts keyint=25:min-keyint=1 -crf 4 -c:a aac -profile:a aac_low -async 25 "C:\Users\david\Desktop\%output%.mp4"

    The gdigrab video works great when it is on its own (no audio). The audio works fine when it is on its own (no video). When I join the two commands to capture both together, as soon as I move a window within my capture area, the area goes black.

    In Windows 7, I used to get around this by stopping the desktop composition service prior to capture, (SC stop uxsms), but this is now not possible in Win10.

    I thought it may be something graphics card related.
    My main monitor is on an Nvidia card, with my second running from the onboard Intel. This is setup for Quicksync H264 playback and encoding with my NLE.

    I know that I could use a dshow screen capture driver such as UScreen but am trying to avoid that as I need the capture area to be specified each time from a simple batch.

    Any help appreciated to solve this black area problem- its driving me crazy !
    David