Recherche avancée

Médias (91)

Autres articles (34)

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

  • How to record frames with ffmpeg and finish the recording

    20 février 2024, par Jorge Augusto Wilchen

    In the following code, i trying to create a class to record frames from an IP camera (RTSP), save frames on a .avi file and finish the record, but, when i kill the operation, the video file may be corrupted. Have any other more safely way to stop the ffmpeg recording ?

    


    .cpp file :

    


    #include "videorecorder.h"


VideoRecorder::VideoRecorder(const std::string& rtspUrl) :
    url(rtspUrl),
    recording(false)
{

}

VideoRecorder::~VideoRecorder()
{
    end_record();
}

bool VideoRecorder::start_record(const std::string &fileName)
{
    if (recording) {
        std::cerr << "Already recording." << std::endl;
        return false;
    }

    std::string command = "ffmpeg -rtsp_transport udp -i " + url
                          + " -c:v mjpeg -preset fast -qp 0 " + fileName;

    videoWriter = popen(command.c_str(), "w");
    if (!videoWriter) {
        std::cerr << "Error opening ffmpeg process." << std::endl;
        return false;
    }

    recording = true;
    ffmpegProcessId = getpid();
    std::cout << "Recording started." << std::endl;
    return true;
}

bool VideoRecorder::end_record()
{
    if (recording) {
        if (videoWriter) {
            pid_t ffmpegPID = fileno(videoWriter);

            if (kill(ffmpegPID, SIGTERM) == 0) {
                std::cout << "Recording terminated successfully." << std::endl;
            } else {
                std::cerr << "Error terminating recording." << std::endl;
                return false;
            }

            int status = pclose(videoWriter);

            if (status == 0) {
                std::cout << "Recording ended successfully." << std::endl;
            } else {
                std::cerr << "Error ending recording. pclose status: " << status << std::endl;
                return false;
            }
        } else {
            std::cerr << "Error ending recording. videoWriter is nullptr." << std::endl;
            return false;
        }

        recording = false;
        return true;
    }

    return false;
}


    


    .h file :

    


    #ifndef VIDEORECORDER_H&#xA;#define VIDEORECORDER_H&#xA;&#xA;#include <string>&#xA;#include <iostream>&#xA;#include <fstream>&#xA;#include <cstdlib>&#xA;#include <csignal>&#xA;#include <sys></sys>wait.h>&#xA;&#xA;extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>avutil.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include &#xA;}&#xA;&#xA;#include <linux></linux>videodev2.h>&#xA;&#xA;#include <opencv2></opencv2>opencv.hpp>&#xA;#include <opencv2></opencv2>videoio.hpp>&#xA;#include <opencv2></opencv2>highgui/highgui.hpp>&#xA;&#xA;&#xA;class VideoRecorder&#xA;{&#xA;public:&#xA;    VideoRecorder(const std::string&amp; rtspUrl);&#xA;    ~VideoRecorder();&#xA;    bool start_record(const std::string&amp; fileName);&#xA;    bool end_record();&#xA;&#xA;private:&#xA;    std::string url;&#xA;    AVFormatContext *formatContext;&#xA;    AVStream *videoStream;&#xA;    AVCodecContext *codecContext;&#xA;    AVCodec *codec;&#xA;    SwsContext *swsContext;&#xA;    AVFrame *frame;&#xA;    AVPacket packet;&#xA;    bool recording;&#xA;    pid_t ffmpegProcessId;&#xA;    FILE* videoWriter;&#xA;};&#xA;&#xA;#endif // VIDEORECORDER_H&#xA;</csignal></cstdlib></fstream></iostream></string>

    &#xA;

    I'm using the ffmpeg lib becouse i need max speed on frames recording, and OpenCV and AV Lib is much slowness than ffmpeg.

    &#xA;

    This my terminal output after recording during 10 seconds (generated a file with 23 seconds duration) :

    &#xA;

    Recording started.&#xA;ffmpeg version 4.3.6-0&#x2B;deb11u1&#x2B;rpt5 Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with gcc 10 (Debian 10.2.1-6)&#xA;  configuration: --prefix=/usr --extra-version=0&#x2B;deb11u1&#x2B;rpt5 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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 --disable-mmal --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --enable-sand --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;  libpostproc    55.  7.100 / 55.  7.100&#xA;Input #0, rtsp, from &#x27;rtsp://admin:[password]@[ip]:[port]/live/0/MAIN&#x27;:&#xA;  Metadata:&#xA;    title           : RTSP Server&#xA;  Duration: N/A, start: 0.280000, bitrate: N/A&#xA;    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc&#xA;Codec AVOption preset (Configuration preset) specified for output file #0 (/home/guardian-tech/Pictures/output_frame.avi) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.&#xA;Codec AVOption qp (Constant quantization parameter rate control method) specified for output file #0 (/home/guardian-tech/Pictures/output_frame.avi) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))&#xA;Press [q] to stop, [?] for help&#xA;Output #0, avi, to &#x27;/home/guardian-tech/Pictures/output_frame.avi&#x27;:&#xA;  Metadata:&#xA;    INAM            : RTSP Server&#xA;    ISFT            : Lavf58.45.100&#xA;    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc), 1920x1080, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc&#xA;    Metadata:&#xA;      encoder         : Lavc58.91.100 mjpeg&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A&#xA;[rtsp @ 0x5592e7bb00] max delay reached. need to consume packet&#xA;[rtsp @ 0x5592e7bb00] RTP: missed 212 packets&#xA;[h264 @ 0x5592ebb790] concealing 2192 DC, 2192 AC, 2192 MV errors in I frame&#xA;rtsp://admin:[password]@[ip]:[port]/live/0/MAIN: corrupt decoded frame in stream 0&#xA;[rtsp @ 0x5592e7bb00] max delay reached. need to consume packet&#xA;[rtsp @ 0x5592e7bb00] RTP: missed 6 packets&#xA;[rtsp @ 0x5592e7bb00] max delay reached. need to consume packet&#xA;[rtsp @ 0x5592e7bb00] RTP: missed 14 packets&#xA;[h264 @ 0x5592f1bd30] cabac decode of qscale diff failed at 42 29&#xA;[h264 @ 0x5592f1bd30] error while decoding MB 42 29, bytestream 0&#xA;[h264 @ 0x5592f1bd30] concealing 4687 DC, 4687 AC, 4687 MV errors in I frame&#xA;rtsp://admin:[password]@[ip]:[port]/live/0/MAIN: corrupt decoded frame in stream 0&#xA;Error terminating recording.&#xA;

    &#xA;

  • Android record video from multiple cameras and composite the multiple videos into one video

    22 mars 2024, par tonySilver

    Android Camera2 records video from multiple cameras, adds real-time timestamps to the frames captured by each camera, and finally composites the multiple videos into a single video file. does Android's native interface support these features ? Do I have to user FFMPEG to handle the frames captured by each camera

    &#xA;

  • how to record screen of windows using ffmpeg inside WSL [closed]

    12 avril 2024, par Santhosh

    I have WSL2 and ubuntu installed inside it.

    &#xA;

    I have ffmpeg command line installed inside it.

    &#xA;

    Now I am not sure how to record the screen. Can someone help me what command options to be used to record screen (including windows UI)

    &#xA;

    I tried the below command.

    &#xA;

    Opened powershell in windows, then entered into wsl and then ran the below command

    &#xA;

     ffmpeg -f x11grab -y -framerate 30 -s 1920x1080 -i :0.0 -c:v libx264 -preset superfast -crf 18 out.mp4&#xA;

    &#xA;

    but it results in blank screen video

    &#xA;