Recherche avancée

Médias (1)

Mot : - Tags -/école

Autres articles (111)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • XMP PHP

    13 mai 2011, par

    Dixit Wikipedia, XMP signifie :
    Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
    Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
    XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)

Sur d’autres sites (12944)

  • FFMPEG Implement RTSP Client, high speed playback

    11 juillet 2021, par TTGroup

    I am writing software to play videos that have been recorded from NVR. I have completed most of the work, but there is one more feature that allows the user to change the play speed such as 0.5x, 2x, 4x, 8x ...

    


    I searched the internet all day and still couldn't find any suggestions. Here is my summary code below.

    


    auto pFormatCtx = avformat_alloc_context();

av_dict_set_int(&opts, "rw_timeout", 5000000, 0);
av_dict_set_int(&opts, "tcp_nodelay", 1, 0);
av_dict_set_int(&opts, "stimeout", 10000000, 0);
av_dict_set(&opts, "user_agent", "Mozilla/5.0", 0);
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
av_dict_set(&opts, "rtsp_flags", "prefer_tcp", 0);
av_dict_set_int(&opts, "buffer_size", BUFSIZE, 0);

int err = avformat_open_input(&pFormatCtx, fullRtspUri, NULL, &opts);
if(err < 0)
    return;
    
err = avformat_find_stream_info(pFormatCtx, NULL);
if (err < 0)
    return;
pFormatCtx->flags |= AVFMT_FLAG_NONBLOCK;
pFormatCtx->flags |= AVFMT_FLAG_DISCARD_CORRUPT;
pFormatCtx->flags |= AVFMT_FLAG_NOBUFFER;       
av_dump_format(pFormatCtx, 0, fullRtspUri, 0);
    
int videoStreamInd = -1;
for (int i = 0; i < pFormatCtx->nb_streams; i++)
{
    AVStream* stream = pFormatCtx->streams[i];
    if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
    {
        if (videoStreamInd == -1)
        {
            videoStreamInd = i;
            break;
        }
    }   
}

if (videoStreamInd == -1)
    return; 
auto videoStream = pFormatCtx->streams[videoStreamInd];

isRunning = true;
while(isRunning)
{
    ret = av_read_frame(pFormatCtx, avPacket);
    if (ret < 0)
        return; 

    if (avPacket->stream_index != videoStreamInd)
        continue;
    
    //Code for render process here............
}


    


    I have read through this NVR API documentation and see support for 2x, 4x speed play as below

    


    Play in 2× Speed:
PLAY rtsp://10.17.133.46:554/ISAPI/streaming/tracks/101?starttime=20170313T230652Z&endtime=20170314T025706Z RTSP/1.0
CSeq:6
Authorization: Digest username="admin", 
realm="4419b66d2485", 
nonce="a0ecd9b1586ff9461f02f910035d0486", 
uri="rtsp://10.17.133.46:554/ISAPI/streaming/tracks/101?starttime=20170313T230652Z&endtime=20170314T025706Z", 
response="fb986d385a7d839052ec4f0b2b70c631"
Session:2049381566;timeout=60
Scale:2.000
User-Agent:NKPlayer-1.00.00.081112

RTSP/1.0 200 OK
CSeq: 6
Session: 2049381566
Scale: 2.000
RTP-Info: url=trackID=1;seq=1,url=trackID=2;seq=1
Date: Tue, Mar 14 2017 10:57:24 GMT


    


    How to play RTSP video with speeds of 0.5x, 2x, 4x ...?
