Recherche avancée

Médias (3)

Mot : - Tags -/spip

Autres articles (48)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

Sur d’autres sites (7953)

  • How to stream Audio/Video using Node.js express streaming with ffmpeg and flowplayer usage ??

    30 septembre 2014, par iknowv

    I want to create node server which streams media file to public using express module in chunks

    Server.js ( This is nodejs server which works for me but without chunks )

               var express = require('express');
               var app = express();

               var http = require('http');
               var fs = require('fs');
               var path = require('path');
               var ext = /[\w\d_-]+\.[\w\d]+$/;

               ffmpeg_path = "ffmpeg\\";
               app.get('/player', function(req, res){
               res.writeHead(200, {'Content-Type': 'text/html'});
               fs.createReadStream('video.html').pipe(res);
               });

               app.get('/audio', function(req, res){

               myParam = [];
               myParam.push("-i","","-f","mp3","pipe:1");
               myParam[1] = 'media\\example_aac.m4a';
               var child_process = require("child_process");
               ffmpeg = child_process.spawn(ffmpeg_path + 'ffmpeg.exe',myParam);  
               ffmpeg.stderr.on('data', function(data)
               {
                   console.log('ffmpeg .error=' + data.toString());
               });
                res.writeHead(200, {
                  'Content-Type': 'audio/mp3'
                });
               ffmpeg.stdout.pipe(res);
               });


               app.get('/video', function(req, res){

               myParam = [];
               myParam.push("-i","","-f","flv","pipe:1");
               myParam[1] = 'media\\example_video.wmv';
               var child_process = require("child_process");
               ffmpeg = child_process.spawn(ffmpeg_path + 'ffmpeg.exe',myParam);  
               ffmpeg.stderr.on('data', function(data)
               {
                   console.log('ffmpeg .error=' + data.toString());
               });
               /*ffmpeg.stdout.on('data', function(data)
               {
               //var buff = new Buffer(data).toString();
               //res.send(buff);
               });*/
               res.writeHead(200, {
                  'Content-Type': 'video/flv'
                });
               ffmpeg.stdout.pipe(res);
               });

               app.listen(3000);

    =================================================

    video.html

                    <code class="echappe-js">&lt;script src=&quot;http://releases.flowplayer.org/js/flowplayer-3.2.13.min.js&quot;&gt;&lt;/script&gt;
                
    Audio Player
    Video Player
    &lt;script type=&quot;text/javascript&quot;&gt;<br />
               $f(&quot;player&quot;, &quot;http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf&quot;, {<br />
               clip: {<br />
                  autoPlay: false,<br />
                  url: &quot;http://localhost:3000/audio&quot;<br />
               },<br />
                plugins: {<br />
                   controls: {<br />
                       fullscreen: false,<br />
                       height: 30,<br />
                       autoHide: false<br />
                   }<br />
               }<br />
    <br />
               });<br />
               &lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;<br />
               flowplayer(&quot;videoplayer&quot;, &quot;http://localhost/flowplayer/flowplayer.commercial-3.2.2.swf&quot;, {<br />
                   clip: {<br />
                       autoPlay: false,<br />
                       autoBuffering: false,<br />
                       scaling: 'fit',<br />
                       url: 'http://localhost:3000/video',<br />
                       captionUrl: ''<br />
                       },<br />
                       plugins: {<br />
                   controls: {<br />
                       fullscreen: false,<br />
                       height: 30,<br />
                       autoHide: false<br />
                   }<br />
               }<br />
                   }<br />
               );<br />
               &lt;/script&gt;
  • Apostrophe issue with FFmpeg

    1er mars 2024, par Rohan Molinillo

    I'm working on a company's project which is vue.js.&#xA;There are also code parts in php.&#xA;It uses FFmpeg to create a video from multiple videos.&#xA;On each video, there is a text type subtitle.&#xA;Each text is retrieved from a .txt file&#xA;But I have a problem with apostrophes.

    &#xA;

    If in the subtitle is stored like this ( I'm here ) in the txt file, on the video there will be written ( Im ).&#xA;The apostrophe is removed and the rest of the text too ( here ) will not be displayed.

    &#xA;

    I'm new to php and ffmpeg, I've been on this problem for almost 3 weeks.

    &#xA;

    I share the php code with you.

    &#xA;

    &lt;?php&#xA;&#xA;declare(strict_types=1);&#xA;&#xA;array_shift($argv); // remove script name in $argv[0]&#xA;&#xA;$parameters = array_reduce($argv, function ($carry, $arg) {&#xA;    $tokens = explode(&#x27;=&#x27;, $arg);&#xA;    $carry[$tokens[0]] = $tokens[1];&#xA;    return $carry;&#xA;}, []);&#xA;&#xA;$projectPath = $parameters[&#x27;projectPath&#x27;];&#xA;$musicPath = $parameters[&#x27;musicPath&#x27;];&#xA;&#xA;$fontPath = getcwd() . "/public/fonts/cobol/Cobol-Bold.ttf";&#xA;$logoPath = getcwd() . "/public/images/saintex.jpg";&#xA;$carnetLogoPath = getcwd() . "/public/images/CarnetTitre.jpg";&#xA;&#xA;// Adding descriptions for each clip and fade in and fade out filters&#xA;$clipsToDescribe =  glob("$projectPath/*.webm");&#xA;$clipFrameRate = (int) shell_exec("cd $projectPath &amp;&amp; ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=r_frame_rate $clipsToDescribe[0]");&#xA;$clipFrameRate = $clipFrameRate > 60 ? 30 : $clipFrameRate;&#xA;&#xA;foreach ($clipsToDescribe as $key => $clipToDescribe) {&#xA;    $clipIndex = $key &#x2B; 1;&#xA;    $clipFrames = (int) shell_exec("cd $projectPath &amp;&amp; ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 $clipToDescribe");&#xA;    $clipDuration = (float) ($clipFrames / $clipFrameRate) - 0.5;&#xA;    file_put_contents("$projectPath/clip{$clipIndex}_desc.txt", addslashes($parameters["clip{$clipIndex}_desc"]));&#xA;    shell_exec("cd $projectPath &amp;&amp; ffmpeg -i $clipToDescribe -vf &#x27;drawtext=fontfile=$fontPath: textfile=clip{$clipIndex}_desc.txt: fontcolor=white: fontsize=46: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h-50): fix_bounds=true, fade=t=in:st=0:d=0.3,fade=t=out:st=$clipDuration:d=0.3&#x27; -b:v 3000K -b:a 192K clip{$clipIndex}.webm");&#xA;}&#xA;array_map(&#x27;unlink&#x27;, glob("$projectPath/*desc.txt"));&#xA;&#xA;shell_exec("cd $projectPath &amp;&amp; ffmpeg -t 2 -f lavfi -i color=c=black:s=1280x720 -r 30 blank.webm");&#xA;shell_exec("cd $projectPath &amp;&amp; ffmpeg -i blank.webm -i $carnetLogoPath -filter_complex &#x27;[0:v][1:v] overlay=(main_w/2)-(overlay_w/2):(main_h/2)-(overlay_h/2)&#x27; -pix_fmt yuv420p -c:a copy logo.webm");&#xA;&#xA;&#xA;&#xA;$workshop = $parameters["workshop_type"];&#xA;$title = $parameters["title"];&#xA;shell_exec("cd $projectPath &amp;&amp; ffmpeg -f lavfi -i color=size=1280x720:duration=3:rate=30:color=black -vf &#x27;drawtext=text=$workshop:fontfile=$fontPath:fontcolor=white:fontsize=46:x=(w-text_w)/2:y=(h-text_h)/2, drawtext=text=$title:fontfile=$fontPath:fontcolor=white:fontsize=46:x=(w-text_w)/2:y=((h-text_h)/2)&#x2B;lh&#x2B;5&#x27; opening.webm");&#xA;unlink("$projectPath/blank.webm");&#xA;&#xA;$videosFile = "file &#x27;logo.webm&#x27;\n";&#xA;$videosFile .= "file &#x27;opening.webm&#x27;\n";{&#xA;    file_put_contents("$projectPath/project_desc.txt", $parameters["project_desc"]);&#xA;    shell_exec("cd $projectPath &amp;&amp; ffmpeg -f lavfi -i color=size=1280x720:duration=3:rate=30:color=black -vf &#x27;drawtext=fontfile=$fontPath:fontsize=46:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:textfile=project_desc.txt&#x27; project_desc.webm");&#xA;    unlink("$projectPath/project_desc.txt");&#xA;    $videosFile .= "file &#x27;project_desc.webm&#x27;\n";&#xA;} &#xA;if(array_key_exists("participants", $parameters)) {&#xA;    file_put_contents("$projectPath/participants.txt", "Participants :\n" . $parameters["participants"]);&#xA;    shell_exec("cd $projectPath &amp;&amp; ffmpeg -f lavfi -i color=size=1280x720:duration=2:rate=30:color=black -vf &#x27;drawtext=fontfile=$fontPath:fontsize=46:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:textfile=participants.txt&#x27; participants.webm");&#xA;    unlink("$projectPath/participants.txt");&#xA;}&#xA;&#xA;$videos =  glob("$projectPath/clip*.webm");&#xA;foreach($videos as $video) {&#xA;    if($video != "originalVideos") {&#xA;        $videosFile .= "file ". "&#x27;{$video}&#x27;\n";&#xA;    }&#xA;} &#xA;if(array_key_exists("participants", $parameters)) {&#xA;    $videosFile .= "file &#x27;$projectPath/participants.webm&#x27;";&#xA;}&#xA;array_map(&#x27;unlink&#x27;, glob("$projectPath/*webm.txt"));&#xA;file_put_contents("$projectPath/videosFile.txt", $videosFile);&#xA;if($musicPath == "/_musics/") {&#xA;    echo(shell_exec("cd $projectPath &amp;&amp; ffmpeg -f concat -safe 0 -i videosFile.txt -b:v 10000K -crf 20 -b:a 192K output.webm"));&#xA;} else {&#xA;    echo(shell_exec("cd $projectPath &amp;&amp; ffmpeg -f concat -safe 0 -i videosFile.txt -b:v 10000K -crf 20 -b:a 192K assembled.webm &amp;&amp; ffmpeg -i assembled.webm -i ../..$musicPath -filter_complex &#x27; [1:0] apad &#x27; -shortest -y -b:v 3000K -b:a 192K output.webm"));&#xA;}&#xA;

    &#xA;

    I tried many things but each time there were errors.&#xA;I think I didn't implement the code properly.

    &#xA;

    I share you the error

    &#xA;

            [09:21:02] RECEIVED EVENT: videoRequest&#xA;{ Error: Command failed: php ./public/src/generate.php projectPath=&#x27;/home/rohan/Documents/dodoc2/_projects/its-a-test&#x27; musicPath=&#x27;/_musics/classic.mp3&#x27; clip1_name=&#x27;&#x27; clip2_name=&#x27;&#x27; clip3_name=&#x27;&#x27; clip4_name=&#x27;&#x27; clip5_name=&#x27;&#x27; clip1_desc=&#x27;It&#x27;s a first test&#x27; clip2_desc=&#x27;It&#x27;s a second test&#x27; clip3_desc=&#x27;It&#x27;s a third test&#x27; clip4_desc=&#x27;It&#x27;s a fourth&#x27; clip5_desc=&#x27;It&#x27;s a last test&#x27; project_desc=&#x27;&#x27; workshop_type=&#x27;Atelier Robotique&#x27; title=&#x27;It&#x27;s a test&#x27; participants=&#x27;Molinillo Rohan&#xA;&#x27;&#xA;PHP Warning:  Undefined array key 1 in /home/rohan/carnet-numerique/public/src/generate.php on line 9&#xA;PHP Warning:  Undefined array key 1 in /home/rohan/carnet-numerique/public/src/generate.php on line 9&#xA;PHP Warning:  Undefined array key 1 in /home/rohan/carnet-numerique/public/src/generate.php on line 9&#xA;PHP Warning:  Undefined array key 1 in /home/rohan/carnet-numerique/public/src/generate.php on line 9&#xA;PHP Warning:  Undefined array key 1 in /home/rohan/carnet-numerique/public/src/generate.php on line 9&#xA;PHP Warning:  Undefined array key 1 in /home/rohan/carnet-numerique/public/src/generate.php on line 9&#xA;ffmpeg version 5.1.1-1ubuntu2.1 Copyright (c) 2000-2022 the FFmpeg developers&#xA;  built with gcc 12 (Ubuntu 12.2.0-3ubuntu1)&#xA;  configuration: --prefix=/usr --extra-version=1ubuntu2.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --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-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-shared&#xA;  libavutil      57. 28.100 / 57. 28.100&#xA;  libavcodec     59. 37.100 / 59. 37.100&#xA;  libavformat    59. 27.100 / 59. 27.100&#xA;  libavdevice    59.  7.100 / 59.  7.100&#xA;  libavfilter     8. 44.100 /  8. 44.100&#xA;  libswscale      6.  7.100 /  6.  7.100&#xA;  libswresample   4.  7.100 /  4.  7.100&#xA;  libpostproc    56.  6.100 / 56.  6.100&#xA;Input #0, matroska,webm, from &#x27;/home/rohan/Documents/dodoc2/_projects/its-a-test/video-20230404-091933-682.webm&#x27;:&#xA;  Metadata:&#xA;    encoder         : QTmuxingAppLibWebM-0.0.1&#xA;  Duration: N/A, start: -0.001000, bitrate: N/A&#xA;  Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1280x720, SAR 1:1 DAR 16:9, 1k tbr, 1k tbn (default)&#xA;  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (vp8 (native) -> vp9 (libvpx-vp9))&#xA;  Stream #0:1 -> #0:1 (opus (native) -> opus (libopus))&#xA;Press [q] to stop, [?] for help&#xA;[libvpx-vp9 @ 0x55952c183000] v1.12.0&#xA;Output #0, webm, to &#x27;clip1.webm&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf59.27.100&#xA;  Stream #0:0(eng): Video: vp9, yuv420p(tv, bt470bg/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 3000 kb/s, 1k fps, 1k tbn (default)&#xA;    Metadata:&#xA;      encoder         : Lavc59.37.100 libvpx-vp9&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, flt, 192 kb/s (default)&#xA;    Metadata:&#xA;      encoder         : Lavc59.37.100 libopus&#xA;frame=  229 fps= 11 q=12.0 Lsize=    2786kB time=00:00:07.52 bitrate=3034.7kbits/s speed=0.377x    &#xA;video:2601kB audio:181kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.175036%&#xA;PHP Warning:  Undefined array key "clip2_desc" in /home/rohan/carnet-numerique/public/src/generate.php on line 29&#xA;PHP Fatal error:  Uncaught TypeError: addslashes(): Argument #1 ($string) must be of type string, null given in /home/rohan/carnet-numerique/public/src/generate.php:29&#xA;Stack trace:&#xA;#0 /home/rohan/carnet-numerique/public/src/generate.php(29): addslashes()&#xA;#1 {main}&#xA;  thrown in /home/rohan/carnet-numerique/public/src/generate.php on line 29&#xA;&#xA;    at ChildProcess.exithandler (child_process.js:275:12)&#xA;    at emitTwo (events.js:126:13)&#xA;    at ChildProcess.emit (events.js:214:7)&#xA;    at maybeClose (internal/child_process.js:925:16)&#xA;    at Socket.stream.socket.on (internal/child_process.js:346:11)&#xA;    at emitOne (events.js:116:13)&#xA;    at Socket.emit (events.js:211:7)&#xA;    at Pipe._handle.close [as _onclose] (net.js:554:12)&#xA;  killed: false,&#xA;  code: 255,&#xA;  signal: null,&#xA;  cmd: &#x27;php ./public/src/generate.php projectPath=\&#x27;/home/rohan/Documents/dodoc2/_projects/its-a-test\&#x27; musicPath=\&#x27;/_musics/classic.mp3\&#x27; clip1_name=\&#x27;\&#x27; clip2_name=\&#x27;\&#x27; clip3_name=\&#x27;\&#x27; clip4_name=\&#x27;\&#x27; clip5_name=\&#x27;\&#x27; clip1_desc=\&#x27;It\&#x27;s a first test\&#x27; clip2_desc=\&#x27;It\&#x27;s a second test\&#x27; clip3_desc=\&#x27;It\&#x27;s a third test\&#x27; clip4_desc=\&#x27;It\&#x27;s a fourth\&#x27; clip5_desc=\&#x27;It\&#x27;s a last test\&#x27; project_desc=\&#x27;\&#x27; workshop_type=\&#x27;Atelier Robotique\&#x27; title=\&#x27;It\&#x27;s a test\&#x27; participants=\&#x27;Molinillo Rohan\n\&#x27;&#x27; }&#xA;

    &#xA;

  • FFmpeg wrong output duration after av_seek_frame

    18 septembre 2022, par Gogogo

    I try to transcode a video and also cut it, but in the output file, I get the wrong duration for the file(video duration is correct). It happens when I seek the video, as an example, if I try cut from 60000 to 63000 ms I will get :&#xA;Format : WebM&#xA;Format version : Version 2&#xA;File size : 17.6 KiB&#xA;Duration : 1 min 4 s&#xA;Overall bit rate : 2 232 b/s&#xA;Writing application : Lavf59.31.100&#xA;Writing library : Lavf59.31.100

    &#xA;

    Video&#xA;ID : 1&#xA;Format : VP9&#xA;Codec ID : V_VP9&#xA;Duration : 2 s 961 ms&#xA;Width : 100 pixels&#xA;Height : 100 pixels&#xA;Display aspect ratio : 1.000&#xA;Frame rate mode : Constant&#xA;Frame rate : 24.000 FPS&#xA;Default : No&#xA;Forced : No

    &#xA;

    Here is my code, what I am doing wrong ?

    &#xA;

     namespace {&#xA;    &#xA;    constexpr auto maxDurationMs = 3000;&#xA;    constexpr auto maxFileSizeByte = 100000;&#xA;    &#xA;    struct StreamingParams {&#xA;      std::string output_extension;&#xA;      std::string muxer_opt_key;&#xA;      std::string muxer_opt_value;&#xA;      std::string video_codec;&#xA;      std::string codec_priv_key;&#xA;      std::string codec_priv_value;&#xA;    };&#xA;    &#xA;    struct StreamingContext {&#xA;      AVFormatContext* avfc = nullptr;&#xA;      AVCodec* video_avc = nullptr;&#xA;      AVStream* video_avs = nullptr;&#xA;      AVCodecContext* video_avcc = nullptr;&#xA;      int video_index = 0;&#xA;      std::string filename;&#xA;      ~StreamingContext() {}&#xA;    };&#xA;    &#xA;    struct StreamingContextDeleter {&#xA;      void operator()(StreamingContext* context) {&#xA;        if (context) {&#xA;          auto* avfc = &amp;context->avfc;&#xA;          auto* avcc = &amp;context->video_avcc;&#xA;          if (avfc)&#xA;            avformat_close_input(avfc);&#xA;          if (avcc)&#xA;            avcodec_free_context(avcc);&#xA;          if (context->avfc)&#xA;            avformat_free_context(context->avfc);&#xA;        }&#xA;      }&#xA;    };&#xA;    &#xA;    struct AVFrameDeleter {&#xA;      void operator()(AVFrame* frame) {&#xA;        if (frame)&#xA;          av_frame_free(&amp;frame);&#xA;      }&#xA;    };&#xA;    &#xA;    struct AVPacketDeleter {&#xA;      void operator()(AVPacket* packet) {&#xA;        if (packet)&#xA;          av_packet_free(&amp;packet);&#xA;      }&#xA;    };&#xA;    &#xA;    struct SwsContextDeleter {&#xA;      void operator()(SwsContext* context) {&#xA;        if (context)&#xA;          sws_freeContext(context);&#xA;      }&#xA;    };&#xA;    &#xA;    struct AVDictionaryDeleter {&#xA;      void operator()(AVDictionary* dictionary) {&#xA;        if (dictionary)&#xA;          av_dict_free(&amp;dictionary);&#xA;      }&#xA;    };&#xA;    &#xA;    int fill_stream_info(AVStream* avs, AVCodec** avc, AVCodecContext** avcc) {&#xA;      *avc = const_cast(avcodec_find_decoder(avs->codecpar->codec_id));&#xA;      if (!*avc) return -1;&#xA;&#xA;      *avcc = avcodec_alloc_context3(*avc);&#xA;      if (!*avcc)  return -1;&#xA;      if (avcodec_parameters_to_context(*avcc, avs->codecpar) &lt; 0) return -1;&#xA;      if (avcodec_open2(*avcc, *avc, nullptr) &lt; 0) return -1;&#xA;&#xA;      return 0;&#xA;    }&#xA;    &#xA;    int open_media(const char* in_filename, AVFormatContext** avfc) {&#xA;      *avfc = avformat_alloc_context();&#xA;      if (!*avfc) return -1;&#xA;      if (avformat_open_input(avfc, in_filename, nullptr, nullptr) != 0) return -1;&#xA;      if (avformat_find_stream_info(*avfc, nullptr) &lt; 0) return -1;&#xA;    &#xA;      return 0;&#xA;    }&#xA;    &#xA;    int prepare_decoder(std::shared_ptr<streamingcontext> sc) {&#xA;      for (int i = 0; i &lt; sc->avfc->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (sc->avfc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;          sc->video_avs = sc->avfc->streams[i];&#xA;          sc->video_index = i;&#xA;    &#xA;          if (fill_stream_info(sc->video_avs, &amp;sc->video_avc, &amp;sc->video_avcc)) return -1;&#xA;        }&#xA;      }&#xA;    &#xA;      return 0;&#xA;    }&#xA;    &#xA;    int prepare_video_encoder(std::shared_ptr<streamingcontext> sc,&#xA;                              AVCodecContext* decoder_ctx,&#xA;                              AVRational input_framerate,&#xA;                              const StreamingParams&amp; sp) {&#xA;      sc->video_avs = avformat_new_stream(sc->avfc, nullptr);&#xA;    &#xA;      sc->video_avc = const_cast(&#xA;          avcodec_find_encoder_by_name(sp.video_codec.c_str()));&#xA;      if (!sc->video_avc) return -1;&#xA;    &#xA;      sc->video_avcc = avcodec_alloc_context3(sc->video_avc);&#xA;      if (!sc->video_avcc) return -1;&#xA;    &#xA;      av_opt_set(sc->video_avcc->priv_data, "preset", "fast", 0);&#xA;&#xA;      sc->video_avcc->height = 100;&#xA;      sc->video_avcc->width = 100;&#xA;      sc->video_avcc->sample_aspect_ratio = decoder_ctx->sample_aspect_ratio;&#xA;      if (sc->video_avc->pix_fmts)&#xA;        sc->video_avcc->pix_fmt = sc->video_avc->pix_fmts[0];&#xA;      else&#xA;        sc->video_avcc->pix_fmt = decoder_ctx->pix_fmt;&#xA;    &#xA;      constexpr int64_t maxBitrate = maxFileSizeByte / (maxDurationMs / 1000.0) - 1;&#xA;    &#xA;      sc->video_avcc->bit_rate = maxBitrate;&#xA;      sc->video_avcc->rc_buffer_size = decoder_ctx->rc_buffer_size;&#xA;      sc->video_avcc->rc_max_rate = maxBitrate;&#xA;      sc->video_avcc->rc_min_rate = maxBitrate;&#xA;      sc->video_avcc->time_base = av_inv_q(input_framerate);&#xA;      sc->video_avs->time_base = sc->video_avcc->time_base;&#xA;    &#xA;      if (avcodec_open2(sc->video_avcc, sc->video_avc, nullptr) &lt; 0) return -1;&#xA;      avcodec_parameters_from_context(sc->video_avs->codecpar, sc->video_avcc);&#xA;    &#xA;      return 0;&#xA;    }&#xA;    &#xA;    int encode_video(std::shared_ptr<streamingcontext> decoder,&#xA;                     std::shared_ptr<streamingcontext> encoder,&#xA;                     AVFrame* input_frame) {&#xA;      if (input_frame)&#xA;        input_frame->pict_type = AV_PICTURE_TYPE_NONE;&#xA;    &#xA;      AVPacket* output_packet = av_packet_alloc();&#xA;      if (!output_packet) return -1;&#xA;    &#xA;      int response = avcodec_send_frame(encoder->video_avcc, input_frame);&#xA;    &#xA;      while (response >= 0) {&#xA;        response = avcodec_receive_packet(encoder->video_avcc, output_packet);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;          break;&#xA;        } else if (response &lt; 0) return -1;&#xA;    &#xA;        output_packet->stream_index = decoder->video_index;&#xA;        output_packet->duration = encoder->video_avs->time_base.den /&#xA;                                  encoder->video_avs->time_base.num /&#xA;                                  decoder->video_avs->avg_frame_rate.num *&#xA;                                  decoder->video_avs->avg_frame_rate.den;&#xA;    &#xA;        av_packet_rescale_ts(output_packet, decoder->video_avs->time_base,&#xA;                             encoder->video_avs->time_base);&#xA;    &#xA;        response = av_interleaved_write_frame(encoder->avfc, output_packet);&#xA;        if (response != 0) return -1;&#xA;      }&#xA;      av_packet_unref(output_packet);&#xA;      av_packet_free(&amp;output_packet);&#xA;      return 0;&#xA;    }&#xA;    &#xA;    int transcode_video(std::shared_ptr<streamingcontext> decoder,&#xA;                        std::shared_ptr<streamingcontext> encoder,&#xA;                        AVPacket* input_packet,&#xA;                        AVFrame* input_frame) {&#xA;      int response = avcodec_send_packet(decoder->video_avcc, input_packet);&#xA;      if (response &lt; 0) return response;&#xA;&#xA;    &#xA;      while (response >= 0) {&#xA;        response = avcodec_receive_frame(decoder->video_avcc, input_frame);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;          break;&#xA;        } else if (response &lt; 0) return response;&#xA;    &#xA;        if (response >= 0) {&#xA;          if (encode_video(decoder, encoder, input_frame)) return -1;&#xA;        }&#xA;        av_frame_unref(input_frame);&#xA;      }&#xA;    &#xA;      return 0;&#xA;    }&#xA;    &#xA;    }  // namespace&#xA;    &#xA;    &#xA;    int VideoToGifConverter::convert(VideoProp input, QString output) {&#xA;      StreamingParams sp;&#xA;      sp.output_extension = ".webm";&#xA;      sp.video_codec = "libvpx-vp9";&#xA;    &#xA;      auto inputStd = input.path.toStdString();&#xA;      auto outputStd =&#xA;          (output &#x2B; &#x27;/&#x27; &#x2B; QUuid::createUuid().toString(QUuid::StringFormat::Id128))&#xA;              .toStdString() &#x2B;&#xA;          sp.output_extension;&#xA;    &#xA;      auto decoder = std::shared_ptr<streamingcontext>(new StreamingContext,&#xA;                                                       StreamingContextDeleter{});&#xA;      auto encoder = std::shared_ptr<streamingcontext>(new StreamingContext,&#xA;                                                       StreamingContextDeleter{});&#xA;    &#xA;      encoder->filename = std::move(outputStd);&#xA;      decoder->filename = std::move(inputStd);&#xA;    &#xA;      if (open_media(decoder->filename.c_str(), &amp;decoder->avfc))&#xA;        return -1;&#xA;      if (prepare_decoder(decoder))&#xA;        return -1;&#xA;    &#xA;      avformat_alloc_output_context2(&amp;encoder->avfc, nullptr, nullptr,&#xA;                                     encoder->filename.c_str());&#xA;      if (!encoder->avfc) return -1;&#xA;    &#xA;      AVRational input_framerate =&#xA;          av_guess_frame_rate(decoder->avfc, decoder->video_avs, nullptr);&#xA;      prepare_video_encoder(encoder, decoder->video_avcc, input_framerate, sp);&#xA;    &#xA;      if (encoder->avfc->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;        encoder->avfc->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;      if (!(encoder->avfc->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        if (avio_open(&amp;encoder->avfc->pb, encoder->filename.c_str(),&#xA;                      AVIO_FLAG_WRITE) &lt; 0) return -1;&#xA;      }&#xA;    &#xA;      AVDictionary* muxer_opts = nullptr;&#xA;    &#xA;      if (!sp.muxer_opt_key.empty() &amp;&amp; !sp.muxer_opt_value.empty()) {&#xA;        av_dict_set(&amp;muxer_opts, sp.muxer_opt_key.c_str(),&#xA;                    sp.muxer_opt_value.c_str(), 0);&#xA;      }&#xA;    &#xA;      if (avformat_write_header(encoder->avfc, &amp;muxer_opts) &lt; 0) return -1;&#xA;    &#xA;      auto inputFrame = std::unique_ptr(av_frame_alloc());&#xA;      if (!inputFrame) return -1;&#xA;    &#xA;      auto inputPacket =&#xA;          std::unique_ptr(av_packet_alloc());&#xA;      if (!inputPacket) return -1;&#xA;    &#xA;      auto** streams = decoder->avfc->streams;&#xA;    &#xA;      const auto fps = static_cast<double>(&#xA;                           streams[inputPacket->stream_index]->avg_frame_rate.num) /&#xA;                       streams[inputPacket->stream_index]->avg_frame_rate.den;&#xA;      const size_t beginFrame = input.beginPosMs * fps / 1000;&#xA;      const size_t endFrame = input.endPosMs * fps / 1000;&#xA;      const auto totalFrames = endFrame - beginFrame;&#xA;    &#xA;      size_t count = 0;&#xA;    &#xA;      int64_t startTime =&#xA;          av_rescale_q(input.beginPosMs * AV_TIME_BASE / 1000, {1, AV_TIME_BASE},&#xA;                       decoder->video_avs->time_base);&#xA;    &#xA;      av_seek_frame(decoder->avfc, inputPacket->stream_index, startTime, 0);&#xA;      avcodec_flush_buffers(decoder->video_avcc);&#xA;    &#xA;      while (count &lt; totalFrames &amp;&amp;&#xA;             av_read_frame(decoder->avfc, inputPacket.get()) >= 0) {&#xA;        if (streams[inputPacket->stream_index]->codecpar->codec_type ==&#xA;            AVMEDIA_TYPE_VIDEO) {&#xA;          if (transcode_video(decoder, encoder, inputPacket.get(), inputFrame.get())) {&#xA;            return -1;&#xA;          }&#xA;          &#x2B;&#x2B;count;&#xA;        }&#xA;        av_packet_unref(inputPacket.get());&#xA;      }&#xA;    &#xA;      if (encode_video(decoder, encoder, nullptr, nullptr)) return -1;&#xA;        &#xA;      av_write_trailer(encoder->avfc);&#xA;    &#xA;      return 0;&#xA;    }&#xA;</double></streamingcontext></streamingcontext></streamingcontext></streamingcontext></streamingcontext></streamingcontext></streamingcontext></streamingcontext>

    &#xA;