Recherche avancée

Médias (0)

Mot : - Tags -/serveur

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

Autres articles (38)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

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

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

Sur d’autres sites (4896)

  • How can you combine multiple video files with FFMPEG and merging the audio track as well

    19 décembre 2023, par Codrut

    I'm trying to combine multiple MP4 files in Delphi with the FFMPEG video library. I have the headers unit with all the functions. All videos are MPEG-4, and so is the destination output file.

    


    I found this question on Stack Overflow asking the same question. To combine video files while keeping the audio and video tracks.
I have translated the answers to Delphi, and while the code is executed successfully, the output file is invalid and cannot be played.

    


    Here is my implementation :

    


    var&#xA;  Files: TArray<pansichar>;&#xA;  Output: PAnsiChar;&#xA;&#xA;  I, S: integer;&#xA;&#xA;  i_fmt_ctx: PAVFormatContext;&#xA;  i_video_stream: PAVStream;&#xA;  o_fmt_ctx: PAVFormatContext;&#xA;  o_video_stream: PAVStream;&#xA;&#xA;  P: PPAVStream;&#xA;begin&#xA;  SetLength(Files, 2);&#xA;  Files[0] := PAnsiChar(&#x27;.\Clips\file9.mp4&#x27;);&#xA;  Files[1] := PAnsiChar(&#x27;.\Clips\file10.mp4&#x27;);&#xA;  Output := &#x27;.\Output\out.mp4&#x27;;&#xA;&#xA;  avcodec_register_all();   &#xA;  av_register_all();&#xA;&#xA;  (* should set to NULL so that avformat_open_input() allocate a new one *)&#xA;  i_fmt_ctx := nil;&#xA;&#xA;  if avformat_open_input(@i_fmt_ctx, Files[0], nil, nil) &lt;> 0 then&#xA;    raise Exception.Create(&#x27;Could not open file&#x27;);&#xA;&#xA;  if avformat_find_stream_info(i_fmt_ctx, nil) &lt; 0 then&#xA;    raise Exception.Create(&#x27;Could not find stream info&#x27;);&#xA;                &#xA;  (* Find 1st video stream *)&#xA;  i_video_stream := nil;&#xA;  P := i_fmt_ctx.streams;&#xA;  for i := 0 to i_fmt_ctx.nb_streams-1 do begin&#xA;    if P^.codec.codec_type = AVMEDIA_TYPE_VIDEO then&#xA;      begin&#xA;        i_video_stream := P^;&#xA;        Break;&#xA;      end;&#xA;    Inc(P);&#xA;  end;&#xA;  if i_video_stream = nil then&#xA;    raise Exception.Create(&#x27;Could not find video stream&#x27;);&#xA;&#xA;  avformat_alloc_output_context2(@o_fmt_ctx, nil, nil, Output);&#xA;&#xA;  (*&#xA;  since all input files are supposed to be identical (framerate, dimension, color format, ...)&#xA;  we can safely set output codec values from first input file&#xA;  *)&#xA;  o_video_stream := avformat_new_stream(o_fmt_ctx, nil);&#xA;  &#xA;  var c: PAVCodecContext;&#xA;  c := o_video_stream.codec;&#xA;  c.bit_rate := 400000;&#xA;  c.codec_id := i_video_stream.codec.codec_id;&#xA;  c.codec_type := i_video_stream.codec.codec_type;&#xA;  c.time_base.num := i_video_stream.time_base.num;&#xA;  c.time_base.den := i_video_stream.time_base.den;&#xA;  //fprintf(stderr, "time_base.num = %d time_base.den = %d\n", c->time_base.num, c->time_base.den);&#xA;  c.width := i_video_stream.codec.width;&#xA;  c.height := i_video_stream.codec.height;&#xA;  c.pix_fmt := i_video_stream.codec.pix_fmt;&#xA;  //printf("%d %d %d", c->width, c->height, c->pix_fmt);&#xA;  c.flags := i_video_stream.codec.flags;&#xA;  c.flags := c.flags or CODEC_FLAG_GLOBAL_HEADER;&#xA;  c.me_range := i_video_stream.codec.me_range;&#xA;  c.max_qdiff := i_video_stream.codec.max_qdiff;&#xA;&#xA;  c.qmin := i_video_stream.codec.qmin;&#xA;  c.qmax := i_video_stream.codec.qmax;&#xA;&#xA;  c.qcompress := i_video_stream.codec.qcompress;&#xA;&#xA;  c.extradata := i_video_stream.codec.extradata;&#xA;  c.extradata_size := i_video_stream.codec.extradata_size;&#xA;&#xA;  avio_open(@o_fmt_ctx.pb, Output, AVIO_FLAG_WRITE);&#xA;&#xA;  (* yes! this is redundant *)&#xA;  avformat_close_input(@i_fmt_ctx);&#xA;&#xA;  avformat_write_header(o_fmt_ctx, nil);&#xA;&#xA;  var last_pts: integer; last_pts := 0;&#xA;  var last_dts: integer; last_dts := 0;&#xA;  for i := 1 to High(Files) do begin&#xA;    i_fmt_ctx := nil;&#xA;&#xA;    if avformat_open_input(@i_fmt_ctx, Files[i], nil, nil) &lt;> 0 then&#xA;      raise Exception.Create(&#x27;Could not open input file&#x27;);&#xA;&#xA;    if avformat_find_stream_info(i_fmt_ctx, nil) &lt; 0 then&#xA;      raise Exception.Create(&#x27;Could not find stream info&#x27;);&#xA;&#xA;    av_dump_format(i_fmt_ctx, 0, Files[i], 0);&#xA;    &#xA;    (* we only use first video stream of each input file *)&#xA;    i_video_stream := nil;&#xA;&#xA;    P := i_fmt_ctx.streams;&#xA;    for S := 0 to i_fmt_ctx.nb_streams-1 do&#xA;      begin&#xA;        if (P^.codec.codec_type = AVMEDIA_TYPE_VIDEO) then&#xA;          begin&#xA;            i_video_stream := P^;&#xA;            break;&#xA;          end;&#xA;        &#xA;        Inc(P);&#xA;      end;&#xA;&#xA;    if i_video_stream = nil then&#xA;      raise Exception.Create(&#x27;Could not find video stream&#x27;);&#xA;    &#xA;    var pts, dts: int64;&#xA;    pts := 0; dts := 0;&#xA;    while true do begin&#xA;      var i_pkt: TAVPacket;&#xA;      av_init_packet( @i_pkt );&#xA;      i_pkt.size := 0;&#xA;      i_pkt.data := nil;&#xA;&#xA;      if av_read_frame(i_fmt_ctx, @i_pkt) &lt; 0 then&#xA;        break;&#xA;      (*&#xA;        pts and dts should increase monotonically&#xA;        pts should be >= dts&#xA;      *)&#xA;      i_pkt.flags := i_pkt.flags or AV_PKT_FLAG_KEY;&#xA;      pts := i_pkt.pts;&#xA;      Inc(i_pkt.pts, last_pts);&#xA;      dts := i_pkt.dts;&#xA;      Inc(i_pkt.dts, last_dts);&#xA;      i_pkt.stream_index := 0;&#xA;&#xA;      // Write&#xA;      av_interleaved_write_frame(o_fmt_ctx, @i_pkt);&#xA;    end;&#xA;&#xA;    Inc(last_dts, dts);&#xA;    Inc(last_pts, pts);  &#xA;  &#xA;    avformat_close_input(@i_fmt_ctx)&#xA;  end;&#xA;&#xA;  av_write_trailer(o_fmt_ctx);&#xA;&#xA;  avcodec_close(o_fmt_ctx.streams^.codec);&#xA;  av_freep(&amp;o_fmt_ctx.streams^.codec);&#xA;  av_freep(&amp;o_fmt_ctx.streams);&#xA;&#xA;  avio_close(o_fmt_ctx.pb);&#xA;  av_free(o_fmt_ctx);&#xA;</pansichar>

    &#xA;

    Which is a translation of Михаил Чеботарев's answer.

    &#xA;

    Even if the code worked, I see no handling of the AVMEDIA_TYPE_AUDIO stream, which means this answer is 1/2 of the problem, since It only combines the video stream.

    &#xA;

    Another approach I tried was using the UBitmaps2Video FFMPEG implementation, which is successfully able to merge the video files, but only the video stream, no audio.

    &#xA;

    I tried manually converting the audio stream with the Bass Audio Library. It was able to read the audio and write It in a single WAV file, which then I converted to MP3. Finally muxing the combined video file and the MP3 file with MuxStreams2. Unfortunately, the audio and video do not align properly. I was unable to pinpoint the issue.

    &#xA;

    Currently, the only functional option is using the precompiled FFMPEG Executables and using ShellExecute with the according parameters to combine the videos.&#xA;This more exactly :

    &#xA;

    ffmpeg -f concat -safe 0 -i video-list.txt -c copy output.mp4&#xA;

    &#xA;

    But I would still rather use the FFMPEG headers in Delphi to combine the videos that way, as that gives the option for Progress indicatiors, more control of the playback and the ability to pause the thread at any point.

    &#xA;

    So, why does my implementation to merge video files not work. And what is a good method to include the audio stream as well ?

    &#xA;

  • TS video copied to MP4, missing 3 first frames when programmatically read (ffmpeg bug)

    3 septembre 2023, par Vasilis Lemonidis

    Running :

    &#xA;

    ffmpeg -i test.ts -fflags &#x2B;genpts -c copy -y test.mp4&#xA;

    &#xA;

    for this test.ts, which has 30 frames, readable by opencv, I end up with 28 frames, out of which 27 are readable by opencv. More specifically :

    &#xA;

    ffprobe -v error -select_streams v:0 -count_packets  -show_entries stream=nb_read_packets -of csv=p=0 tmp.ts &#xA;

    &#xA;

    returns 30.

    &#xA;

    ffprobe -v error -select_streams v:0 -count_packets     -show_entries stream=nb_read_packets -of csv=p=0 tmp.mp4&#xA;

    &#xA;

    returns 28.

    &#xA;

    Using OpenCV in that manner

    &#xA;

    cap = cv2.VideoCapture(tmp_path)&#xA;readMat = []&#xA;while cap.isOpened():&#xA;        ret, frame = cap.read()&#xA;        if not ret:&#xA;            break&#xA;        readMat.append(frame)&#xA;

    &#xA;

    I get for the ts file 30 frames, while for the mp4 27 frames.

    &#xA;

    Could someone explain why the discrepancies ? I get no error during the transformation from ts to mp4 :

    &#xA;

    ffmpeg version N-111746-gd53acf452f Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with gcc 11.3.0 (GCC)&#xA;  configuration: --ld=g&#x2B;&#x2B; --bindir=/bin --extra-libs=&#x27;-lpthread -lm&#x27; --pkg-config-flags=--static --enable-static --enable-gpl --enable-libaom --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-libnpp &#xA;  libavutil      58. 16.101 / 58. 16.101&#xA;  libavcodec     60. 23.100 / 60. 23.100&#xA;  libavformat    60. 10.100 / 60. 10.100&#xA;  libavdevice    60.  2.101 / 60.  2.101&#xA;  libavfilter     9. 10.100 /  9. 10.100&#xA;  libswscale      7.  3.100 /  7.  3.100&#xA;  libswresample   4. 11.100 /  4. 11.100&#xA;  libpostproc    57.  2.100 / 57.  2.100&#xA;[mpegts @ 0x4237240] DTS discontinuity in stream 0: packet 5 with DTS 306003, packet 6 with DTS 396001&#xA;Input #0, mpegts, from &#x27;tmp.ts&#x27;:&#xA;  Duration: 00:00:21.33, start: 3.400000, bitrate: 15 kb/s&#xA;  Program 1 &#xA;    Metadata:&#xA;      service_name    : Service01&#xA;      service_provider: FFmpeg&#xA;  Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 300x300, 1 fps, 3 tbr, 90k tbn&#xA;Output #0, mp4, to &#x27;test.mp4&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf60.10.100&#xA;  Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 300x300, q=2-31, 1 fps, 3 tbr, 90k tbn&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (copy)&#xA;Press [q] to stop, [?] for help&#xA;[out#0/mp4 @ 0x423e280] video:25kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.192123%&#xA;frame=   30 fps=0.0 q=-1.0 Lsize=      26kB time=00:00:21.00 bitrate=  10.3kbits/s speed=1e&#x2B;04x &#xA;

    &#xA;

    Additional information

    &#xA;

    The origin of the video I am processing comes from a continuous stitching operation of still images ts videos, produced by this class update method :

    &#xA;

    import cv2&#xA;import os&#xA;import subprocess&#xA;from tempfile import NamedTemporaryFile&#xA;class VideoUpdater:&#xA;    def __init__(&#xA;        self, video_path: str, framerate: int, timePerFrame: Optional[int] = None&#xA;    ):&#xA;        """&#xA;        Video updater takes in a video path, and updates it using a supplied frame, based on a given framerate.&#xA;        Args:&#xA;            video_path: str: Specify the path to the video file&#xA;            framerate: int: Set the frame rate of the video&#xA;        """&#xA;        if not video_path.endswith(".mp4"):&#xA;            LOGGER.warning(&#xA;                f"File type {os.path.splitext(video_path)[1]} not supported for streaming, switching to ts"&#xA;            )&#xA;            video_path = os.path.splitext(video_path)[0] &#x2B; ".mp4"&#xA;&#xA;        self._ps = None&#xA;        self.env = {&#xA;            &#xA;        }&#xA;        self.ffmpeg = "/usr/bin/ffmpeg "&#xA;&#xA;        self.video_path = video_path&#xA;        self.ts_path = video_path.replace(".mp4", ".ts")&#xA;        self.tfile = None&#xA;        self.framerate = framerate&#xA;        self._video = None&#xA;        self.last_frame = None&#xA;        self.curr_frame = None&#xA;&#xA;&#xA;    def update(self, frame: np.ndarray):&#xA;        if len(frame.shape) == 2:&#xA;            frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)&#xA;        else:&#xA;            frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)&#xA;        self.writeFrame(frame)&#xA;&#xA;    def writeFrame(self, frame: np.ndarray):&#xA;        """&#xA;        The writeFrame function takes a frame and writes it to the video file.&#xA;        Args:&#xA;            frame: np.ndarray: Write the frame to a temporary file&#xA;        """&#xA;&#xA;&#xA;        tImLFrame = NamedTemporaryFile(suffix=".png")&#xA;        tVidLFrame = NamedTemporaryFile(suffix=".ts")&#xA;&#xA;        cv2.imwrite(tImLFrame.name, frame)&#xA;        ps = subprocess.Popen(&#xA;            self.ffmpeg&#xA;            &#x2B; rf"-loop 1 -r {self.framerate} -i {tImLFrame.name} -t {self.framerate} -vcodec libx264 -pix_fmt yuv420p -y {tVidLFrame.name}",&#xA;            env=self.env,&#xA;            shell=True,&#xA;            stdout=subprocess.PIPE,&#xA;            stderr=subprocess.PIPE,&#xA;        )&#xA;        ps.communicate()&#xA;        if os.path.isfile(self.ts_path):&#xA;            # this does not work to watch, as timestamps are not updated&#xA;            ps = subprocess.Popen(&#xA;                self.ffmpeg&#xA;                &#x2B; rf&#x27;-i "concat:{self.ts_path}|{tVidLFrame.name}" -c copy -y {self.ts_path.replace(".ts", ".bak.ts")}&#x27;,&#xA;                env=self.env,&#xA;                shell=True,&#xA;                stdout=subprocess.PIPE,&#xA;                stderr=subprocess.PIPE,&#xA;            )&#xA;            ps.communicate()&#xA;            shutil.move(self.ts_path.replace(".ts", ".bak.ts"), self.ts_path)&#xA;&#xA;        else:&#xA;            shutil.copyfile(tVidLFrame.name, self.ts_path)&#xA;        # fixing timestamps, we dont have to wait for this operation&#xA;        ps = subprocess.Popen(&#xA;            self.ffmpeg&#xA;            &#x2B; rf"-i {self.ts_path} -fflags &#x2B;genpts -c copy -y {self.video_path}",&#xA;            env=self.env,&#xA;            shell=True,&#xA;            # stdout=subprocess.PIPE,&#xA;            # stderr=subprocess.PIPE,&#xA;        )&#xA;        tImLFrame.close()&#xA;        tVidLFrame.close()&#xA;

    &#xA;

  • FFMPEG : TS video copied to MP4, missing 3 first frames [closed]

    21 août 2023, par Vasilis Lemonidis

    Running :

    &#xA;

    ffmpeg -i test.ts -fflags &#x2B;genpts -c copy -y test.mp4&#xA;

    &#xA;

    for this test.ts, which has 30 frames, readable by opencv, I end up with 28 frames, out of which 27 are readable by opencv. More specifically :

    &#xA;

    ffprobe -v error -select_streams v:0 -count_packets  -show_entries stream=nb_read_packets -of csv=p=0 tmp.ts &#xA;

    &#xA;

    returns 30.

    &#xA;

    ffprobe -v error -select_streams v:0 -count_packets     -show_entries stream=nb_read_packets -of csv=p=0 tmp.mp4&#xA;

    &#xA;

    returns 28.

    &#xA;

    Using OpenCV in that manner

    &#xA;

    cap = cv2.VideoCapture(tmp_path)&#xA;readMat = []&#xA;while cap.isOpened():&#xA;        ret, frame = cap.read()&#xA;        if not ret:&#xA;            break&#xA;        readMat.append(frame)&#xA;

    &#xA;

    I get for the ts file 30 frames, while for the mp4 27 frames.

    &#xA;

    Could someone explain why the discrepancies ? I get no error during the transformation from ts to mp4 :

    &#xA;

    ffmpeg version N-111746-gd53acf452f Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with gcc 11.3.0 (GCC)&#xA;  configuration: --ld=g&#x2B;&#x2B; --bindir=/bin --extra-libs=&#x27;-lpthread -lm&#x27; --pkg-config-flags=--static --enable-static --enable-gpl --enable-libaom --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-libnpp &#xA;  libavutil      58. 16.101 / 58. 16.101&#xA;  libavcodec     60. 23.100 / 60. 23.100&#xA;  libavformat    60. 10.100 / 60. 10.100&#xA;  libavdevice    60.  2.101 / 60.  2.101&#xA;  libavfilter     9. 10.100 /  9. 10.100&#xA;  libswscale      7.  3.100 /  7.  3.100&#xA;  libswresample   4. 11.100 /  4. 11.100&#xA;  libpostproc    57.  2.100 / 57.  2.100&#xA;[mpegts @ 0x4237240] DTS discontinuity in stream 0: packet 5 with DTS 306003, packet 6 with DTS 396001&#xA;Input #0, mpegts, from &#x27;tmp.ts&#x27;:&#xA;  Duration: 00:00:21.33, start: 3.400000, bitrate: 15 kb/s&#xA;  Program 1 &#xA;    Metadata:&#xA;      service_name    : Service01&#xA;      service_provider: FFmpeg&#xA;  Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 300x300, 1 fps, 3 tbr, 90k tbn&#xA;Output #0, mp4, to &#x27;test.mp4&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf60.10.100&#xA;  Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 300x300, q=2-31, 1 fps, 3 tbr, 90k tbn&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (copy)&#xA;Press [q] to stop, [?] for help&#xA;[out#0/mp4 @ 0x423e280] video:25kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.192123%&#xA;frame=   30 fps=0.0 q=-1.0 Lsize=      26kB time=00:00:21.00 bitrate=  10.3kbits/s speed=1e&#x2B;04x &#xA;

    &#xA;

    Additional information

    &#xA;

    The origin of the video I am processing comes from a continuous stitching operation of still images ts videos, produced by this class update method :

    &#xA;

    import cv2&#xA;import os&#xA;import subprocess&#xA;from tempfile import NamedTemporaryFile&#xA;class VideoUpdater:&#xA;    def __init__(&#xA;        self, video_path: str, framerate: int, timePerFrame: Optional[int] = None&#xA;    ):&#xA;        """&#xA;        Video updater takes in a video path, and updates it using a supplied frame, based on a given framerate.&#xA;        Args:&#xA;            video_path: str: Specify the path to the video file&#xA;            framerate: int: Set the frame rate of the video&#xA;        """&#xA;        if not video_path.endswith(".mp4"):&#xA;            LOGGER.warning(&#xA;                f"File type {os.path.splitext(video_path)[1]} not supported for streaming, switching to ts"&#xA;            )&#xA;            video_path = os.path.splitext(video_path)[0] &#x2B; ".mp4"&#xA;&#xA;        self._ps = None&#xA;        self.env = {&#xA;            &#xA;        }&#xA;        self.ffmpeg = "/usr/bin/ffmpeg "&#xA;&#xA;        self.video_path = video_path&#xA;        self.ts_path = video_path.replace(".mp4", ".ts")&#xA;        self.tfile = None&#xA;        self.framerate = framerate&#xA;        self._video = None&#xA;        self.last_frame = None&#xA;        self.curr_frame = None&#xA;&#xA;&#xA;    def update(self, frame: np.ndarray):&#xA;        if len(frame.shape) == 2:&#xA;            frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)&#xA;        else:&#xA;            frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)&#xA;        self.writeFrame(frame)&#xA;&#xA;    def writeFrame(self, frame: np.ndarray):&#xA;        """&#xA;        The writeFrame function takes a frame and writes it to the video file.&#xA;        Args:&#xA;            frame: np.ndarray: Write the frame to a temporary file&#xA;        """&#xA;&#xA;&#xA;        tImLFrame = NamedTemporaryFile(suffix=".png")&#xA;        tVidLFrame = NamedTemporaryFile(suffix=".ts")&#xA;&#xA;        cv2.imwrite(tImLFrame.name, frame)&#xA;        ps = subprocess.Popen(&#xA;            self.ffmpeg&#xA;            &#x2B; rf"-loop 1 -r {self.framerate} -i {tImLFrame.name} -t {self.framerate} -vcodec libx264 -pix_fmt yuv420p -y {tVidLFrame.name}",&#xA;            env=self.env,&#xA;            shell=True,&#xA;            stdout=subprocess.PIPE,&#xA;            stderr=subprocess.PIPE,&#xA;        )&#xA;        ps.communicate()&#xA;        if os.path.isfile(self.ts_path):&#xA;            # this does not work to watch, as timestamps are not updated&#xA;            ps = subprocess.Popen(&#xA;                self.ffmpeg&#xA;                &#x2B; rf&#x27;-i "concat:{self.ts_path}|{tVidLFrame.name}" -c copy -y {self.ts_path.replace(".ts", ".bak.ts")}&#x27;,&#xA;                env=self.env,&#xA;                shell=True,&#xA;                stdout=subprocess.PIPE,&#xA;                stderr=subprocess.PIPE,&#xA;            )&#xA;            ps.communicate()&#xA;            shutil.move(self.ts_path.replace(".ts", ".bak.ts"), self.ts_path)&#xA;&#xA;        else:&#xA;            shutil.copyfile(tVidLFrame.name, self.ts_path)&#xA;        # fixing timestamps, we dont have to wait for this operation&#xA;        ps = subprocess.Popen(&#xA;            self.ffmpeg&#xA;            &#x2B; rf"-i {self.ts_path} -fflags &#x2B;genpts -c copy -y {self.video_path}",&#xA;            env=self.env,&#xA;            shell=True,&#xA;            # stdout=subprocess.PIPE,&#xA;            # stderr=subprocess.PIPE,&#xA;        )&#xA;        tImLFrame.close()&#xA;        tVidLFrame.close()&#xA;

    &#xA;