Recherche avancée

Médias (0)

Mot : - Tags -/utilisateurs

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (103)

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

  • FFmpeg.swr_convert : audio to raw 16 bit pcm, to be used with xna SoundEffect. Audio cuts out when i convert

    21 mars 2019, par Robert Russell

    I want to resample mkv(vp8/ogg) and also raw 4 bit adpcm to raw 16bit pcm byte[] to be loaded into SoundEffect from xna library. So I can play it out while I’m using other code to display the frames (the video side is working).
    I can read a 16 bit wav file and play it. But when I goto resample something it doesn’t play 100%. One file is 3 mins and 15 secs. I only get 13 sec and 739 ms before it quits playing. I have been learning to do this by finding code samples in c++ and correcting it to work in c# using ffmpeg.autogen.

    the below is my best attempt at resampling.

               int nb_samples = Frame->nb_samples;
                       int output_nb_samples = nb_samples;
                       int nb_channels = ffmpeg.av_get_channel_layout_nb_channels(ffmpeg.AV_CH_LAYOUT_STEREO);
                       int bytes_per_sample = ffmpeg.av_get_bytes_per_sample(AVSampleFormat.AV_SAMPLE_FMT_S16) * nb_channels;
                       int bufsize = ffmpeg.av_samples_get_buffer_size(null, nb_channels, nb_samples,
                                                                AVSampleFormat.AV_SAMPLE_FMT_S16, 1);

                       byte*[] b = Frame->data;
                       fixed (byte** input = b)
                       {
                           byte* output = null;
                           ffmpeg.av_samples_alloc(&output, null,
                               nb_channels,
                               nb_samples,
                               (AVSampleFormat)Frame->format, 0);//

                           // Buffer input

                           Ret = ffmpeg.swr_convert(Swr, &output, output_nb_samples / 2, input, nb_samples);
                           CheckRet();
                           WritetoMs(output, 0, Ret * bytes_per_sample);
                           output_nb_samples -= Ret;

                           // Drain buffer
                           while ((Ret = ffmpeg.swr_convert(Swr, &output, output_nb_samples, null, 0)) > 0)
                           {
                               CheckRet();
                               WritetoMs(output, 0, Ret * bytes_per_sample);
                               output_nb_samples -= Ret;
                           }
                       }

    I changed that all to this but it cuts off sooner.

     Channels = ffmpeg.av_get_channel_layout_nb_channels(OutFrame->channel_layout);
                       int nb_channels = ffmpeg.av_get_channel_layout_nb_channels(ffmpeg.AV_CH_LAYOUT_STEREO);
                       int bytes_per_sample = ffmpeg.av_get_bytes_per_sample(AVSampleFormat.AV_SAMPLE_FMT_S16) * nb_channels;

                       if((Ret = ffmpeg.swr_convert_frame(Swr, OutFrame, Frame))>=0)
                           WritetoMs(*OutFrame->extended_data, 0, OutFrame->nb_samples * bytes_per_sample);
                       CheckRet();

    Both code use a function to set Swr it runs one time after the first frame is decoded.

           private void PrepareResampler()
       {
           ffmpeg.av_frame_copy_props(OutFrame, Frame);
           OutFrame->channel_layout = ffmpeg.AV_CH_LAYOUT_STEREO;
           OutFrame->format = (int)AVSampleFormat.AV_SAMPLE_FMT_S16;
           OutFrame->sample_rate = Frame->sample_rate;
           OutFrame->channels = 2;
           Swr = ffmpeg.swr_alloc();
           if (Swr == null)
               throw new Exception("SWR = Null");
           Ret = ffmpeg.swr_config_frame(Swr, OutFrame, Frame);
           CheckRet();
           Ret = ffmpeg.swr_init(Swr);
           CheckRet();
           Ret = ffmpeg.swr_is_initialized(Swr);
           CheckRet();
       }

    This is where I take the output and put it in the sound effect

    private void ReadAll()
       {

           using (Ms = new MemoryStream())
           {
               while (true)
               {
                   Ret = ffmpeg.av_read_frame(Format, Packet);
                   if (Ret == ffmpeg.AVERROR_EOF)
                       break;
                   CheckRet();
                   Decode();
               }
               if (Ms.Length > 0)
               {
                   se = new SoundEffect(Ms.ToArray(), 0, (int)Ms.Length, OutFrame->sample_rate, (AudioChannels)Channels, 0, 0);
                   //se.Duration; Stream->duration;


                   see = se.CreateInstance();
                   see.Play();
               }
           }
       }
  • How to detect a surge of activity in a video ?

    22 mars 2019, par Alain Collins

    I’d like to automatically detect a surge of activity in a video, e.g. basketball jump shot, hockey face-off, sprinters starting, etc., preferably using ffmpeg.

    In these instances, there’s some motion as the players assume their positions, followed by a pause as they wait for the ref to throw the ball or drop the puck, followed by a lot of motion as all players begin to react. It’s also typical that the camera will be still during this period and begin moving as the ball or puck changes position.

    I’ve tried using the ’select’ filter select='gt(scene,0.4)', but that seems to be more concerned with scene changes (i.e., more dramatic changes) even with low thresholds.

    I also tried exporting the scene information and examining it manually, but couldn’t find a clear pattern that correlated with motion in the video.

    UPDATE : I ran a mestimate on the video. Processing took a long time, but there was definitely a change in activity before and at point of interest. Is there a way to export this information to a file, or otherwise detect the amount of motion seen my mestimate ?

  • Decoding YUYV422 raw images using FFmpeg

    12 avril 2019, par user373864q

    I have a collection of sequential YUYV422 raw images that I wish to turn into a video. The problem seems to be that when the frame is created in the avcodec_receive_frame. The frame only contains one channel instead of four in the YUYV format. This results in Input picture width <640> is greater then stride (0) since only the zeroth index of data and linesize is set in the frame. I don’t know if this is a ffmpeg bug or a misconfiguration on my part.

    #include "icsFfmpegImageDecoder.h"
    #include <stdexcept>

    ImageDecoder::ImageDecoder(std::string filename)
    {
       AVInputFormat* iformat;
       if (!(iformat = av_find_input_format("image2")))
           throw std::invalid_argument(std::string("input Codec not found\n"));

       this->fctx = NULL;
       if (avformat_open_input(&amp;this->fctx, filename.c_str(), iformat, NULL) &lt; 0)
       {
           std::string error = "Failed to open input file ";
           error += filename;
           error += "\n";
           throw std::invalid_argument(error);
       }
    #ifdef LIB_AVFORMAT_STREAM_CODEC_DEPRECATED
       if (!(this->codec = avcodec_find_decoder(this->fctx->streams[0]->codecpar->codec_id)))
           throw std::invalid_argument(std::string("Failed to find codec\n"));

       if (!(this->cctx = avcodec_alloc_context3(this->codec)))
           throw std::invalid_argument(std::string("could not create image read context codec"));

       if (avcodec_parameters_to_context(this->cctx, this->fctx->streams[0]->codecpar) &lt; 0)
           throw std::invalid_argument(std::string("could not get contest codec from stream"));
    #else
       this->cctx = this->fctx->streams[0]->codec;
       if (!(this->codec = avcodec_find_decoder(this->cctx->codec_id)))
           throw std::invalid_argument(std::string("Failed to find codec\n"));
    #endif

       if (this->cctx->codec_id == AV_CODEC_ID_RAWVIDEO) {
           // TODO Make Dynamic
           this->cctx->pix_fmt = AV_PIX_FMT_YUYV422 ;
           this->cctx->height = 800;
           this->cctx->width = 1280;
       }

       if (avcodec_open2(this->cctx, this->codec, NULL) &lt; 0)
           throw std::invalid_argument(std::string("Failed to open codec\n"));

    #ifdef USING_NEW_AVPACKET_SETUP
       if (!(this->pkt = av_packet_alloc()))
           throw std::invalid_argument(std::string("Failed to alloc frame\n"));
    #else
       this->pkt = new AVPacket();
       av_init_packet(this->pkt);
    #endif
       read_file();
    }

    ImageDecoder::~ImageDecoder()
    {
       avcodec_close(this->cctx);
       avformat_close_input(&amp;this->fctx);
    #ifdef USING_NEW_AVPACKET_SETUP
       av_packet_free(&amp;this->pkt);
    #else
       av_free_packet(this->pkt);
       delete this->pkt;
    #endif
    }

    void ImageDecoder::read_file()
    {
       if (av_read_frame(this->fctx, this->pkt) &lt; 0)
           throw std::invalid_argument(std::string("Failed to read frame from file\n"));

       if (this->pkt->size == 0)  
           this->ret = -1;
    }

    #ifdef LIB_AVCODEC_USE_SEND_RECEIVE_NOTATION
    void ImageDecoder::send_next_packet() {

       if ((this->ret = avcodec_send_packet(this->cctx, this->pkt)) &lt; 0)
           throw std::invalid_argument("Error sending a packet for decoding\n");
    }

    bool ImageDecoder::receive_next_frame(AVFrame* frame)
    {
       if (this->ret >= 0)
       {
           this->ret = avcodec_receive_frame(this->cctx, frame);
           if (this->ret == AVERROR_EOF)
               return false;
           else if (this->ret == AVERROR(11))//11 == EAGAIN builder sucks
               return false;
           else if (this->ret &lt; 0)
               throw std::invalid_argument("Error during decoding\n");
           return true;
       }
       return false;
    }
    #else
    void ImageDecoder::decode_frame(AVFrame* frame)
    {
       int got_frame = 0;
       if (avcodec_decode_video2(this->cctx, frame, &amp;got_frame, this->pkt) &lt; 0)
           throw std::invalid_argument("Error while decoding frame %d\n");
    }
    #endif
    </stdexcept>