Everyone who can assist me in this case, I am very grateful.

    


  • Generating mp4 from images with libavformat has really high framerate

    13 septembre 2016, par Taylor Southwick

    I want to generate video from still shots using libav. I’ve successfully done this when the container is .avi, but I would also like to be able to output it into .mp4. However, when I try to do this, on the initial frame is shown (the .avi version works fine. I’ve created the following repro of the pertinent code using dummy picture generation.

    If you run

    CreateVideo("test.avi", 600, 300);

    It will generate a functional video. However,

    CreateVideo("test.mp4", 600, 300);

    will generate a video, but only a single frame.

    Any thoughts on why it works for .avi but not .mp4 ? Is there a setting I’m missing ?

    extern "C" {
    #include <libavformat></libavformat>avformat.h>
    #include <libavutil></libavutil>avassert.h>
    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>opt.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>imgutils.h>
    #include <libswscale></libswscale>swscale.h>
    #include <libswresample></libswresample>swresample.h>
    }

    using namespace std;
    using namespace Ffmpeg;

    void AddFrame(AVPacket &amp;pkt, AVCodecContext *codec, AVFormatContext *_avFmtCtx, AVFrame *_frame, int i)
    {
       // Initialize a packet and clear data as it will be allocated by the encoder
       av_init_packet(&amp;pkt);
       pkt.data = nullptr;
       pkt.size = 0;

       i = i % 25;

       /* prepare a dummy image */
       /* Y */
       for (int y = 0; y &lt; _frame->height; y++) {
           for (int x = 0; x &lt; _frame->width; x++) {
               _frame->data[0][y * _frame->linesize[0] + x] = x + y + i * 3;
           }
       }

       /* Cb and Cr */
       for (int y = 0; y &lt; _frame->height / 2; y++) {
           for (int x = 0; x &lt; _frame->width / 2; x++) {
               _frame->data[1][y * _frame->linesize[1] + x] = 128 + y + i * 2;
               _frame->data[2][y * _frame->linesize[2] + x] = 64 + x + i * 5;
           }
       }

       int got_output;
       avcodec_encode_video2(codec, &amp;pkt, _frame, &amp;got_output);

       _frame->pts++;

       if (got_output)
       {
           av_interleaved_write_frame(_avFmtCtx, &amp;pkt);
           av_packet_unref(&amp;pkt);
       }
    }

    static void CreateVideo(string path, int width, int height)
    {
       // This will quickly exit if registration has already occurred
       av_register_all();

       AVFormatContext *_avFmtCtx;
       avformat_alloc_output_context2(&amp;_avFmtCtx, nullptr, nullptr, path.c_str());

       AVCodec *codec = avcodec_find_encoder(_avFmtCtx->oformat->video_codec);
       AVStream *_video = avformat_new_stream(_avFmtCtx, codec);

       // Customize codec
       _video->codec->coder_type = AVMEDIA_TYPE_VIDEO;
       _video->codec->bit_rate = 200000;
       _video->codec->width = width;
       _video->codec->height = height;
       _video->codec->time_base.num = 1;
       _video->codec->time_base.den = 15;
       _video->codec->gop_size = 12;
       _video->codec->pix_fmt = AV_PIX_FMT_YUV420P;

       if (_video->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
       {
           // Just for testing, add B-frames
    #ifdef _DEBUG
           _video->codec->max_b_frames = 2;
    #endif
       }

       if (_video->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO)
       {
           _video->codec->mb_decision = 2;
       }

       if (_avFmtCtx->oformat->flags &amp; AVFMT_GLOBALHEADER)
       {
           _video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
       }

       // Open file
       avio_open(&amp;_avFmtCtx->pb, path.c_str(), AVIO_FLAG_WRITE);
       avformat_write_header(_avFmtCtx, nullptr);

       AVFrame *_frame = av_frame_alloc();
       _frame->format = _video->codec->pix_fmt;
       _frame->width = _video->codec->width;
       _frame->height = _video->codec->height;
       _frame->pts = 0;

       /* the image can be allocated by any means and av_image_alloc() is  *
        * just the most convenient way if av_malloc() is to be used        */
       av_image_alloc(_frame->data, _frame->linesize, _video->codec->width, _video->codec->height, _video->codec->pix_fmt, 32);

       avcodec_open2(_video->codec, codec, nullptr);

       SwsContext *_swsCtx = sws_getContext(width, height,
           AV_PIX_FMT_BGRA,
           width, height,
           AV_PIX_FMT_YUV420P,
           0, 0, 0, 0);

       AVPacket packet;
       for (int i = 0; i &lt; 25; i++)
       {
           AddFrame(packet, _video->codec, _avFmtCtx, _frame, i);
       }

       /* get the delayed frames */
       int got_output = 1;
       while (got_output)
       {
           // Initialize a packet and clear data as it will be allocated by the encoder
           AVPacket pkt;
           av_init_packet(&amp;pkt);
           pkt.data = nullptr;
           pkt.size = 0;

           avcodec_encode_video2(_video->codec, &amp;pkt, nullptr, &amp;got_output);

           if (got_output)
           {
               av_interleaved_write_frame(_avFmtCtx, &amp;pkt);
               av_packet_unref(&amp;pkt);
           }
       }

       av_write_trailer(_avFmtCtx);
       avio_close(_avFmtCtx->pb);
       sws_freeContext(_swsCtx);
       av_freep(&amp;_frame->data);
       av_frame_free(&amp;_frame);
       avcodec_close(_video->codec);
       avformat_free_context(_avFmtCtx);
    }
  • How to calculate bitrate of lower resolution videos created from high resolution video ?

    4 avril 2020, par Ryosuke

    I am trying to implement HLS video using ffmpeg. Suppose I have a video with following specs :

    &#xA;&#xA;

    1080x1920 bitrate: 20971649&#xA;

    &#xA;&#xA;

    Now I have to write a command to convert it to for example : 720p. So now the actual converted video by ffmpeg has bitrate : 760808.

    &#xA;&#xA;

    Is there a way that I can know this bitrate before hand, so that I can include in the master playlist correctly ?

    &#xA;