Recherche avancée

Médias (91)

Autres articles (41)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

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

  • Cannot concatenate videos ffmpeg [on hold]

    1er mai 2014, par Paul Prescod

    I have a bitmap that I would like to concatenate to the front of many videos as a sort of title screen or disclaimer screen.

    I try to turn it into a video with the same attributes as the rest of the video. So first I introspect the video :

    ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
     built on Apr 11 2014 22:50:38 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
     configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
     libavutil      52. 66.100 / 52. 66.100
     libavcodec     55. 52.102 / 55. 52.102
     libavformat    55. 33.100 / 55. 33.100
     libavdevice    55. 10.100 / 55. 10.100
     libavfilter     4.  2.100 /  4.  2.100
     libavresample   1.  2.  0 /  1.  2.  0
     libswscale      2.  5.102 /  2.  5.102
     libswresample   0. 18.100 /  0. 18.100
     libpostproc    52.  3.100 / 52.  3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'EO1.mp4':
     Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.78.3
     Duration: 00:00:17.77, start: 0.000000, bitrate: 582 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 584x328 [SAR 1:1 DAR 73:41], 512 kb/s, 23.98 fps, 23.98 tbr, 1199 tbn, 47.96 tbc (default)
    Metadata:
     creation_time   : 1970-01-01 00:00:00
     handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
     creation_time   : 1970-01-01 00:00:00
     handler_name    : SoundHandler

    Then I try and create a similar file :

    /usr/local/Cellar/ffmpeg/2.2.1/bin/ffmpeg -y -loop 1 -i Disclaimer.png -c:v libx264 -r 23.98 -t 5 -pix_fmt yuv420p -profile:v main disclaimer.mp4

    It seems to work okay. The video plays I would expect it to. The attributes turn out very similar. Here is a diff :

    < Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'disclaimer.mp4':
    ---
    > Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'EO1.mp4':
    18,20c18,21
    <     encoder         : Lavf55.33.100
    <   Duration: 00:00:05.01, start: 0.000000, bitrate: 21 kb/s
    <     Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 584x328 [SAR 1:1 DAR 73:41], 17 kb/s, 23.98 fps, 23.98 tbr, 19184 tbn, 47.96 tbc (default)
    ---
    >     creation_time   : 1970-01-01 00:00:00
    >     encoder         : Lavf52.78.3
    >   Duration: 00:00:17.77, start: 0.000000, bitrate: 582 kb/s
    >     Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 584x328 [SAR 1:1 DAR 73:41], 512 kb/s, 23.98 fps, 23.98 tbr, 1199 tbn, 47.96 tbc (default)
    21a23
    22a25,28
    >     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 64 kb/s (default)
    >     Metadata:
    >       handler_name    : SoundHandler

    But when I try to concatenate, I get errors.

    > $ cat temporary.txt

       file disclaimer.mp4
       file EO1.mp4

    /usr/local/Cellar/ffmpeg/2.2.1/bin/ffmpeg -y -f concat -i temporary.txt -c copy output.mp4

    [concat @ 0x7fd880806600] Estimating duration from bitrate, this may be inaccurate
    Input #0, concat, from 'temporary.txt':
     Duration: 00:00:00.02, start: 0.000000, bitrate: 17 kb/s
    Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 584x328 [SAR 1:1 DAR 73:41], 17 kb/s, 23.98 fps, 23.98 tbr, 19184 tbn, 47.96 tbc
    Output #0, mp4, to 'output.mp4':
     Metadata:
    encoder         : Lavf55.33.100
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 584x328 [SAR 1:1 DAR 73:41], q=2-31, 17 kb/s, 23.98 fps, 19184 tbn, 19184 tbc
    Stream mapping:
     Stream #0:0 -> #0:0 (copy)
    Press [q] to stop, [?] for help
    [mp4 @ 0x7fd880829a00] Non-monotonous DTS in output stream 0:0; previous: 93600, current: 5951; changing to 93601. This may result in incorrect timestamps in the output file.
    [concat @ 0x7fd880806600] Invalid stream index 1
    [mp4 @ 0x7fd880829a00] Non-monotonous DTS in output stream 0:0; previous: 93601, current: 6001; changing to 93602. This may result in incorrect timestamps in the output file.
    [concat @ 0x7fd880806600] Invalid stream index 1
    [mp4 @ 0x7fd880829a00] Non-monotonous DTS in output stream 0:0; previous: 93602, current: 6051; changing to 93603. This may result in incorrect timestamps in the output file.

    ...

    frame=  546 fps=0.0 q=-1.0 Lsize=    1127kB time=00:00:04.90 bitrate=1882.9kbits/s    
    video:1123kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.349865%

    The output looks like it only has my disclaimer file in it, not the rest of the video.

    I’m also confused why it feels like it needs to "estimate" anything. It knows the input FPS and input durations. I’m not sure if this is the problem or not. Maybe its just a bug.

  • Capture from multiple streams concurrently, best way to do it and how to reduce CPU usage

    19 juin 2019, par DRONE_6969

    I am currently in the process of writing an application that will capture a lot of RTSP streams(in my case its 12) and display it on the QT widget. The problem arouses when I am going beyond around 6-7 streams, the CPU usage spikes and there is visible stutter.

    The reason why I think that it is not QT draw function is because I have done some checking to measure how much time it takes to draw an incoming image from camera and just sample images I had, it is always a lot less than 33 milliseconds(even if there are 12 widgets being updated).

    I also just ran opencv capture method without drawing and got pretty much the same CPU consumption as if I was drawing the frames (lost like 10% CPU at most and GPU usage went to zero).

    IMPORTANT : I am using RTSP stream which is a h264 stream.

    IF IT MATTERS MY SPECS :

    Intel Core i7-6700 @ 3.40GHZ(8 CPUS)
    Memory : 16gb
    GPU : Intel HD Graphics 530

    (Also I ran my code on a computer with dedicated Graphics card, it did eliminate some stutter but CPU usage is still pretty high)

    I am currently using OPENCV 4.1.0 with GSTREAMER enabled and built, I also have the OPENCV-WORLD version, there is no difference in performance.

    I have created a special class called Camera that holds its frame size constraints and various control functions as well stream function. The stream function is being ran on a separate thread, whenever stream() function is done with current frame it sends ready Mat via onNewFrame event I created which converts to QPixmap and updates widget’s lastImage variable. This way I can update image in a more thread safe way.

    I have tried to manipulate those VideoCapture.set() values, but it didn’t really help.

    This is my stream function (Ignore the bool return, it doesn’t do anything it is a remnant from couple of minutes ago when I was trying to use std::async) :

    bool Camera::stream() {
       /* This function is meant to run on a separate thread and fill up the buffer independantly of
       main stream thread */
       //cv::setNumThreads(100);
       /* Rules for these slightly changed! */
       Mat pre;  // Grab initial undoctored frame
       //pre = Mat::zeros(size, CV_8UC1);
       Mat frame; // Final modified frame
       frame = Mat::zeros(size, CV_8UC1);
       if (!pre.isContinuous()) pre = pre.clone();

       ipCam.open(streamUrl, CAP_FFMPEG);


       while (ipCam.isOpened() && capture) {
           // If camera is opened wel need to capture and process the frame
           try {
               auto start = std::chrono::system_clock::now();

               ipCam >> pre;

               if (pre.empty()) {
                   /* Check for blank frame, return error if there is a blank frame*/
                   cerr << id << ": ERROR! blank frame grabbed\n";
                   for (FrameListener* i : clients) {
                       i->onNotification(1); // Notify clients about this shit
                   }
                   break;
               }

               else {
                   // Only continue if frame not empty

                   if (pre.cols != size.width && pre.rows != size.height) {
                       resize(pre, frame, size);
                       pre.release();
                   }
                   else {
                       frame = pre;
                   }

                   dPacket* pack = new dPacket{id,&frame};
                   for (auto i : clients) {
                       i->onPNewFrame(pack);
                   }
                   frame.release();
                   delete pack;
               }
           }

           catch (int e) {
               cout << endl << "-----Exception during capture process! CODE " << e << endl;
           }
           // End camera manipulations
       }

       cout << "Camera timed out, or connection is closed..." << endl;
       if (tryResetConnection) {
           cout << "Reconnection flag is set, retrying after 3 seconds..." << endl;
           for (FrameListener* i : clients) {
               i->onNotification(-1); // Notify clients about this shit
           }
           this_thread::sleep_for(chrono::milliseconds(3000));
           stream();
       }

       return true;
    }

    This is my onPNewFrame function. The conversion is still being done on camera’s thread because it was called within stream() and therefore is within that scope(and I also checked) :

    void GLWidget::onPNewFrame(dPacket* inPack) {
       lastFlag = 0;

       if (bufferEnabled) {
           buffer.push(QPixmap::fromImage(toQImageFromPMat(inPack->frame)));
       }
       else {
           if (playing) {
               /* Only process if this widget is playing */
               frameProcessing = true;
               lastImage.convertFromImage(toQImageFromPMat(inPack->frame));
               frameProcessing = false;
           }
       }

       if (lastFlag != -1 && !lastImage.isNull()) {
           connecting = false;
       }
       else {
           connecting = true;
       }
    }

    This is my Mat to QImage :

    QImage GLWidget::toQImageFromPMat(cv::Mat* mat) {



       return QImage(mat->data, mat->cols, mat->rows, QImage::Format_RGB888).rgbSwapped();

    NOTE : not converting does not result in CPU boost (at least not a significant one).

    Minimal verifiable example

    This program is large. I am going to paste GLWidget.cpp and GLWidget.h as well as Camera.h and Camera.cpp. You can put GLWidget into anything just as long as you spawn more than 6 of it. Camera relies on the CamUtils, but it is possible to just paste url in videocapture

    I also supplied CamUtils, just in case

    Camera.h :

    #pragma once
    #include <iostream>
    #include <vector>
    #include <fstream>
    #include <map>
    #include <string>
    #include <sstream>
    #include <algorithm>
    #include "FrameListener.h"
    #include
    #include <thread>
    #include "CamUtils.h"
    #include <ctime>
    #include "dPacket.h"

    using namespace std;
    using namespace cv;

    class Camera
    {

       /*
           CLEANED UP!
           Camera now is only responsible for streaming and echoing captured frames.
           Frames are now wrapped into dPacket struct.
       */


    private:
       string id;
       vector clients;
       VideoCapture ipCam;
       string streamUrl;
       Size size;
       bool tryResetConnection = false;

       //TODO: Remove these as they are not going to be used going on:
       bool isPlaying = true;
       bool capture = true;

       //SECRET FEATURES:
       bool detect = false;


    public:
       Camera(string url, int width = 480, int height = 240, bool detect_=false);
       bool stream();
       void setReconnectable(bool newReconStatus);
       void addListener(FrameListener* client);
       vector<bool> getState();    // Returns current state: vector[0] stream state; vector[1] stream state; TODO: Remove this as this is no longer should control behaviour
       void killStream();
       bool getReconnectable();
    };

    </bool></ctime></thread></algorithm></sstream></string></map></fstream></vector></iostream>

    Camera.cpp

    #include "Camera.h"


    Camera::Camera(string url, int width, int height, bool detect_) // Default 240p
    {
       streamUrl = url; // Prepare url
       size = Size(width, height);
       detect = detect_;

    }

    void Camera::addListener(FrameListener* client) {
       clients.push_back(client);
    }


    /*
                   TEST CAMERAS(Paste into cameras.dViewer):
                   {"id":"96a73796-c129-46fc-9c01-40acd8ed7122","ip":"176.57.73.231","password":"null","username":"null"},
                   {"id":"96a73796-c129-46fc-9c01-40acd8ed7122","ip":"176.57.73.231","password":"null","username":"null"},
                   {"id":"96a73796-c129-46fc-9c01-40acd8ed7144","ip":"172.20.101.13","password":"admin","username":"root"}
                   {"id":"96a73796-c129-46fc-9c01-40acd8ed7144","ip":"172.20.101.13","password":"admin","username":"root"}

    */



    bool Camera::stream() {
       /* This function is meant to run on a separate thread and fill up the buffer independantly of
       main stream thread */
       //cv::setNumThreads(100);
       /* Rules for these slightly changed! */
       Mat pre;  // Grab initial undoctored frame
       //pre = Mat::zeros(size, CV_8UC1);
       Mat frame; // Final modified frame
       frame = Mat::zeros(size, CV_8UC1);
       if (!pre.isContinuous()) pre = pre.clone();

       ipCam.open(streamUrl, CAP_FFMPEG);

       while (ipCam.isOpened() &amp;&amp; capture) {
           // If camera is opened wel need to capture and process the frame
           try {
               auto start = std::chrono::system_clock::now();

               ipCam >> pre;

               if (pre.empty()) {
                   /* Check for blank frame, return error if there is a blank frame*/
                   cerr &lt;&lt; id &lt;&lt; ": ERROR! blank frame grabbed\n";
                   for (FrameListener* i : clients) {
                       i->onNotification(1); // Notify clients about this shit
                   }
                   break;
               }

               else {
                   // Only continue if frame not empty

                   if (pre.cols != size.width &amp;&amp; pre.rows != size.height) {
                       resize(pre, frame, size);
                       pre.release();
                   }
                   else {
                       frame = pre;
                   }

                   auto end = std::chrono::system_clock::now();
                   std::time_t ts = std::chrono::system_clock::to_time_t(end);
                   dPacket* pack = new dPacket{ id,&amp;frame};
                   for (auto i : clients) {
                       i->onPNewFrame(pack);
                   }
                   frame.release();
                   delete pack;
               }
           }

           catch (int e) {
               cout &lt;&lt; endl &lt;&lt; "-----Exception during capture process! CODE " &lt;&lt; e &lt;&lt; endl;
           }
           // End camera manipulations
       }

       cout &lt;&lt; "Camera timed out, or connection is closed..." &lt;&lt; endl;
       if (tryResetConnection) {
           cout &lt;&lt; "Reconnection flag is set, retrying after 3 seconds..." &lt;&lt; endl;
           for (FrameListener* i : clients) {
               i->onNotification(-1); // Notify clients about this shit
           }
           this_thread::sleep_for(chrono::milliseconds(3000));
           stream();
       }

       return true;
    }


    void Camera::killStream(){
       tryResetConnection = false;
       capture = false;
       ipCam.release();
    }

    void Camera::setReconnectable(bool reconFlag) {
       tryResetConnection = reconFlag;
    }

    bool Camera::getReconnectable() {
       return tryResetConnection;
    }

    vector<bool> Camera::getState() {
       vector<bool> states;
       states.push_back(isPlaying);
       states.push_back(ipCam.isOpened());
       return states;
    }



    </bool></bool>

    GLWidget.h :

    #ifndef GLWIDGET_H
    #define GLWIDGET_H

    #include <qopenglwidget>
    #include <qmouseevent>
    #include "FrameListener.h"
    #include "Camera.h"
    #include "FrameListener.h"
    #include
    #include "Camera.h"
    #include "CamUtils.h"
    #include
    #include "dPacket.h"
    #include <chrono>
    #include <ctime>
    #include
    #include "FullScreenVideo.h"
    #include <qmovie>
    #include "helper.h"
    #include <iostream>
    #include <qpainter>
    #include <qtimer>

    class Helper;

    class GLWidget : public QOpenGLWidget, public FrameListener
    {
       Q_OBJECT

    public:
       GLWidget(std::string camId, CamUtils *cUtils, int width, int height, bool denyFullScreen_ = false, bool detectFlag_=false, QWidget* parent = nullptr);
       void killStream();
       ~GLWidget();

    public slots:
       void animate();
       void setBufferEnabled(bool setState);
       void setCameraRetryConnection(bool setState);
       void GLUpdate();            // Call to update the widget
       void onRightClickMenu(const QPoint&amp; point);

    protected:
       void paintEvent(QPaintEvent* event) override;
       void onPNewFrame(dPacket* frame);
       void onNotification(int alert_code);


    private:
       // Objects and resourses
       Helper* helper;
       Camera* cam;
       CamUtils* camUtils;
       QTimer* timer; // Keep track of update
       QPixmap lastImage;
       QMovie* connMov;
       QMovie* test;

       QPixmap logo;

       // Control fields
       int width;
       int height;
       int camUtilsAddr;
       int elapsed;
       std::thread* camThread;
       std::string camId;
       bool denyFullScreen = false;
       bool playing = true;
       bool streaming = true;
       bool debug = false;
       bool connecting = true;
       int lastFlag = 0;


       // Debug fields
       std::chrono::high_resolution_clock::time_point lastFrameAt;
       std::chrono::high_resolution_clock::time_point now;
       std::chrono::duration<double> painTime; // time took to draw last frame

       //Buffer stuff
       std::queue<qpixmap> buffer;
       bool bufferEnabled = false;
       bool initialBuffer = false;
       bool buffering = true;
       bool frameProcessing = false;



       //Functions
       QImage toQImageFromPMat(cv::Mat* inFrame);
       void mousePressEvent(QMouseEvent* event) override;
       void drawImageGLLatest(QPainter* painter, QPaintEvent* event, int elapsed);
       void drawOnPaused(QPainter* painter, QPaintEvent* event, int elapsed);
       void drawOnStatus(int statusFlag, QPainter* painter, QPaintEvent* event, int elapsed);
    };

    #endif

    </qpixmap></double></qtimer></qpainter></iostream></qmovie></ctime></chrono></qmouseevent></qopenglwidget>

    GLWidget.cpp :

    #include "glwidget.h"
    #include <future>


    FullScreenVideo* fullScreen;

    GLWidget::GLWidget(std::string camId_, CamUtils* cUtils, int width_, int height_,  bool denyFullScreen_, bool detectFlag_, QWidget* parent)
       : QOpenGLWidget(parent), helper(helper)
    {
       cout &lt;&lt; "Player for CAMERA " &lt;&lt; camId_ &lt;&lt; endl;

       /* Underlying properties */
       camUtils = cUtils;
       cout &lt;&lt; "GLWidget Incoming CamUtils addr " &lt;&lt; camUtils &lt;&lt; endl;
       cout &lt;&lt; "GLWidget Set CamUtils addr " &lt;&lt; camUtils &lt;&lt; endl;
       camId = camId_;
       elapsed = 0;
       width = width_ + 5;
       height = height_ + 5;
       helper = new Helper();
       setFixedSize(width, height);
       denyFullScreen = denyFullScreen_;

       /* Camera capture thread */
       cam = new Camera(camUtils->getCameraStreamURL(camId), width_, height_, detectFlag_);
       cam->addListener(this);

       /* Sync states */
       vector<bool> initState = cam->getState();
       playing = initState[0];
       streaming = initState[1];
       cout &lt;&lt; "Initial states: " &lt;&lt; playing &lt;&lt; " " &lt;&lt; streaming &lt;&lt; endl;
       camThread = new std::thread(&amp;Camera::stream, cam);
       cout &lt;&lt; "================================================" &lt;&lt; endl;

       // Right click set up
       setContextMenuPolicy(Qt::CustomContextMenu);


       /* Loading gif */
       connMov = new QMovie("establishingConnection.gif");
       connMov->start();
       QString url = R"(RLC-logo.png)";
       logo = QPixmap(url);
       QTimer* timer = new QTimer(this);
       connect(timer, SIGNAL(timeout()), this, SLOT(GLUpdate()));
       timer->start(1000/30);
       playing = true;

    }

    /* SYSTEM */
    void GLWidget::animate()
    {
       elapsed = (elapsed + qobject_cast(sender())->interval()) % 1000;
       std::cout &lt;&lt; elapsed &lt;&lt; "\n";
    }


    void GLWidget::GLUpdate() {
       /* Process descisions before update call */
       if (bufferEnabled) {
           /* Process buffer before update */
           now = chrono::high_resolution_clock::now();
           std::chrono::duration timeSinceLastUpdate = now - lastFrameAt;
           if (timeSinceLastUpdate.count() > 25) {
               if (buffer.size() > 1 &amp;&amp; playing) {
                   lastImage.swap(buffer.front());
                   buffer.pop();
                   lastFrameAt = chrono::high_resolution_clock::now();
               }
           }
           //update(); // Update
       }
       else {
           /* No buffer */
       }
       repaint();
    }


    /* EVENTS */
    void GLWidget::onRightClickMenu(const QPoint&amp; point) {
       cout &lt;&lt; "Right click request got" &lt;&lt; endl;

       QPoint globPos = this->mapToGlobal(point);
       QMenu myMenu;

       if (!denyFullScreen) {
           myMenu.addAction("Open Full Screen");
       }
       myMenu.addAction("Toggle Debug Info");


       QAction* selected = myMenu.exec(globPos);

       if (selected) {
           string optiontxt = selected->text().toStdString();

           if (optiontxt == "Open Full Screen") {
               cout &lt;&lt; "Chose to open full screen of " &lt;&lt; camId &lt;&lt; endl;
               fullScreen = new FullScreenVideo(bufferEnabled, this);
               fullScreen->setUpView(camUtils, camId);
               fullScreen->show();
               playing = false;
           }

           if (optiontxt == "Toggle Debug Info") {
               cout &lt;&lt; "Chose to toggle debug of " &lt;&lt; camId &lt;&lt; endl;
               debug = !debug;
           }
       }
       else {
           cout &lt;&lt; "Chose nothing!" &lt;&lt; endl;
       }


    }



    void GLWidget::onPNewFrame(dPacket* inPack) {
       lastFlag = 0;

       if (bufferEnabled) {
           buffer.push(QPixmap::fromImage(toQImageFromPMat(inPack->frame)));
       }
       else {
           if (playing) {
               /* Only process if this widget is playing */
               frameProcessing = true;
               lastImage.convertFromImage(toQImageFromPMat(inPack->frame));
               frameProcessing = false;
           }
       }

       if (lastFlag != -1 &amp;&amp; !lastImage.isNull()) {
           connecting = false;
       }
       else {
           connecting = true;
       }
    }


    void GLWidget::onNotification(int alert) {
       lastFlag = alert;  
    }


    /* Paint events*/


    void GLWidget::paintEvent(QPaintEvent* event)
    {
       QPainter painter(this);

           if (lastFlag != 0 || connecting) {
               drawOnStatus(lastFlag, &amp;painter, event, elapsed);
           }
           else {

               /* Actual frame drawing */
               if (playing) {
                   if (!frameProcessing) {
                       drawImageGLLatest(&amp;painter, event, elapsed);
                   }
               }
               else {
                   drawOnPaused(&amp;painter, event, elapsed);
               }
           }
       painter.end();

    }


    /* DRAWING STUFF */

    void GLWidget::drawOnStatus(int statusFlag, QPainter* bgPaint, QPaintEvent* event, int elapsed) {

       QString str;
       QFont font("times", 15);
       bgPaint->eraseRect(QRect(0, 0, width, height));
       if (!lastImage.isNull()) {
           bgPaint->drawPixmap(QRect(0, 0, width, height), lastImage);
       }
       /* Test background painting */
       if (connecting) {
           string k = "Connecting to " + camUtils->getIp(camId);
           str.append(k.c_str());
       }
       else {
           switch (statusFlag) {
           case 1:
               str = "Blank frame received...";
               break;

           case -1:
               if (cam->getReconnectable()) {
                   str = "Connection lost, will try to reconnect.";
                   bgPaint->setOpacity(0.3);
               }
               else {
                   str = "Connection lost...";
                   bgPaint->setOpacity(0.3);
               }

               break;
           }
       }

       bgPaint->drawPixmap(QRect(0, 0, width, height), QPixmap::fromImage(connMov->currentImage()));
       bgPaint->setPen(Qt::red);
       bgPaint->setFont(font);
       QFontMetrics fm(font);
       const QRect kek(0, 0, fm.width(str), fm.height());
       QRect bound;
       bgPaint->setOpacity(1);
       bgPaint->drawText(bgPaint->viewport().width()/2 - kek.width()/2, bgPaint->viewport().height()/2 - kek.height(), str);

       bgPaint->drawPixmap(bgPaint->viewport().width() / 2 - logo.width()/2, height - logo.width() - 15, logo);

    }



    void GLWidget::drawOnPaused(QPainter* painter, QPaintEvent* event, int elapsed) {
       painter->eraseRect(0, 0, width, height);
       QFont font = painter->font();
       font.setPointSize(18);
       painter->setPen(Qt::red);
       QFontMetrics fm(font);
       QString str("Paused");
       painter->drawPixmap(QRect(0, 0, width, height),lastImage);
       painter->drawText(QPoint(painter->viewport().width() - fm.width(str), 50), str);

       if (debug) {
           QFont font = painter->font();
           font.setPointSize(25);
           painter->setPen(Qt::red);
           string camMess = "CAMID: " + camId;
           QString mess(camMess.c_str());
           string camIp = "IP: " + camUtils->getIp(camId);
           QString ipMess(camIp.c_str());
           QString bufferSize("Buffer size: " + QString::number(buffer.size()));
           QString lastFrameText("Last frame draw time: " + QString::number(painTime.count()) + "s");
           painter->drawText(QPoint(10, 50), mess);
           painter->drawText(QPoint(10, 60), ipMess);
           QString bufferState;
           if (bufferEnabled) {
               bufferState = QString("Experimental BUFFER is enabled!");
               QString currentBufferSize("Current buffer load: " + QString::number(buffer.size()));
               painter->drawText(QPoint(10, 80), currentBufferSize);
           }
           else {
               bufferState = QString("Experimental BUFFER is disabled!");
           }
           painter->drawText(QPoint(10, 70), bufferState);
           painter->drawText(QPoint(10, height - 25), lastFrameText);
       }
    }


    void GLWidget::drawImageGLLatest(QPainter* painter, QPaintEvent* event, int elapsed) {
       auto start = chrono::high_resolution_clock::now();
       painter->drawPixmap(QRect(0, 0, width, height), lastImage);
       if (debug) {
           QFont font = painter->font();
           font.setPointSize(25);
           painter->setPen(Qt::red);
           string camMess = "CAMID: " + camId;
           QString mess(camMess.c_str());
           string camIp = "IP: " + camUtils->getIp(camId);
           QString ipMess(camIp.c_str());
           QString bufferSize("Buffer size: " + QString::number(buffer.size()));
           QString lastFrameText("Last frame draw time: " + QString::number(painTime.count()) + "s");
           painter->drawText(QPoint(10, 50), mess);
           painter->drawText(QPoint(10, 60), ipMess);
           QString bufferState;
           if(bufferEnabled){
               bufferState = QString("Experimental BUFFER is enabled!");
               QString currentBufferSize("Current buffer load: " + QString::number(buffer.size()));
               painter->drawText(QPoint(10,80), currentBufferSize);
           }
           else {
               bufferState = QString("Experimental BUFFER is disabled!");
               QString currentBufferSize("Current buffer load: " + QString::number(buffer.size()));
               painter->drawText(QPoint(10, 80), currentBufferSize);
           }
           painter->drawText(QPoint(10, 70), bufferState);
           painter->drawText(QPoint(10, height - 25), lastFrameText);

       }
       auto end = chrono::high_resolution_clock::now();
       painTime = end - start;
    }



    /* END DRAWING STUFF */



    /* UI EVENTS */

    void GLWidget::mousePressEvent(QMouseEvent* e) {

       if (e->button() == Qt::LeftButton) {
           if (fullScreen == nullptr || !fullScreen->isVisible()) { // Do not unpause if window is opened
               playing = !playing;
           }
       }

       if (e->button() == Qt::RightButton) {
           onRightClickMenu(e->pos());
       }
    }



    /* Utilities */
    QImage GLWidget::toQImageFromPMat(cv::Mat* mat) {



       return QImage(mat->data, mat->cols, mat->rows, QImage::Format_RGB888).rgbSwapped();



    }

    /* State control */

    void GLWidget::killStream() {
       cam->killStream();
       camThread->join();
    }

    void GLWidget::setBufferEnabled(bool newBufferState) {
       cout &lt;&lt; "Player: " &lt;&lt; camId &lt;&lt; ", buffer state updated: " &lt;&lt; newBufferState &lt;&lt; endl;
       bufferEnabled = newBufferState;
       buffer.empty();
    }

    void GLWidget::setCameraRetryConnection(bool newState) {
       cam->setReconnectable(newState);
    }

    /* Destruction */
    GLWidget::~GLWidget() {
       cam->killStream();
       camThread->join();
    }
    </bool></future>

    CamUtils.h :

    #pragma once
    #include <iostream>
    #include <vector>
    #include <fstream>
    #include <map>
    #include <string>
    #include <sstream>
    #include <algorithm>
    #include <nlohmann></nlohmann>json.hpp>

    using namespace std;
    using json = nlohmann::json;

    class CamUtils
    {
    private:

       string camDb = "cameras.dViewer";
       map> cameraList; // Legacy
       json cameras;
       ofstream dbFile;
       bool dbExists(); // Always hard coded

       /* Old IMPLEMENTATION */
       void writeLineToDb_(const string&amp; content, bool append = false);
       void loadCameras_();

       /* JSON based */
       void loadCameras();

    public:
       CamUtils();
       string generateRandomString(size_t length);
       string getCameraStreamURL(string cameraId) const;
       string saveCamera(string ip, string username, string pass); // Return generated id
       vector<string> listAllCameraIds();
       string getIp(string cameraId);
    };


    </string></algorithm></sstream></string></map></fstream></vector></iostream>

    CamUtils.cpp :

    #include "CamUtils.h"
    #pragma comment(lib, "rpcrt4.lib")  // UuidCreate - Minimum supported OS Win 2000
    #include
    #include <iostream>

    CamUtils::CamUtils()
    {
       if (!dbExists()) {
           ofstream dbFile;
           dbFile.open(camDb);
           cameras["cameras"] = json::array();
           dbFile &lt;&lt; cameras &lt;&lt; std::endl;
           dbFile.close();

       }
       else {
           loadCameras();
       }
    }




    vector<string> CamUtils::listAllCameraIds() {
       vector<string> ids;
       cout &lt;&lt; "IN LIST " &lt;&lt; endl;
       for (auto&amp; cam : cameras["cameras"]) {
           ids.push_back(cam["id"].get<string>());
           //cout &lt;&lt; cam["id"].get<string>() &lt;&lt; std::endl;
       }
       return ids;
    }

    string CamUtils::getIp(string id) {
       vector<string> camDetails = cameraList[id];
       string ip = "NO IP WILL DISPLAYED UNTIL I FIGURE OUT A BUG";
       for (auto&amp; cam : cameras["cameras"]) {
           if (id == cam["id"]) {
               ip = cam["ip"].get<string>();
           }
       }

       return ip;
    }

    string CamUtils::getCameraStreamURL(string id) const {
       string url = "err"; // err is the default, it will be overwritten in case id is found, dont forget to check for it

       for (auto&amp; cam : cameras["cameras"]) {
           if (id == cam["id"]) {
               if (cam["username"].get<string>() == "null") {
                   url = "rtsp://" + cam["ip"].get<string>() + ":554/axis-media/media.amp?tcp";
               }
               else {
                   url = "rtsp://" + cam["username"].get<string>() + ":" + cam["password"].get<string>() + "@" + cam["ip"].get<string>() + ":554/axis-media/media.amp?streamprofile=720_30";
               }
           }
       }

       return url;  // Dont forget to check for err when using this shit
    }


    string CamUtils::saveCamera(string ip, string username, string password) {
       UUID uid;
       UuidCreate(&amp;uid);
       char* str;
       UuidToStringA(&amp;uid, (RPC_CSTR*)&amp;str);
       string id = str;
       cout &lt;&lt; "GEN: " &lt;&lt; id &lt;&lt; endl;
       json cam = json({}); //Create emtpy object
       cam["id"] = id;
       cam["ip"] = ip;
       cam["username"] = username;
       cam["password"] = password;
       cameras["cameras"].push_back(cam);
       std::ofstream out(camDb);
       out &lt;&lt; cameras &lt;&lt; std::endl;
       cout &lt;&lt; cameras["cameras"] &lt;&lt; endl;

       cout &lt;&lt; "Saved camera as " &lt;&lt; id &lt;&lt; endl;
       return id;
    }


    bool CamUtils::dbExists() {
       ifstream dbFile(camDb);
       return (bool)dbFile;
    }





    void CamUtils::loadCameras() {
       cout &lt;&lt; "Load call" &lt;&lt; endl;
       ifstream dbFile(camDb);
       string line;
       string wholeFile;

       while (std::getline(dbFile, line)) {
           cout &lt;&lt; line &lt;&lt; endl;
           wholeFile += line;
       }
       try {
           cameras = json::parse(wholeFile);
           //cout &lt;&lt; cameras["cameras"] &lt;&lt; endl;

       }
       catch (exception e) {
           cout &lt;&lt; e.what() &lt;&lt; endl;
       }
       dbFile.close();
    }










    /*
       LEGACY CODE, TO BE REMOVED!

    */



    void CamUtils::loadCameras_() {
       /*
           LEGACY CODE:
           This used to be the way to load cameras, but I moved on to JSON based configuration so this is no longer needed and will be removed soon
       */

       ifstream dbFile(camDb);
       string line;
       while (std::getline(dbFile, line)) {
           /*
               This function load camera data to the map:
               The order MUST be the following: 0:ID, 1:IP, 2:USERNAME, 3:PASSWORD.
               Always delimited with | no spaces between!
           */
           if (!line.empty()) {
               stringstream ss(line);
               string item;
               vector<string> splitString;

               while (std::getline(ss, item, '|')) {
                   splitString.push_back(item);
               }
               if (splitString.size() > 0) {
                   /* Dont even parse if the program didnt split right*/
                   //cout &lt;&lt; "Split string: " &lt;&lt; splitString.size() &lt;&lt; "\n";
                   for (int i = 0; i &lt; (splitString.size()); i++) cameraList[splitString[0]].push_back(splitString[i]);
               }
           }
       }
    }



    void CamUtils::writeLineToDb_(const string &amp; content, bool append) {
       ofstream dbFile;
       cout &lt;&lt; "Creating?";
       if (append) {
           dbFile.open(camDb, ios_base::app);
       }
       else {
           dbFile.open(camDb);
       }

       dbFile &lt;&lt; content.c_str() &lt;&lt; "\r\n";
       dbFile.flush();
    }

    /* JSON Reworx */




    string CamUtils::generateRandomString(size_t length)
    {
       const char* charmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
       const size_t charmapLength = strlen(charmap);
       auto generator = [&amp;]() { return charmap[rand() % charmapLength]; };
       string result;
       result.reserve(length);
       generate_n(back_inserter(result), length, generator);
       return result;
    }
    </string></string></string></string></string></string></string></string></string></string></string></string></iostream>

    End of example

    How would I go about decreasing CPU usage when dealing with large amount of streams ?

  • extract subtitle from video ffmpeg. subs.srt : Invalid argument

    3 juillet 2019, par evgeni fotia
       let filename_ext = file.path.split('/').pop()
       let filename = filename_ext.split('.').slice(0, filename_ext.split('.').length-1).join('.')

       var result = ffmpeg({
         MEMFS: [{name: filename_ext, data: buffer}],
         arguments: ["-i", filename_ext, "-map", "0:s:0", "subs.srt"],
         // Ignore stdin read requests
         stdin: function() {},
       });
       // Write out.webm to disk.
       var out = result.MEMFS[0];
       fs.outputFile(pathname + '/' + out.name, Buffer(out.data), 'binary');

    I get the following

       ffmpeg version n3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
     built with emcc (Emscripten gcc/clang-like replacement) 1.36.7 ()
     configuration: --cc=emcc --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avutil --enable-swresample --enable-swscale --enable-avfilter --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vda --disable-vdpau --enable-decoder=vp8 --enable-decoder=vp9 --enable-decoder=theora --enable-decoder=mpeg2video --enable-decoder=mpeg4 --enable-decoder=h264 --enable-decoder=hevc --enable-decoder=png --enable-decoder=mjpeg --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=ac3 --enable-decoder=aac --enable-decoder=ass --enable-decoder=ssa --enable-decoder=srt --enable-decoder=webvtt --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=avi --enable-demuxer=mov --enable-demuxer=flv --enable-demuxer=mpegps --enable-demuxer=image2 --enable-demuxer=mp3 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl --disable-securetransport --disable-xlib --disable-zlib --enable-encoder=libvpx_vp8 --enable-encoder=libopus --enable-encoder=mjpeg --enable-muxer=webm --enable-muxer=ogg --enable-muxer=null --enable-muxer=image2 --enable-filter=subtitles --enable-libass --enable-libopus --enable-libvpx --extra-cflags=-I../libvpx/dist/include --extra-ldflags=-L../libvpx/dist/lib
     libavutil      55. 28.100 / 55. 28.100
     libavcodec     57. 48.101 / 57. 48.101
     libavformat    57. 41.100 / 57. 41.100
     libavfilter     6. 47.100 /  6. 47.100
     libswscale      4.  1.100 /  4.  1.100
     libswresample   2.  1.100 /  2.  1.100
    [h264 @ 0x7d7510] Warning: not compiled with thread support, using thread emulation
    [aac @ 0x7d81c0] Warning: not compiled with thread support, using thread emulation
    [ssa @ 0x7d8e30] Warning: not compiled with thread support, using thread emulation
    Input #0, matroska,webm, from 'censored filename.mkv':
     Metadata:
       encoder         : no_variable_data
       creation_time   : 1970-01-01 00:00:00
     Duration: 00:23:40.13, start: 0.000000, bitrate: 2789 kb/s
       Stream #0:0: Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
       Metadata:
         BPS             : 2658044
         BPS-eng         : 2658044
         DURATION        : 00:23:40.045000000
         DURATION-eng    : 00:23:40.045000000
         NUMBER_OF_FRAMES: 34047
         NUMBER_OF_FRAMES-eng: 34047
         NUMBER_OF_BYTES : 471817808
         NUMBER_OF_BYTES-eng: 471817808
         _STATISTICS_WRITING_APP: no_variable_data
         _STATISTICS_WRITING_APP-eng: no_variable_data
         _STATISTICS_WRITING_DATE_UTC: 1970-01-01 00:00:00
         _STATISTICS_WRITING_DATE_UTC-eng: 1970-01-01 00:00:00
         _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
         _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       Stream #0:1(jpn): Audio: aac (LC), 44100 Hz, stereo, fltp (default)
       Metadata:
         BPS             : 128000
         BPS-eng         : 128000
         DURATION        : 00:23:40.109000000
         DURATION-eng    : 00:23:40.109000000
         NUMBER_OF_FRAMES: 61159
         NUMBER_OF_FRAMES-eng: 61159
         NUMBER_OF_BYTES : 22721748
         NUMBER_OF_BYTES-eng: 22721748
         _STATISTICS_WRITING_APP: no_variable_data
         _STATISTICS_WRITING_APP-eng: no_variable_data
         _STATISTICS_WRITING_DATE_UTC: 1970-01-01 00:00:00
         _STATISTICS_WRITING_DATE_UTC-eng: 1970-01-01 00:00:00
         _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
         _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       Stream #0:2(eng): Subtitle: ass (default)
       Metadata:
         BPS             : 110
         BPS-eng         : 110
         DURATION        : 00:23:25.280000000
         DURATION-eng    : 00:23:25.280000000
         NUMBER_OF_FRAMES: 298
         NUMBER_OF_FRAMES-eng: 298
         NUMBER_OF_BYTES : 19407
         NUMBER_OF_BYTES-eng: 19407
         _STATISTICS_WRITING_APP: no_variable_data
         _STATISTICS_WRITING_APP-eng: no_variable_data
         _STATISTICS_WRITING_DATE_UTC: 1970-01-01 00:00:00
         _STATISTICS_WRITING_DATE_UTC-eng: 1970-01-01 00:00:00
         _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
         _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       Stream #0:3: Attachment: ttf
       Metadata:
         filename        : OpenSans-Semibold.ttf
         mimetype        : application/x-truetype-font
    [NULL @ 0x9eac90] Unable to find a suitable output format for 'subs.srt'
    subs.srt: Invalid argument

    the file is a mkv video file

    Other info

    Codecs:
    D..... = Decoding supported
    .E.... = Encoding supported
    ..V... = Video codec
    ..A... = Audio codec
    ..S... = Subtitle codec
    ...I.. = Intra frame-only codec
    ....L. = Lossy compression
    .....S = Lossless compression
    -------
    ..VI.. 012v                 Uncompressed 4:2:2 10-bit
    ..V.L. 4xm                  4X Movie
    ..VI.S 8bps                 QuickTime 8BPS video
    ..VIL. a64_multi            Multicolor charset for Commodore 64
    ..VIL. a64_multi5           Multicolor charset for Commodore 64, extended with 5th color (colram)
    ..V..S aasc                 Autodesk RLE
    ..VIL. aic                  Apple Intermediate Codec
    ..VI.S alias_pix            Alias/Wavefront PIX image
    ..VIL. amv                  AMV Video
    ..V.L. anm                  Deluxe Paint Animation
    ..V.L. ansi                 ASCII/ANSI art
    ..V..S apng                 APNG (Animated Portable Network Graphics) image
    ..VIL. asv1                 ASUS V1
    ..VIL. asv2                 ASUS V2
    ..VIL. aura                 Auravision AURA
    ..VIL. aura2                Auravision Aura 2
    ..V... avrn                 Avid AVI Codec
    ..VI.. avrp                 Avid 1:1 10-bit RGB Packer
    ..V.L. avs                  AVS (Audio Video Standard) video
    ..VI.. avui                 Avid Meridien Uncompressed
    ..VI.. ayuv                 Uncompressed packed MS 4:4:4:4
    ..V.L. bethsoftvid          Bethesda VID video
    ..V.L. bfi                  Brute Force &amp; Ignorance
    ..V.L. binkvideo            Bink video
    ..VI.. bintext              Binary text
    ..VI.S bmp                  BMP (Windows and OS/2 bitmap)
    ..V..S bmv_video            Discworld II BMV video
    ..VI.S brender_pix          BRender PIX image
    ..V.L. c93                  Interplay C93
    ..V.L. cavs                 Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)
    ..V.L. cdgraphics           CD Graphics video
    ..VIL. cdxl                 Commodore CDXL video
    ..V.L. cfhd                 Cineform HD
    ..V.L. cinepak              Cinepak
    ..VIL. cljr                 Cirrus Logic AccuPak
    ..VI.S cllc                 Canopus Lossless Codec
    ..V.L. cmv                  Electronic Arts CMV video
    ..V... cpia                 CPiA video format
    ..V..S cscd                 CamStudio
    ..VIL. cyuv                 Creative YUV (CYUV)
    ..V.LS daala                Daala
    ..VILS dds                  DirectDraw Surface image decoder
    ..V.L. dfa                  Chronomaster DFA
    ..V.LS dirac                Dirac
    ..VIL. dnxhd                VC3/DNxHD
    ..VI.S dpx                  DPX (Digital Picture Exchange) image
    ..V.L. dsicinvideo          Delphine Software International CIN video
    ..VIL. dvvideo              DV (Digital Video)
    ..V..S dxa                  Feeble Files/ScummVM DXA
    ..VI.S dxtory               Dxtory
    ..VIL. dxv                  Resolume DXV
    ..V.L. escape124            Escape 124
    ..V.L. escape130            Escape 130
    ..VILS exr                  OpenEXR image
    ..V..S ffv1                 FFmpeg video codec #1
    ..VI.S ffvhuff              Huffyuv FFmpeg variant
    ..V.L. fic                  Mirillis FIC
    ..V..S flashsv              Flash Screen Video v1
    ..V.L. flashsv2             Flash Screen Video v2
    ..V..S flic                 Autodesk Animator Flic video
    ..V.L. flv1                 FLV / Sorenson Spark / Sorenson H.263 (Flash Video)
    ..V..S fraps                Fraps
    ..VI.S frwu                 Forward Uncompressed
    ..V.L. g2m                  Go2Meeting
    ..V..S gif                  GIF (Graphics Interchange Format)
    ..V.L. h261                 H.261
    D.V.L. h263                 H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2
    ..V.L. h263i                Intel H.263
    ..V.L. h263p                H.263+ / H.263-1998 / H.263 version 2
    D.V.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    ..VIL. hap                  Vidvox Hap decoder
    D.V.L. hevc                 H.265 / HEVC (High Efficiency Video Coding)
    ..V.L. hnm4video            HNM 4 video
    ..VIL. hq_hqa               Canopus HQ/HQA
    ..VIL. hqx                  Canopus HQX
    ..VI.S huffyuv              HuffYUV
    ..V.L. idcin                id Quake II CIN video
    ..VI.. idf                  iCEDraw text
    ..V.L. iff_ilbm             IFF ACBM/ANIM/DEEP/ILBM/PBM/RGB8/RGBN
    ..V.L. indeo2               Intel Indeo 2
    ..V.L. indeo3               Intel Indeo 3
    ..V.L. indeo4               Intel Indeo Video Interactive 4
    ..V.L. indeo5               Intel Indeo Video Interactive 5
    ..V.L. interplayvideo       Interplay MVE video
    ..VILS jpeg2000             JPEG 2000
    ..VILS jpegls               JPEG-LS
    ..VIL. jv                   Bitmap Brothers JV video
    ..V.L. kgv1                 Kega Game Video
    ..V.L. kmvc                 Karl Morton's video codec
    ..VI.S lagarith             Lagarith lossless
    ..VI.S ljpeg                Lossless JPEG
    ..VI.S loco                 LOCO
    ..VI.S m101                 Matrox Uncompressed SD
    ..V.L. mad                  Electronic Arts Madcow Video
    ..VI.S magicyuv             MagicYUV Lossless Video
    ..VIL. mdec                 Sony PlayStation MDEC (Motion DECoder)
    ..V.L. mimic                Mimic
    DEVIL. mjpeg                Motion JPEG
    ..VIL. mjpegb               Apple MJPEG-B
    ..V.L. mmvideo              American Laser Games MM Video
    ..V.L. motionpixels         Motion Pixels video
    ..V.L. mpeg1video           MPEG-1 video
    D.V.L. mpeg2video           MPEG-2 video
    D.V.L. mpeg4                MPEG-4 part 2
    ..V.L. mpegvideo_xvmc       MPEG-1/2 video XvMC (X-Video Motion Compensation)
    ..V.L. msa1                 MS ATC Screen
    ..V.L. msmpeg4v1            MPEG-4 part 2 Microsoft variant version 1
    ..V.L. msmpeg4v2            MPEG-4 part 2 Microsoft variant version 2
    ..V.L. msmpeg4v3            MPEG-4 part 2 Microsoft variant version 3
    ..V..S msrle                Microsoft RLE
    ..V.L. mss1                 MS Screen 1
    ..VIL. mss2                 MS Windows Media Video V9 Screen
    ..V.L. msvideo1             Microsoft Video 1
    ..VI.S mszh                 LCL (LossLess Codec Library) MSZH
    ..V.L. mts2                 MS Expression Encoder Screen
    ..VIL. mvc1                 Silicon Graphics Motion Video Compressor 1
    ..VIL. mvc2                 Silicon Graphics Motion Video Compressor 2
    ..V.L. mxpeg                Mobotix MxPEG video
    ..V.L. nuv                  NuppelVideo/RTJPEG
    ..V.L. paf_video            Amazing Studio Packed Animation File Video
    ..VI.S pam                  PAM (Portable AnyMap) image
    ..VI.S pbm                  PBM (Portable BitMap) image
    ..VI.S pcx                  PC Paintbrush PCX image
    ..VI.S pgm                  PGM (Portable GrayMap) image
    ..VI.S pgmyuv               PGMYUV (Portable GrayMap YUV) image
    ..VIL. pictor               Pictor/PC Paint
    ..V..S png                  PNG (Portable Network Graphics) image
    ..VI.S ppm                  PPM (Portable PixelMap) image
    ..VIL. prores               Apple ProRes (iCodec Pro)
    ..VIL. ptx                  V.Flash PTX image
    ..VI.S qdraw                Apple QuickDraw
    ..V.L. qpeg                 Q-team QPEG
    ..V..S qtrle                QuickTime Animation (RLE) video
    ..VI.S r10k                 AJA Kona 10-bit RGB Codec
    ..VI.S r210                 Uncompressed RGB 10-bit
    ..VI.S rawvideo             raw video
    ..VIL. rl2                  RL2 video
    ..V.L. roq                  id RoQ video
    ..V.L. rpza                 QuickTime video (RPZA)
    ..V..S rscc                 innoHeim/Rsupport Screen Capture Codec
    ..V.L. rv10                 RealVideo 1.0
    ..V.L. rv20                 RealVideo 2.0
    ..V.L. rv30                 RealVideo 3.0
    ..V.L. rv40                 RealVideo 4.0
    ..V.L. sanm                 LucasArts SANM/SMUSH video
    ..V..S screenpresso         Screenpresso
    ..VI.S sgi                  SGI image
    ..VI.S sgirle               SGI RLE 8-bit
    ..VI.S sheervideo           BitJazz SheerVideo
    ..V.L. smackvideo           Smacker video
    ..V.L. smc                  QuickTime Graphics (SMC)
    ..V... smvjpeg              Sigmatel Motion Video
    ..V.LS snow                 Snow
    ..VIL. sp5x                 Sunplus JPEG (SP5X)
    ..VI.S sunrast              Sun Rasterfile image
    ..V.L. svq1                 Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1
    ..V.L. svq3                 Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3
    ..VI.S targa                Truevision Targa image
    ..VI.. targa_y216           Pinnacle TARGA CineWave YUV16
    ..V.L. tdsc                 TDSC
    ..V.L. tgq                  Electronic Arts TGQ video
    ..V.L. tgv                  Electronic Arts TGV video
    D.V.L. theora               Theora
    ..VIL. thp                  Nintendo Gamecube THP video
    ..V.L. tiertexseqvideo      Tiertex Limited SEQ video
    ..VI.S tiff                 TIFF image
    ..VIL. tmv                  8088flex TMV
    ..V.L. tqi                  Electronic Arts TQI video
    ..V.L. truemotion1          Duck TrueMotion 1.0
    ..V.L. truemotion2          Duck TrueMotion 2.0
    ..V.L. truemotion2rt        Duck TrueMotion 2.0 Real Time
    ..V..S tscc                 TechSmith Screen Capture Codec
    ..V.L. tscc2                TechSmith Screen Codec 2
    ..VIL. txd                  Renderware TXD (TeXture Dictionary) image
    ..V.L. ulti                 IBM UltiMotion
    ..VI.S utvideo              Ut Video
    ..VI.S v210                 Uncompressed 4:2:2 10-bit
    ..VI.S v210x                Uncompressed 4:2:2 10-bit
    ..VI.. v308                 Uncompressed packed 4:4:4
    ..VI.. v408                 Uncompressed packed QT 4:4:4:4
    ..VI.S v410                 Uncompressed 4:4:4 10-bit
    ..V.L. vb                   Beam Software VB
    ..VI.S vble                 VBLE Lossless Codec
    ..V.L. vc1                  SMPTE VC-1
    ..V.L. vc1image             Windows Media Video 9 Image v2
    ..VIL. vcr1                 ATI VCR1
    ..VIL. vixl                 Miro VideoXL
    ..V.L. vmdvideo             Sierra VMD video
    ..V..S vmnc                 VMware Screen Codec / VMware Video
    D.V.L. vp3                  On2 VP3
    ..V.L. vp5                  On2 VP5
    ..V.L. vp6                  On2 VP6
    ..V.L. vp6a                 On2 VP6 (Flash version, with alpha channel)
    ..V.L. vp6f                 On2 VP6 (Flash version)
    ..V.L. vp7                  On2 VP7
    DEV.L. vp8                  On2 VP8 (encoders: libvpx )
    D.V.L. vp9                  Google VP9
    ..VILS webp                 WebP
    ..V.L. wmv1                 Windows Media Video 7
    ..V.L. wmv2                 Windows Media Video 8
    ..V.L. wmv3                 Windows Media Video 9
    ..V.L. wmv3image            Windows Media Video 9 Image
    ..VIL. wnv1                 Winnov WNV1
    ..V..S wrapped_avframe      AVFrame to AVPacket passthrough
    ..V.L. ws_vqa               Westwood Studios VQA (Vector Quantized Animation) video
    ..V.L. xan_wc3              Wing Commander III / Xan
    ..V.L. xan_wc4              Wing Commander IV / Xxan
    ..VI.. xbin                 eXtended BINary text
    ..VI.S xbm                  XBM (X BitMap) image
    ..VIL. xface                X-face image
    ..VI.S xwd                  XWD (X Window Dump) image
    ..VI.. y41p                 Uncompressed YUV 4:1:1 12-bit
    ..VI.S ylc                  YUY2 Lossless Codec
    ..V.L. yop                  Psygnosis YOP Video
    ..VI.. yuv4                 Uncompressed packed 4:2:0
    ..V..S zerocodec            ZeroCodec Lossless Video
    ..VI.S zlib                 LCL (LossLess Codec Library) ZLIB
    ..V..S zmbv                 Zip Motion Blocks Video
    ..A.L. 4gv                  4GV (Fourth Generation Vocoder)
    ..A.L. 8svx_exp             8SVX exponential
    ..A.L. 8svx_fib             8SVX fibonacci
    D.A.L. aac                  AAC (Advanced Audio Coding)
    ..A.L. aac_latm             AAC LATM (Advanced Audio Coding LATM syntax)
    D.A.L. ac3                  ATSC A/52A (AC-3)
    ..A.L. adpcm_4xm            ADPCM 4X Movie
    ..A.L. adpcm_adx            SEGA CRI ADX ADPCM
    ..A.L. adpcm_afc            ADPCM Nintendo Gamecube AFC
    ..A.L. adpcm_aica           ADPCM Yamaha AICA
    ..A.L. adpcm_ct             ADPCM Creative Technology
    ..A.L. adpcm_dtk            ADPCM Nintendo Gamecube DTK
    ..A.L. adpcm_ea             ADPCM Electronic Arts
    ..A.L. adpcm_ea_maxis_xa    ADPCM Electronic Arts Maxis CDROM XA
    ..A.L. adpcm_ea_r1          ADPCM Electronic Arts R1
    ..A.L. adpcm_ea_r2          ADPCM Electronic Arts R2
    ..A.L. adpcm_ea_r3          ADPCM Electronic Arts R3
    ..A.L. adpcm_ea_xas         ADPCM Electronic Arts XAS
    ..A.L. adpcm_g722           G.722 ADPCM
    ..A.L. adpcm_g726           G.726 ADPCM
    ..A.L. adpcm_g726le         G.726 ADPCM little-endian
    ..A.L. adpcm_ima_amv        ADPCM IMA AMV
    ..A.L. adpcm_ima_apc        ADPCM IMA CRYO APC
    ..A.L. adpcm_ima_dat4       ADPCM IMA Eurocom DAT4
    ..A.L. adpcm_ima_dk3        ADPCM IMA Duck DK3
    ..A.L. adpcm_ima_dk4        ADPCM IMA Duck DK4
    ..A.L. adpcm_ima_ea_eacs    ADPCM IMA Electronic Arts EACS
    ..A.L. adpcm_ima_ea_sead    ADPCM IMA Electronic Arts SEAD
    ..A.L. adpcm_ima_iss        ADPCM IMA Funcom ISS
    ..A.L. adpcm_ima_oki        ADPCM IMA Dialogic OKI
    ..A.L. adpcm_ima_qt         ADPCM IMA QuickTime
    ..A.L. adpcm_ima_rad        ADPCM IMA Radical
    ..A.L. adpcm_ima_smjpeg     ADPCM IMA Loki SDL MJPEG
    ..A.L. adpcm_ima_wav        ADPCM IMA WAV
    ..A.L. adpcm_ima_ws         ADPCM IMA Westwood
    ..A.L. adpcm_ms             ADPCM Microsoft
    ..A.L. adpcm_mtaf           ADPCM MTAF
    ..A.L. adpcm_psx            ADPCM Playstation
    ..A.L. adpcm_sbpro_2        ADPCM Sound Blaster Pro 2-bit
    ..A.L. adpcm_sbpro_3        ADPCM Sound Blaster Pro 2.6-bit
    ..A.L. adpcm_sbpro_4        ADPCM Sound Blaster Pro 4-bit
    ..A.L. adpcm_swf            ADPCM Shockwave Flash
    ..A.L. adpcm_thp            ADPCM Nintendo THP
    ..A.L. adpcm_thp_le         ADPCM Nintendo THP (Little-Endian)
    ..A.L. adpcm_vima           LucasArts VIMA audio
    ..A.L. adpcm_xa             ADPCM CDROM XA
    ..A.L. adpcm_yamaha         ADPCM Yamaha
    ..A..S alac                 ALAC (Apple Lossless Audio Codec)
    ..A.L. amr_nb               AMR-NB (Adaptive Multi-Rate NarrowBand)
    ..A.L. amr_wb               AMR-WB (Adaptive Multi-Rate WideBand)
    ..A..S ape                  Monkey's Audio
    ..A.L. atrac1               ATRAC1 (Adaptive TRansform Acoustic Coding)
    ..A.L. atrac3               ATRAC3 (Adaptive TRansform Acoustic Coding 3)
    ..A.L. atrac3p              ATRAC3+ (Adaptive TRansform Acoustic Coding 3+)
    ..A.L. avc                  On2 Audio for Video Codec
    ..A.L. binkaudio_dct        Bink Audio (DCT)
    ..A.L. binkaudio_rdft       Bink Audio (RDFT)
    ..A.L. bmv_audio            Discworld II BMV audio
    ..A.L. celt                 Constrained Energy Lapped Transform (CELT)
    ..A.L. comfortnoise         RFC 3389 Comfort Noise
    ..A.L. cook                 Cook / Cooker / Gecko (RealAudio G2)
    ..A.L. dsd_lsbf             DSD (Direct Stream Digital), least significant bit first
    ..A.L. dsd_lsbf_planar      DSD (Direct Stream Digital), least significant bit first, planar
    ..A.L. dsd_msbf             DSD (Direct Stream Digital), most significant bit first
    ..A.L. dsd_msbf_planar      DSD (Direct Stream Digital), most significant bit first, planar
    ..A.L. dsicinaudio          Delphine Software International CIN audio
    ..A.L. dss_sp               Digital Speech Standard - Standard Play mode (DSS SP)
    ..A..S dst                  DST (Direct Stream Transfer)
    ..A.LS dts                  DCA (DTS Coherent Acoustics)
    ..A.L. dvaudio              DV audio
    ..A.L. eac3                 ATSC A/52B (AC-3, E-AC-3)
    ..A.L. evrc                 EVRC (Enhanced Variable Rate Codec)
    ..A..S flac                 FLAC (Free Lossless Audio Codec)
    ..A.L. g723_1               G.723.1
    ..A.L. g729                 G.729
    ..A.L. gsm                  GSM
    ..A.L. gsm_ms               GSM Microsoft variant
    ..A.L. iac                  IAC (Indeo Audio Coder)
    ..A.L. ilbc                 iLBC (Internet Low Bitrate Codec)
    ..A.L. imc                  IMC (Intel Music Coder)
    ..A.L. interplay_dpcm       DPCM Interplay
    ..A.L. interplayacm         Interplay ACM
    ..A.L. mace3                MACE (Macintosh Audio Compression/Expansion) 3:1
    ..A.L. mace6                MACE (Macintosh Audio Compression/Expansion) 6:1
    ..A.L. metasound            Voxware MetaSound
    ..A..S mlp                  MLP (Meridian Lossless Packing)
    ..A.L. mp1                  MP1 (MPEG audio layer 1)
    ..A.L. mp2                  MP2 (MPEG audio layer 2)
    D.A.L. mp3                  MP3 (MPEG audio layer 3)
    ..A.L. mp3adu               ADU (Application Data Unit) MP3 (MPEG audio layer 3)
    ..A.L. mp3on4               MP3onMP4
    ..A..S mp4als               MPEG-4 Audio Lossless Coding (ALS)
    ..A.L. musepack7            Musepack SV7
    ..A.L. musepack8            Musepack SV8
    ..A.L. nellymoser           Nellymoser Asao
    DEA.L. opus                 Opus (Opus Interactive Audio Codec) (encoders: libopus )
    ..A.L. paf_audio            Amazing Studio Packed Animation File Audio
    ..A.L. pcm_alaw             PCM A-law / G.711 A-law
    ..A..S pcm_bluray           PCM signed 16|20|24-bit big-endian for Blu-ray media
    ..A..S pcm_dvd              PCM signed 20|24-bit big-endian
    ..A..S pcm_f32be            PCM 32-bit floating point big-endian
    ..A..S pcm_f32le            PCM 32-bit floating point little-endian
    ..A..S pcm_f64be            PCM 64-bit floating point big-endian
    ..A..S pcm_f64le            PCM 64-bit floating point little-endian
    ..A..S pcm_lxf              PCM signed 20-bit little-endian planar
    ..A.L. pcm_mulaw            PCM mu-law / G.711 mu-law
    ..A..S pcm_s16be            PCM signed 16-bit big-endian
    ..A..S pcm_s16be_planar     PCM signed 16-bit big-endian planar
    ..A..S pcm_s16le            PCM signed 16-bit little-endian
    ..A..S pcm_s16le_planar     PCM signed 16-bit little-endian planar
    ..A..S pcm_s24be            PCM signed 24-bit big-endian
    ..A..S pcm_s24daud          PCM D-Cinema audio signed 24-bit
    ..A..S pcm_s24le            PCM signed 24-bit little-endian
    ..A..S pcm_s24le_planar     PCM signed 24-bit little-endian planar
    ..A..S pcm_s32be            PCM signed 32-bit big-endian
    ..A..S pcm_s32le            PCM signed 32-bit little-endian
    ..A..S pcm_s32le_planar     PCM signed 32-bit little-endian planar
    ..A..S pcm_s8               PCM signed 8-bit
    ..A..S pcm_s8_planar        PCM signed 8-bit planar
    ..A..S pcm_u16be            PCM unsigned 16-bit big-endian
    ..A..S pcm_u16le            PCM unsigned 16-bit little-endian
    ..A..S pcm_u24be            PCM unsigned 24-bit big-endian
    ..A..S pcm_u24le            PCM unsigned 24-bit little-endian
    ..A..S pcm_u32be            PCM unsigned 32-bit big-endian
    ..A..S pcm_u32le            PCM unsigned 32-bit little-endian
    ..A..S pcm_u8               PCM unsigned 8-bit
    ..A.L. pcm_zork             PCM Zork
    ..A.L. qcelp                QCELP / PureVoice
    ..A.L. qdm2                 QDesign Music Codec 2
    ..A.L. qdmc                 QDesign Music
    ..A.L. ra_144               RealAudio 1.0 (14.4K)
    ..A.L. ra_288               RealAudio 2.0 (28.8K)
    ..A..S ralf                 RealAudio Lossless
    ..A.L. roq_dpcm             DPCM id RoQ
    ..A..S s302m                SMPTE 302M
    ..A.L. sdx2_dpcm            DPCM Squareroot-Delta-Exact
    ..A..S shorten              Shorten
    ..A.L. sipr                 RealAudio SIPR / ACELP.NET
    ..A.L. smackaudio           Smacker audio
    ..A.L. smv                  SMV (Selectable Mode Vocoder)
    ..A.L. sol_dpcm             DPCM Sol
    ..A... sonic                Sonic
    ..A... sonicls              Sonic lossless
    ..A.L. speex                Speex
    ..A..S tak                  TAK (Tom's lossless Audio Kompressor)
    ..A..S truehd               TrueHD
    ..A.L. truespeech           DSP Group TrueSpeech
    ..A..S tta                  TTA (True Audio)
    ..A.L. twinvq               VQF TwinVQ
    ..A.L. vmdaudio             Sierra VMD audio
    D.A.L. vorbis               Vorbis
    ..A.L. voxware              Voxware RT29 Metasound
    ..A... wavesynth            Wave synthesis pseudo-codec
    ..A.LS wavpack              WavPack
    ..A.L. westwood_snd1        Westwood Audio (SND1)
    ..A..S wmalossless          Windows Media Audio Lossless
    ..A.L. wmapro               Windows Media Audio 9 Professional
    ..A.L. wmav1                Windows Media Audio 1
    ..A.L. wmav2                Windows Media Audio 2
    ..A.L. wmavoice             Windows Media Audio Voice
    ..A.L. xan_dpcm             DPCM Xan
    ..A.L. xma1                 Xbox Media Audio 1
    ..A.L. xma2                 Xbox Media Audio 2
    ..D... bin_data             binary data
    ..D... dvd_nav_packet       DVD Nav packet
    ..D... klv                  SMPTE 336M Key-Length-Value (KLV) metadata
    ..D... otf                  OpenType font
    ..D... timed_id3            timed ID3 metadata
    ..D... ttf                  TrueType font
    D.S... ass                  ASS (Advanced SSA) subtitle (decoders: ssa ass )
    ..S... dvb_subtitle         DVB subtitles
    ..S... dvb_teletext         DVB teletext
    ..S... dvd_subtitle         DVD subtitles
    ..S... eia_608              EIA-608 closed captions
    ..S... hdmv_pgs_subtitle    HDMV Presentation Graphic Stream subtitles
    ..S... hdmv_text_subtitle   HDMV Text subtitle
    ..S... jacosub              JACOsub subtitle
    ..S... microdvd             MicroDVD subtitle
    ..S... mov_text             MOV text
    ..S... mpl2                 MPL2 subtitle
    ..S... pjs                  PJS (Phoenix Japanimation Society) subtitle
    ..S... realtext             RealText subtitle
    ..S... sami                 SAMI subtitle
    ..S... srt                  SubRip subtitle with embedded timing
    ..S... ssa                  SSA (SubStation Alpha) subtitle
    ..S... stl                  Spruce subtitle format
    D.S... subrip               SubRip subtitle (decoders: srt )
    ..S... subviewer            SubViewer subtitle
    ..S... subviewer1           SubViewer v1 subtitle
    ..S... text                 raw UTF-8 text
    ..S... vplayer              VPlayer subtitle
    D.S... webvtt               WebVTT subtitle
    ..S... xsub                 XSUB