Recherche avancée

Médias (1)

Mot : - Tags -/ogv

Autres articles (112)

  • 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 ;

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

Sur d’autres sites (11213)

  • How can I re-encode video frames to another codec using ffmpeg ?

    24 juillet 2019, par Pedro Constantino

    I am trying to learn ffmpeg, so I started a small project where I am sending an MP4 video stream to my C# application where I want to re-encode the video to webM and send it to an icecast server.

    My icecast server is receiving the video but I am not able to reproduce it (the video time is updated each time I press play but the video doesn’t play and I only see a black frame)

    Anyone can help me ? I have no idea of what is wrong in my code.

    My code execution flow is openInput->openOutput->streamingTest

      private void openInput()
       {
           _pInputFormatContext = ffmpeg.avformat_alloc_context();

           var pFormatContext = _pInputFormatContext;
           ffmpeg.avformat_open_input(&pFormatContext, configuration.Source, null, null).ThrowExceptionIfError();

           ffmpeg.avformat_find_stream_info(_pInputFormatContext, null).ThrowExceptionIfError();

           // find the first video stream
           for (var i = 0; i < _pInputFormatContext->nb_streams; i++)
               if (_pInputFormatContext->streams[i]->codec->codec_type == AVMediaType.AVMEDIA_TYPE_VIDEO)
               {
                   pInputStream = _pInputFormatContext->streams[i];
                   break;
               }

           if (pInputStream == null) throw new InvalidOperationException("Could not found video stream.");

           _inputStreamIndex = pInputStream->index;
           _pInputCodecContext = pInputStream->codec;

           var codecId = _pInputCodecContext->codec_id;
           var pCodec = ffmpeg.avcodec_find_decoder(codecId);
           if (pCodec == null) throw new InvalidOperationException("Unsupported codec.");

           ffmpeg.avcodec_open2(_pInputCodecContext, pCodec, null).ThrowExceptionIfError();

           configuration.CodecName = ffmpeg.avcodec_get_name(codecId);
           configuration.FrameSize = new Size(_pInputCodecContext->width, _pInputCodecContext->height);
           configuration.PixelFormat = _pInputCodecContext->pix_fmt;

           _pPacket = ffmpeg.av_packet_alloc();
           _pFrame = ffmpeg.av_frame_alloc();
       }


       private bool openOutput()
       {

           int ret;
           _pOutputFormatContext = ffmpeg.avformat_alloc_context();
           fixed (AVFormatContext** ppOutputFormatContext = &_pOutputFormatContext)
           {
               ret = ffmpeg.avformat_alloc_output_context2(ppOutputFormatContext, null, "webm", configuration.Destination);
               if (ret < 0)
               {
                   return false;
               }
           }

           AVOutputFormat* out_format = ffmpeg.av_guess_format(null, configuration.Destination, null);

           // Configure output video stream

           _pOutputStream = ffmpeg.avformat_new_stream(_pOutputFormatContext, null);

           AVStream* pInputVideoStream = null;

           for (var i = 0; i < _pInputFormatContext->nb_streams; i++)
           {
               if (_pInputFormatContext->streams[i]->codec->codec_type == AVMediaType.AVMEDIA_TYPE_VIDEO)
               {
                   pInputVideoStream = _pInputFormatContext->streams[i];
               }
           }

           ffmpeg.avcodec_parameters_copy(_pOutputStream->codecpar, pInputVideoStream->codecpar);

           _pOutputStream->codecpar->codec_type = AVMediaType.AVMEDIA_TYPE_VIDEO;
           _pOutputStream->codecpar->codec_id = AVCodecID.AV_CODEC_ID_VP8;

           AVDictionary* opt_dict;

           ffmpeg.av_dict_set(&opt_dict, "content_type", "video/webm", 0);
           ffmpeg.av_dict_set(&opt_dict, "user_agent", "GCS", 0);

           fixed (AVFormatContext** ppOutputFormatContext = &_pOutputFormatContext)
           {
               ret = ffmpeg.avio_open2(&_pOutputFormatContext->pb, configuration.Destination, ffmpeg.AVIO_FLAG_WRITE, null, &opt_dict);
               if (ret < 0)
               {
                   return false;
               }
           }

           ret = ffmpeg.avformat_write_header(_pOutputFormatContext, null);

           if (ret < 0)
           {
               return false;
           }

           ffmpeg.av_dump_format(_pOutputFormatContext, 0, configuration.Destination, 1);

           return true;
       }


       private unsafe void streamingTest(object gggg)
       {
           isStreamUp = true;

           AVPacket frame = new AVPacket();
           AVPacket* pFrame = &frame;
           ffmpeg.av_init_packet(pFrame);
           updateState(VideoStreamStates.Streaming);

           try
           {
               long start_time = ffmpeg.av_gettime();
               DateTime lastFrame = DateTime.MinValue;
               while (isStreamUp)
               {
                   if (cancelationToken.IsCancellationRequested)
                   {
                       throw new TaskCanceledException();
                   }

                   try
                   {
                       int error;
                       isReadingFrame = true;
                       do
                       {
                           error = ffmpeg.av_read_frame(_pInputFormatContext, pFrame);
                           if (error == ffmpeg.AVERROR_EOF)
                           {
                               frame = *pFrame;
                               continue;
                           }

                           error.ThrowExceptionIfError();
                       } while (frame.stream_index != _inputStreamIndex);

                       isWritingFrame = true;
                       //frame.stream_index = _outputStreamIndex;
                       _pOutputCodecContext = ffmpeg.avcodec_alloc_context3(_pOutputFormatContext->video_codec);

                       int ret = 0;
                       while (ret >= 0)
                       {
                           ret = ffmpeg.avcodec_receive_packet(_pOutputCodecContext, pFrame);
                       }

                       //ffmpeg.avcodec_send_frame(_pOutputCodecContext, pFrame);
                       //ffmpeg.avcodec_send_packet(_pOutputCodecContext, pFrame);

                       ret = ffmpeg.av_write_frame(_pOutputFormatContext, pFrame);

                       isWritingFrame = false;

                       if (frame.stream_index == _inputStreamIndex)
                       {
                           if (ret < 0)
                           {
                               Console.WriteLine("Missed frame");
                               missedFrames++;
                           }
                           else
                           {
                               Console.WriteLine("Sent frame");
                               sentFrames++;
                           }

                           AVRational time_base = _pInputFormatContext->streams[_inputStreamIndex]->time_base;
                           AVRational time_base_q = new AVRational();
                           time_base_q.num = 1;
                           time_base_q.den = ffmpeg.AV_TIME_BASE;

                           long pts_time = ffmpeg.av_rescale_q(frame.dts, time_base, time_base_q);
                           //long pts_time = ffmpeg.av_rescale_q(frame.dts, time_base_q, time_base);
                           long now_time = ffmpeg.av_gettime() - start_time;
                           if (pts_time > now_time)
                               ffmpeg.av_usleep((uint)(pts_time - now_time));
                       }
                       else
                           Console.WriteLine("????");
                   }
                   catch (Exception ex)
                   {
                       Console.WriteLine("Erro ao enviar: " + ex.Message);
                   }
                   finally
                   {
                       ffmpeg.av_packet_unref(pFrame);
                   }
               }
           }
           catch (TaskCanceledException)
           {
               updateState(VideoStreamStates.Stopped);
           }
           catch (Exception e)
           {
               Console.WriteLine(e.Message.ToString());
           }
       }
  • Place two videos side by side using ffmpeg ?and download it as one file

    5 août 2019, par marceloo1223

    I have two video files, which I want to play side by side and download them later. I used FFMPEG to merge them as one :

    protected void combinetwovideo()
    {
       string strParam;
       string Path_FFMPEG = Path.Combine(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["FFMpegPath"]));
       string apppath=HttpRuntime.AppDomainAppPath;
       //Merging two videos              
       String video1=apppath+"\\recordings\\client2019-08-03 02_23_59";
       String video2 =apppath+"\\userrecord\\User2019-08-03 02_24_00";
       String strResult =apppath+"\\RESULT\\";
       strParam = string.Format("-i ('" + video1 + "') -i ('" + video2 + "') -filter_complex \'[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid]' /-map [vid] -c:v libx264 -crf 23 -preset veryfast output.mp4");
       process(Path_FFMPEG, strParam);
    }
    public void process(string Path_FFMPEG, string strParam)
    {
       try
       {
           Process ffmpeg = new Process();
           ProcessStartInfo ffmpeg_StartInfo = new ProcessStartInfo(Path_FFMPEG, strParam);
           ffmpeg_StartInfo.UseShellExecute = false;
           ffmpeg_StartInfo.RedirectStandardError = true;
           ffmpeg_StartInfo.RedirectStandardOutput = true;
           ffmpeg.StartInfo = ffmpeg_StartInfo;
           ffmpeg_StartInfo.CreateNoWindow = true;
           ffmpeg.EnableRaisingEvents = true;
           ffmpeg.Start();
           ffmpeg.WaitForExit();
           ffmpeg.Close();
           ffmpeg.Dispose();
           ffmpeg = null;
       }
       catch (Exception ex)
       {
       }
    }

    But this method outputs nothing and does not throw any errors. I’m confused about the strParam query. Did I write it wrong or am I missing something. Any help would be apreciated.

  • How to read percentage from ffmpeg command in java ?

    23 juillet 2019, par Prasab R

    I am trying to convert video file to specific format by executing ffmpeg command. In that process I want to read percentage by using timepattern format. Somehow I am not able to do it.

    I have tried using the below code. Specially I am getting null in the while loop condition.

    import java.io.*;
    import java.util.Scanner;
    import java.util.regex.Pattern;

    class Test {
     public static void main(String[] args) throws IOException {
       ProcessBuilder pb = new ProcessBuilder("ffmpeg","-i","in.webm","out.mp4");
       final Process p = pb.start();

       new Thread() {
         public void run() {

           Scanner sc = new Scanner(p.getErrorStream());

           // Find duration
           Pattern durPattern = Pattern.compile("(?<=Duration: )[^,]*");
           String dur = sc.findWithinHorizon(durPattern, 0);
           if (dur == null)
             throw new RuntimeException("Could not parse duration.");
           String[] hms = dur.split(":");
           double totalSecs = Integer.parseInt(hms[0]) * 3600
                            + Integer.parseInt(hms[1]) *   60
                            + Double.parseDouble(hms[2]);
           System.out.println("Total duration: " + totalSecs + " seconds.");

           // Find time as long as possible.
           Pattern timePattern = Pattern.compile("(?<=time=)[\\d.]*");
           String match;
           while (null != (match = sc.findWithinHorizon(timePattern, 0))) {
             double progress = Double.parseDouble(match) / totalSecs;
             System.out.printf("Progress: %.2f%%%n", progress * 100);
           }
         }
       }.start();

     }
    }

    I am expecting a value in the while condition, but it coming as null.enter code here