Recherche avancée

Médias (1)

Mot : - Tags -/illustrator

Autres articles (67)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (9236)

  • Video streamign with FFMpeg and Nest.js+Next.js

    17 septembre 2024, par Aizen

    Here is my problem : I have one video src 1080p (on the frontend). On the frontend, I send this video-route to the backend :

    


    const req = async()=>{try{const res = await axios.get('/catalog/item',{params:{SeriesName:seriesName}});return {data:res.data};}catch(err){console.log(err);return false;}}const fetchedData = await req();-On the backend i return seriesName.Now i can make a full path,what the video is,and where it is,code:


    


    const videoUrl = 'C:/Users/arMori/Desktop/RedditClone/reddit/public/videos';console.log('IT VideoURL',videoUrl);


    


    const selectedFile = `${videoUrl}/${fetchedData.data.VideoSource}/${seriesName}-1080p.mp4`
console.log(`ITS'S SELECTED FILE: ${selectedFile}`);


    


    Ok, I have my src 1080p, now is the time to send it to the backend :

    


    const response = await axios.post('/videoFormat', {videoUrl:selectedFile})console.log('Это консоль лог путей: ',response.data);const videoPaths = response.data;


    


    Backend takes it and FFMpqg makes two types of resolution,720p and 480p,save it to the temp storage on backend, and then returns two routes where these videos stores

    


    async videoUpload(videoUrl:string){try{const tempDir = C:/Users/arMori/Desktop/RedditClone/reddit_back/src/video/temp;const inputFile = videoUrl;console.log('VIDEOURL: ',videoUrl);


    


            const outputFiles = [];&#xA;        &#xA;        await this.createDirectories(tempDir);        &#xA;        outputFiles.push(await this.convertVideo(inputFile, &#x27;1280x720&#x27;, &#x27;720p.mp4&#x27;));&#xA;        outputFiles.push(await this.convertVideo(inputFile, &#x27;854x480&#x27;, &#x27;480p.mp4&#x27;));&#xA;        console.log(&#x27;OUTUPT FILES SERVICE: &#x27;,outputFiles);&#xA;        &#xA;        return outputFiles;&#xA;&#xA;    }catch(err){&#xA;        console.error(&#x27;VideoFormatterService Error: &#x27;,err);&#xA;        &#xA;    }&#xA;}&#xA;&#xA;private convertVideo(inputPath:string,resolution:string,outputFileName:string):Promise<string>{&#xA;    const temp = `C:/Users/arMori/Desktop/RedditClone/reddit_back/src/video/temp`;&#xA;    return new Promise(async(resolve,reject)=>{&#xA;        const height = resolution.split(&#x27;x&#x27;)[1];&#xA;        console.log(&#x27;HIEGHT: &#x27;,height);&#xA;        &#xA;        const outputDir = `C:/Users/arMori/Desktop/RedditClone/reddit_back/src/video/temp/${height}p`;&#xA;        const outputPath = join(outputDir, outputFileName);&#xA;        const isExists = await fs.access(outputPath).then(() => true).catch(() => false);&#xA;        if(isExists){ &#xA;            console.log(`File already exists: ${outputPath}`);&#xA;            return resolve(outputPath)&#xA;        };&#xA;        ffmpeg(inputPath)&#xA;        .size(`${resolution}`)&#xA;        .videoCodec(&#x27;libx264&#x27;) // Кодек H.264&#xA;        .audioCodec(&#x27;aac&#x27;) &#xA;        .output(outputPath)&#xA;        .on(&#x27;end&#x27;,()=>resolve(outputPath))&#xA;        .on(&#x27;error&#x27;,(err)=>reject(err))&#xA;        .run()&#xA;            &#xA;    })&#xA;}&#xA;&#xA;private async createDirectories(temp:string){&#xA;    try{&#xA;        const dir720p = `${temp}/720p`;&#xA;        const dir480p = `${temp}/480p`;&#xA;        const dir720pExists = await fs.access(dir720p).then(() => true).catch(() => false);&#xA;        const dir480pExists = await fs.access(dir480p).then(() => true).catch(() => false);&#xA;        if(dir720pExists &amp;&amp; dir480pExists){&#xA;            console.log(&#x27;FILES ALIVE&#x27;);&#xA;            return;&#xA;        }&#xA;        if (!dir720pExists) {&#xA;            await fs.mkdir(dir720p, { recursive: true });&#xA;            console.log(&#x27;Папка 720p создана&#x27;);&#xA;        }&#xA;        &#xA;        if (!dir480pExists) {&#xA;            await fs.mkdir(dir480p, { recursive: true });&#xA;            console.log(&#x27;Папка 480p создана&#x27;);&#xA;        }&#xA;    } catch (err) {&#xA;        console.error(&#x27;Ошибка при создании директорий:&#x27;, err);&#xA;    }&#xA;}&#xA;</string>

    &#xA;

    Continue frontentd code :

    &#xA;

    let videoPath;&#xA;&#xA;if (quality === &#x27;720p&#x27;) {&#xA;        videoPath = videoPaths[0];&#xA;} else if (quality === &#x27;480p&#x27;) {&#xA;        videoPath = videoPaths[1];&#xA;}&#xA;&#xA;if (!videoPath) {&#xA;        console.error(&#x27;Video path not found!&#x27;);&#xA;        return;&#xA;}&#xA;&#xA;// Получаем видео по его пути&#xA;console.log(&#x27;VIDEOPATH LOG: &#x27;,videoPath);&#xA;    &#xA;const videoRes = await axios.get(&#x27;/videoFormat/getVideo&#x27;, { &#xA;        params: { path: videoPath } ,&#xA;        headers: { Range: &#x27;bytes=0-&#x27; },&#xA;        responseType: &#x27;blob&#x27;&#xA;    });&#xA;    console.log(&#x27;Video fetched: &#x27;, videoRes);&#xA;    const videoBlob = new Blob([videoRes.data], { type: &#x27;video/mp4&#x27; });&#xA;    const videoURL = URL.createObjectURL(videoBlob);&#xA;    return videoURL;&#xA;    /* console.log(&#x27;Видео успешно загружено:&#x27;, response.data); */&#xA;    } catch (error) {&#xA;    console.error(&#x27;Ошибка при загрузке видео:&#x27;, error);&#xA;    }&#xA;}&#xA;

    &#xA;

    Here I just choose one of the route and make a new GET request (VideoRes), now in the controller in the backend, I'm trying to do a video streaming :

    &#xA;

    @Public()&#xA;    @Get(&#x27;/getVideo&#x27;)&#xA;    async getVideo(@Query(&#x27;path&#x27;) videoPath:string,@Req() req:Request,@Res() res:Response){&#xA;        try {&#xA;            console.log(&#x27;PATH ARGUMENT: &#x27;,videoPath);&#xA;            console.log(&#x27;VIDEOPATH IN SERVICE: &#x27;,videoPath);&#xA;        const videoSize = (await fs.stat(videoPath)).size;&#xA;        const CHUNK_SIZE = 10 ** 6;&#xA;        const range = req.headers[&#x27;range&#x27;] as string | undefined;&#xA;        if (!range) {&#xA;            return new ForbiddenException(&#x27;Range не найденно&#x27;);&#xA;        }&#xA;        const start = Number(range.replace(/\D/g,""));&#xA;        const end = Math.min(start &#x2B; CHUNK_SIZE,videoSize - 1);&#xA;&#xA;        const contentLength = end - start &#x2B; 1;&#xA;        const videoStream = fsSync.createReadStream(videoPath, { start, end });&#xA;        const headers = {&#xA;            &#x27;Content-Range&#x27;:`bytes ${start}-${end}/${videoSize}`,&#xA;            &#x27;Accept-Ranges&#x27;:&#x27;bytes&#x27;,&#xA;            &#x27;Content-Length&#x27;:contentLength,&#xA;            &#x27;Content-Type&#x27;:&#x27;video/mp4&#x27;&#xA;        }&#xA;        &#xA;        res.writeHead(206,headers);&#xA;&#xA;        // Передаем поток в ответ&#xA;        videoStream.pipe(res);&#xA;        &#xA;&#xA;        // Если возникнет ошибка при стриминге, логируем ошибку&#xA;        videoStream.on(&#x27;error&#x27;, (error) => {&#xA;            console.error(&#x27;Ошибка при чтении видео:&#x27;, error);&#xA;            res.status(500).send(&#x27;Ошибка при чтении видео&#x27;);&#xA;        });&#xA;        } catch (error) {&#xA;            console.error(&#x27;Ошибка при обработке запросов:&#x27;, error);&#xA;            return res.status(400).json({ message: &#x27;Ошибка при обработке getVideo запросов&#x27; });&#xA;        }&#xA;    }&#xA;

    &#xA;

    Send to the frontend

    &#xA;

    res.writeHead(206,headers);&#xA;

    &#xA;

    In the frontend, I make blob url for video src and return it

    &#xA;

    const videoBlob = new Blob([videoRes.data], { type: &#x27;video/mp4&#x27; });const videoURL = URL.createObjectURL(videoBlob);return videoURL;&#xA;

    &#xA;

    And assign src to the video :

    &#xA;

    useVideo(seriesName,quality).then(src => {&#xA;                if (src) {&#xA;                    console.log(&#x27;ITS VIDEOLOGISC GOIDA!&#x27;);&#xA;                    if(!playRef.current) return;&#xA;                    &#xA;                    const oldURL = playRef.current.src;&#xA;                    if (oldURL &amp;&amp; oldURL.startsWith(&#x27;blob:&#x27;)) {&#xA;                        URL.revokeObjectURL(oldURL);&#xA;                    }&#xA;                    playRef.current.pause();&#xA;                    playRef.current.src = &#x27;&#x27;;&#xA;                    setQuality(quality);&#xA;                    console.log(&#x27;SRC: &#x27;,src);&#xA;                    &#xA;                    playRef.current.src = src;&#xA;                    playRef.current.load();&#xA;                    console.log(&#x27;ITS VIDEOURL GOIDA!&#x27;);&#xA;                    togglePlayPause();&#xA;                }&#xA;            })&#xA;            .catch(err => console.error(&#x27;Failed to fetch video&#x27;, err));&#xA;

    &#xA;

    But the problem is :

    &#xA;

    &#xA;

    Vinland-Saga:1 Uncaught (in promise) NotSupportedError : Failed to load because no supported source was found

    &#xA;

    &#xA;

    And I don't know why...

    &#xA;

    I tried everything, but I don't understand why src is incorrect..

    &#xA;

  • How to get the correct result file data if I use Web Worker on ffmpeg.js ?

    23 avril 2019, par SuperBerry

    I have tried to use FFMPEG.js (https://github.com/Kagami/ffmpeg.js) to convert mp3 files on the browser/client side, and I followed the usage of the page of Web Worker. However, the worker works well on the converting and it seems the file has been converted, but I cannot get the correct result file data back.

    Here my code is :

    <code class="echappe-js">&lt;script&gt;<br />
    <br />
    var stdout = &quot;&quot;;<br />
    var outputhtml=&quot;&quot;;<br />
    var stderr = &quot;&quot;;<br />
    var outputfile;<br />
    <br />
    var sampleVideoData;<br />
    <br />
    function retrieveSampleVideo() {<br />
     var oReq = new XMLHttpRequest();<br />
     oReq.open(&quot;GET&quot;, &quot;short.mp3&quot;, true);<br />
     oReq.responseType = &quot;arraybuffer&quot;;<br />
    <br />
     oReq.onload = function (oEvent) {<br />
       var arrayBuffer = oReq.response;<br />
       if (arrayBuffer) {<br />
         sampleVideoData = new Uint8Array(arrayBuffer);<br />
       }<br />
     };<br />
    <br />
     oReq.send(null);<br />
    }<br />
    <br />
    function getDownloadLink(fileData, fileName) {<br />
     var a = document.createElement('a');<br />
     a.download = fileName;<br />
     var blob = new Blob([fileData]);<br />
     var src = window.URL.createObjectURL(blob);<br />
     a.href = src;<br />
     a.textContent = 'Click here to download ' + fileName + &quot;!&quot;;<br />
     document.body.appendChild(a);<br />
    }<br />
    <br />
    var worker = new Worker(&quot;ffmpeg-worker-mp4.js&quot;);<br />
    <br />
    retrieveSampleVideo();<br />
    <br />
    var memfs =[];  <br />
    <br />
    //[, {name: &quot;input.mp3&quot;, data: output}];<br />
    <br />
    worker.onmessage = function(e) {<br />
     var msg = e.data;<br />
    <br />
     switch (msg.type) {<br />
     case &quot;ready&quot;:<br />
       console.log(&quot;ready: &quot; + msg.data);<br />
       alert(sampleVideoData.length);<br />
       memfs.push({name: &quot;input.mp3&quot;, data: sampleVideoData});<br />
       memfs.push({name: &quot;output.mp3&quot;, data: outputfile});<br />
    <br />
       worker.postMessage({type: &quot;run&quot;, MEMFS: memfs, arguments: [&quot;-i&quot;, &quot;input.mp3&quot;, &quot;-y&quot;, &quot;output.mp3&quot;]});<br />
    <br />
    <br />
       break;<br />
     case &quot;stdout&quot;:<br />
       console.log(&quot;stdout: &quot; + msg.data);<br />
       stdout += msg.data + &quot;\n&quot;;<br />
       outputhtml+=msg.data + &quot;&lt;br&gt;&quot;;<br />
    <br />
       break;<br />
     case &quot;stderr&quot;:<br />
       console.log(&quot;stderr: &quot; + msg.data);<br />
       stderr += msg.data + &quot;\n&quot;;<br />
       outputhtml+=msg.data + &quot;&lt;br&gt;&quot;;<br />
    <br />
       break;<br />
    <br />
     case &quot;exit&quot;:<br />
    <br />
       console.log(&quot;Process exited with code &quot; + msg.data);<br />
       console.log(stdout);<br />
       document.write(outputhtml);<br />
    <br />
       getDownloadLink(outputfile, &quot;output.mp3&quot;);<br />
       worker.terminate();<br />
    <br />
    <br />
       break;<br />
     }<br />
    };<br />
    <br />
       &lt;/script&gt;

    And the console output looks good :

    stderr: ffmpeg version n3.1.2 Copyright (c) 2000-2016 the FFmpeg developers index.html:66:4
    stderr:   built with emcc (Emscripten gcc/clang-like replacement) 1.36.7 () index.html:66:4
    stderr:   configuration: --cc=emcc --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avutil --enable-swresample --enable-swscale --enable-avfilter --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vda --disable-vdpau --enable-decoder=vp8 --enable-decoder=vp9 --enable-decoder=theora --enable-decoder=mpeg2video --enable-decoder=mpeg4 --enable-decoder=h264 --enable-decoder=hevc --enable-decoder=png --enable-decoder=mjpeg --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=ac3 --enable-decoder=aac --enable-decoder=ass --enable-decoder=ssa --enable-decoder=srt --enable-decoder=webvtt --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=avi --enable-demuxer=mov --enable-demuxer=flv --enable-demuxer=mpegps --enable-demuxer=image2 --enable-demuxer=mp3 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl --disable-securetransport --disable-xlib --disable-zlib --enable-encoder=libx264 --enable-encoder=libmp3lame --enable-encoder=aac --enable-muxer=mp4 --enable-muxer=mp3 --enable-muxer=null --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags=-I../lame/dist/include --extra-ldflags=-L../lame/dist/lib index.html:66:4
    stderr:   libavutil      55. 28.100 / 55. 28.100 index.html:66:4
    stderr:   libavcodec     57. 48.101 / 57. 48.101 index.html:66:4
    stderr:   libavformat    57. 41.100 / 57. 41.100 index.html:66:4
    stderr:   libavfilter     6. 47.100 /  6. 47.100 index.html:66:4
    stderr:   libswscale      4.  1.100 /  4.  1.100 index.html:66:4
    stderr:   libswresample   2.  1.100 /  2.  1.100 index.html:66:4
    stderr: [mp3 @ 0x812380] Warning: not compiled with thread support, using thread emulation index.html:66:4
    stderr: Input #0, mp3, from 'input.mp3': index.html:66:4
    stderr:   Metadata: index.html:66:4
    stderr:     encoder         : Lavf57.66.101 index.html:66:4
    stderr:   Duration: 00:00:03.02, start: 0.023021, bitrate: 128 kb/s index.html:66:4
    stderr:     Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s index.html:66:4
    stderr:     Metadata: index.html:66:4
    stderr:       encoder         : Lavc57.75 index.html:66:4
    stderr: [mp3 @ 0x8240f0] Warning: not compiled with thread support, using thread emulation index.html:66:4
    stderr: [libmp3lame @ 0x81b8a0] Warning: not compiled with thread support, using thread emulation index.html:66:4
    stderr: [mp3 @ 0x80b0f0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. index.html:66:4
    stderr: Output #0, mp3, to 'output.mp3': index.html:66:4
    stderr:   Metadata: index.html:66:4
    stderr:     TSSE            : Lavf57.41.100 index.html:66:4
    stderr:     Stream #0:0: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s16p index.html:66:4
    stderr:     Metadata: index.html:66:4
    stderr:       encoder         : Lavc57.48.101 libmp3lame index.html:66:4
    stderr: Stream mapping: index.html:66:4
    stderr:   Stream #0:0 -> #0:0 (mp3 (native) -> mp3 (libmp3lame)) index.html:66:4
    stderr: Press [q] to stop, [?] for help index.html:66:4
    stderr: size=      47kB time=00:00:03.00 bitrate= 129.6kbits/s speed=10.9x    index.html:66:4
    stderr: video:0kB audio:47kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.489831% index.html:66:4
    Process exited with code 0

    I have set the output into the memfs in the code :

    memfs.push(name : "output.mp3", data : outputfile) ;

    But I cannot get the result file data in outputfile to create the blob downloadd link.

  • Assertion desc failed at src/libswscale/swscale_internal.h:764

    18 avril 2022, par harsh bhatnagar

    I am trying to implement the ffmpeg code written in C++ language .

    &#xA;

    Tutorial link : https://www.youtube.com/watch?v=W6Yx3injNZs

    &#xA;

    Github Reference : https://github.com/bartjoyce/video-app/tree/master/src

    &#xA;

    When pass the filename or Rtsp Link in the avformat_open_input funcion. It shows the strange bug not able understand the issue in the C++ code or camera setting issue .

    &#xA;

    // av_err2str returns a temporary array. This doesn&#x27;t work in gcc.&#xA;// This function can be used as a replacement for av_err2str.&#xA;#include "video_reader.hpp"&#xA;static const char* av_make_error(int errnum) {&#xA;    static char str[AV_ERROR_MAX_STRING_SIZE];&#xA;    memset(str, 0, sizeof(str));&#xA;    return av_make_error_string(str, AV_ERROR_MAX_STRING_SIZE, errnum);&#xA;}&#xA;&#xA;static AVPixelFormat correct_for_deprecated_pixel_format(AVPixelFormat pix_fmt) {&#xA;    // Fix swscaler deprecated pixel format warning&#xA;    // (YUVJ has been deprecated, change pixel format to regular YUV)&#xA;    switch (pix_fmt) {&#xA;        case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P;&#xA;        case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P;&#xA;        case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P;&#xA;        case AV_PIX_FMT_YUVJ440P: return AV_PIX_FMT_YUV440P;&#xA;        default:                  return pix_fmt;&#xA;    }&#xA;}&#xA;&#xA;bool video_reader_open(VideoReaderState* state, const char* filename) {&#xA;&#xA;    // Unpack members of state&#xA;    auto&amp; width = state->width;&#xA;    auto&amp; height = state->height;&#xA;    auto&amp; time_base = state->time_base;&#xA;    auto&amp; av_format_ctx = state->av_format_ctx;&#xA;    auto&amp; av_codec_ctx = state->av_codec_ctx;&#xA;    auto&amp; video_stream_index = state->video_stream_index;&#xA;    auto&amp; av_frame = state->av_frame;&#xA;    auto&amp; av_packet = state->av_packet;&#xA;&#xA;    // Open the file using libavformat&#xA;    av_format_ctx = avformat_alloc_context();&#xA;    if (!av_format_ctx) {&#xA;        printf("Couldn&#x27;t created AVFormatContext\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    if (avformat_open_input(&amp;av_format_ctx, filename, NULL, NULL) != 0) {&#xA;        printf("Couldn&#x27;t open video file\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    // Find the first valid video stream inside the file&#xA;    video_stream_index = -1;&#xA;    AVCodecParameters* av_codec_params;&#xA;    AVCodec* av_codec;&#xA;    for (int i = 0; i &lt; av_format_ctx->nb_streams; &#x2B;&#x2B;i) {&#xA;        av_codec_params = av_format_ctx->streams[i]->codecpar;&#xA;        av_codec = avcodec_find_decoder(av_codec_params->codec_id);&#xA;        if (!av_codec) {&#xA;            continue;&#xA;        }&#xA;        if (av_codec_params->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            video_stream_index = i;&#xA;            width = av_codec_params->width;&#xA;            height = av_codec_params->height;&#xA;            time_base = av_format_ctx->streams[i]->time_base;&#xA;            break;&#xA;        }&#xA;    }&#xA;    if (video_stream_index == -1) {&#xA;        printf("Couldn&#x27;t find valid video stream inside file\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    // Set up a codec context for the decoder&#xA;    av_codec_ctx = avcodec_alloc_context3(av_codec);&#xA;    if (!av_codec_ctx) {&#xA;        printf("Couldn&#x27;t create AVCodecContext\n");&#xA;        return false;&#xA;    }&#xA;    if (avcodec_parameters_to_context(av_codec_ctx, av_codec_params) &lt; 0) {&#xA;        printf("Couldn&#x27;t initialize AVCodecContext\n");&#xA;        return false;&#xA;    }&#xA;    if (avcodec_open2(av_codec_ctx, av_codec, NULL) &lt; 0) {&#xA;        printf("Couldn&#x27;t open codec\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    av_frame = av_frame_alloc();&#xA;    if (!av_frame) {&#xA;        printf("Couldn&#x27;t allocate AVFrame\n");&#xA;        return false;&#xA;    }&#xA;    av_packet = av_packet_alloc();&#xA;    if (!av_packet) {&#xA;        printf("Couldn&#x27;t allocate AVPacket\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;bool video_reader_read_frame(VideoReaderState* state, uint8_t* frame_buffer, int64_t* pts) {&#xA;&#xA;    // Unpack members of state&#xA;    auto&amp; width = state->width;&#xA;    auto&amp; height = state->height;&#xA;    auto&amp; av_format_ctx = state->av_format_ctx;&#xA;    auto&amp; av_codec_ctx = state->av_codec_ctx;&#xA;    auto&amp; video_stream_index = state->video_stream_index;&#xA;    auto&amp; av_frame = state->av_frame;&#xA;    auto&amp; av_packet = state->av_packet;&#xA;    auto&amp; sws_scaler_ctx = state->sws_scaler_ctx;&#xA;&#xA;    // Decode one frame&#xA;    int response;&#xA;    while (av_read_frame(av_format_ctx, av_packet) >= 0) {&#xA;        if (av_packet->stream_index != video_stream_index) {&#xA;            av_packet_unref(av_packet);&#xA;            continue;&#xA;        }&#xA;&#xA;        response = avcodec_send_packet(av_codec_ctx, av_packet);&#xA;        if (response &lt; 0) {&#xA;            printf("Failed to decode packet: %s\n", av_make_error(response));&#xA;            return false;&#xA;        }&#xA;&#xA;        response = avcodec_receive_frame(av_codec_ctx, av_frame);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;            av_packet_unref(av_packet);&#xA;            continue;&#xA;        } else if (response &lt; 0) {&#xA;            printf("Failed to decode packet: %s\n", av_make_error(response));&#xA;            return false;&#xA;        }&#xA;&#xA;        av_packet_unref(av_packet);&#xA;        break;&#xA;    }&#xA;&#xA;    *pts = av_frame->pts;&#xA;    &#xA;    // Set up sws scaler&#xA;    if (!sws_scaler_ctx) {&#xA;        auto source_pix_fmt = correct_for_deprecated_pixel_format(av_codec_ctx->pix_fmt);&#xA;        sws_scaler_ctx = sws_getContext(width, height, source_pix_fmt,&#xA;                                        width, height, AV_PIX_FMT_RGB0,&#xA;                                        SWS_BILINEAR, NULL, NULL, NULL);&#xA;    }&#xA;    if (!sws_scaler_ctx) {&#xA;        printf("Couldn&#x27;t initialize sw scaler\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    uint8_t* dest[4] = { frame_buffer, NULL, NULL, NULL };&#xA;    int dest_linesize[4] = { width * 4, 0, 0, 0 };&#xA;    sws_scale(sws_scaler_ctx, av_frame->data, av_frame->linesize, 0, av_frame->height, dest, dest_linesize);&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;bool video_reader_seek_frame(VideoReaderState* state, int64_t ts) {&#xA;    &#xA;    // Unpack members of state&#xA;    auto&amp; av_format_ctx = state->av_format_ctx;&#xA;    auto&amp; av_codec_ctx = state->av_codec_ctx;&#xA;    auto&amp; video_stream_index = state->video_stream_index;&#xA;    auto&amp; av_packet = state->av_packet;&#xA;    auto&amp; av_frame = state->av_frame;&#xA;    &#xA;    av_seek_frame(av_format_ctx, video_stream_index, ts, AVSEEK_FLAG_BACKWARD);&#xA;&#xA;    // av_seek_frame takes effect after one frame, so I&#x27;m decoding one here&#xA;    // so that the next call to video_reader_read_frame() will give the correct&#xA;    // frame&#xA;    int response;&#xA;    while (av_read_frame(av_format_ctx, av_packet) >= 0) {&#xA;        if (av_packet->stream_index != video_stream_index) {&#xA;            av_packet_unref(av_packet);&#xA;            continue;&#xA;        }&#xA;&#xA;        response = avcodec_send_packet(av_codec_ctx, av_packet);&#xA;        if (response &lt; 0) {&#xA;            printf("Failed to decode packet: %s\n", av_make_error(response));&#xA;            return false;&#xA;        }&#xA;&#xA;        response = avcodec_receive_frame(av_codec_ctx, av_frame);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;            av_packet_unref(av_packet);&#xA;            continue;&#xA;        } else if (response &lt; 0) {&#xA;            printf("Failed to decode packet: %s\n", av_make_error(response));&#xA;            return false;&#xA;        }&#xA;&#xA;        av_packet_unref(av_packet);&#xA;        break;&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;void video_reader_close(VideoReaderState* state) {&#xA;    sws_freeContext(state->sws_scaler_ctx);&#xA;    avformat_close_input(&amp;state->av_format_ctx);&#xA;    avformat_free_context(state->av_format_ctx);&#xA;    av_frame_free(&amp;state->av_frame);&#xA;    av_packet_free(&amp;state->av_packet);&#xA;    avcodec_free_context(&amp;state->av_codec_ctx);&#xA;}&#xA;

    &#xA;

    Bug :

    &#xA;

    [rtsp @ 0x55def0b00ac0] getaddrinfo(): Name or service not known&#xA;[rtsp @ 0x55def0b00ac0] max delay reached. need to consume packet&#xA;[rtsp @ 0x55def0b00ac0] RTP: missed 10 packets&#xA;Assertion desc failed at src/libswscale/swscale_internal.h:764&#xA;Aborted (core dumped)&#xA;

    &#xA;