Recherche avancée

Médias (91)

Autres articles (23)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

  • Changer son thème graphique

    22 février 2011, par

    Le thème graphique ne touche pas à la disposition à proprement dite des éléments dans la page. Il ne fait que modifier l’apparence des éléments.
    Le placement peut être modifié effectivement, mais cette modification n’est que visuelle et non pas au niveau de la représentation sémantique de la page.
    Modifier le thème graphique utilisé
    Pour modifier le thème graphique utilisé, il est nécessaire que le plugin zen-garden soit activé sur le site.
    Il suffit ensuite de se rendre dans l’espace de configuration du (...)

Sur d’autres sites (5705)

  • Anomalie #3217 (Nouveau) : Caractères spéciaux d’expression régulière présents dans une chaîne de ...

    22 mai 2014, par Pascal Verrier

    Bonjour,

    J’ai une boucle au sein de l’affichage d’un forum qui permet d’afficher les autres posts similaires ; pour cela, l’argument recherche est renseigné avec le titre du forum en cours d’affichage.

    Cela fonctionne bien sur la plupart des pages sauf sur un forum ayant le titre suivant : Sortie du kit compatible SPIP 3 ??

    J’ai une erreur MySQL 1139 :

    Got error ’repetition-operator operand invalid’ from regexp
    SELECT t.id_forum, t.titre, t.texte, t.auteur, t.email_auteur, t.nom_site, t.url_site FROM spip_forum AS t WHERE t.titre REGEXP ’Sortie du kit compatible SPIP 3 ??|Sortie|compatible|SPIP’ OR ...
    

    Ce sont les ?? qui coincent car manifestament ils sont interprétés en tant que métacaractères dans la regex, n’ayant pas été échappés.

    J’ai fait un autre essai en mettant d’autres opérateurs de regex : Sortie kit[0-9]* compatib(ilité|le) SPIP 3 ??, qui confirme ce que je pensais :

    Erreur SQL 1139
    Got error ’repetition-operator operand invalid’ from regexp
    SELECT ... WHERE t.titre REGEXP ’Sortie kit[0-9]* compatib(ilite|le) SPIP 3 ??|Sortie|kit[0-9]*|compatib(ilite|le)|SPIP’ OR ...
    

    à savoir la chaîne de recherche n’est pas prétraitée, et les caractères spéciaux sont repris tels quels, d’où le plantage MySQL.

    Je propose donc les corrections ci-joint pour ecrire/inc/rechercher.php (commentaires avec pverrier).

  • Is there a way to extract frames from a video file using ffmpeg to memory and make some manipulation on each frame ?

    28 octobre 2022, par Rojer Brief

    The goal is to extract each time a frame from the video file then make histogram from the image and then to move to the next frame. this way all the frames.

    


    The frames extraction and the histogram manipulation is working fine when the frames have saved as images on the hard disk. but now i want to do it all in memory.

    


    to extract the frames i'm using ffmpeg because i think it's fast enough :

    


    ffmpeg -r 1 -i MyVid.mp4 -r 1 "$filename%03d.png


    


    for now i'm using the ffmpeg in command prompt window.

    


    with this command it will save on the hard disk over 65000 images(frames).
but instead saving them on the hard disk i wonder if i can make the histogram manipulation on each frame in memory instead saving all the 65000 frames to the hard disk.

    


    then i want to find specific images using the histogram and save to the hard disk this frames.

    


    the histogram part for now is also using files from the hard disk and not from the memory :

    


    private void btnLoadHistogram_Click(object sender, System.EventArgs e)
        {
            string[] files = Directory.GetFiles(@"d:\screenshots\", "*.jpg");

            for (int i = 0; i < files.Length; i++)
            {
                sbInfo.Text = "Loading image";
                if (pbImage.Image != null)
                    pbImage.Image.Dispose();

                pbImage.Image = Image.FromFile(files[i]);//txtFileName.Text);

                Application.DoEvents();

                sbInfo.Text = "Computing histogram";
                long[] myValues = GetHistogram(new Bitmap(pbImage.Image));

                Histogram.DrawHistogram(myValues);

                sbInfo.Text = "";   
            }   
        }

        public long[] GetHistogram(System.Drawing.Bitmap picture)
        {
            long[] myHistogram = new long[256];

            for (int i=0;i3;
                    myHistogram[Temp]++;
                }

            return myHistogram;
        }


    


    and the code of the class of the constrol HistogramaDesenat :

    


    using System;&#xA;using System.Collections;&#xA;using System.ComponentModel;&#xA;using System.Drawing;&#xA;using System.Data;&#xA;using System.Windows.Forms;&#xA;&#xA;namespace Histograma&#xA;{&#xA;    /// <summary>&#xA;    /// Summary description for HistogramaDesenat.&#xA;    /// </summary>&#xA;    public class HistogramaDesenat : System.Windows.Forms.UserControl&#xA;    {&#xA;        /// <summary> &#xA;        /// Required designer variable.&#xA;        /// </summary>&#xA;        private System.ComponentModel.Container components = null;&#xA;&#xA;        public HistogramaDesenat()&#xA;        {&#xA;            // This call is required by the Windows.Forms Form Designer.&#xA;            InitializeComponent();&#xA;&#xA;            // TODO: Add any initialization after the InitializeComponent call&#xA;&#xA;            this.Paint &#x2B;= new PaintEventHandler(HistogramaDesenat_Paint);&#xA;            this.Resize&#x2B;=new EventHandler(HistogramaDesenat_Resize);&#xA;        }&#xA;&#xA;        /// <summary> &#xA;        /// Clean up any resources being used.&#xA;        /// </summary>&#xA;        protected override void Dispose( bool disposing )&#xA;        {&#xA;            if( disposing )&#xA;            {&#xA;                if(components != null)&#xA;                {&#xA;                    components.Dispose();&#xA;                }&#xA;            }&#xA;            base.Dispose( disposing );&#xA;        }&#xA;&#xA;        #region Component Designer generated code&#xA;        /// <summary> &#xA;        /// Required method for Designer support - do not modify &#xA;        /// the contents of this method with the code editor.&#xA;        /// </summary>&#xA;        private void InitializeComponent()&#xA;        {&#xA;            // &#xA;            // HistogramaDesenat&#xA;            // &#xA;            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));&#xA;            this.Name = "HistogramaDesenat";&#xA;            this.Size = new System.Drawing.Size(208, 176);&#xA;        }&#xA;        #endregion&#xA;&#xA;        private void HistogramaDesenat_Paint(object sender, PaintEventArgs e)&#xA;        {&#xA;            if (myIsDrawing)&#xA;            {&#xA;&#xA;                Graphics g = e.Graphics;&#xA;                Pen myPen = new Pen(new SolidBrush(myColor),myXUnit);&#xA;                //The width of the pen is given by the XUnit for the control.&#xA;                for (int i=0;i/We draw each line &#xA;                    g.DrawLine(myPen,&#xA;                        new PointF(myOffset &#x2B; (i*myXUnit), this.Height - myOffset), &#xA;                        new PointF(myOffset &#x2B; (i*myXUnit), this.Height - myOffset - myValues[i] * myYUnit));&#xA;&#xA;                    //We plot the coresponding index for the maximum value.&#xA;                    if (myValues[i]==myMaxValue)&#xA;                    {&#xA;                        SizeF mySize = g.MeasureString(i.ToString(),myFont);&#xA;&#xA;                        g.DrawString(i.ToString(),myFont,new SolidBrush(myColor),&#xA;                            new PointF(myOffset &#x2B; (i*myXUnit) - (mySize.Width/2), this.Height - myFont.Height ),&#xA;                            System.Drawing.StringFormat.GenericDefault);&#xA;                    }&#xA;                }&#xA;&#xA;                //We draw the indexes for 0 and for the length of the array beeing plotted&#xA;                g.DrawString("0",myFont, new SolidBrush(myColor),new PointF(myOffset,this.Height - myFont.Height),System.Drawing.StringFormat.GenericDefault);&#xA;                g.DrawString((myValues.Length-1).ToString(),myFont, &#xA;                    new SolidBrush(myColor),&#xA;                    new PointF(myOffset &#x2B; (myValues.Length * myXUnit) - g.MeasureString((myValues.Length-1).ToString(),myFont).Width,&#xA;                    this.Height - myFont.Height),&#xA;                    System.Drawing.StringFormat.GenericDefault);&#xA;&#xA;                //We draw a rectangle surrounding the control.&#xA;                g.DrawRectangle(new System.Drawing.Pen(new SolidBrush(Color.Black),1),0,0,this.Width-1,this.Height-1);&#xA;            }&#xA;&#xA;        }&#xA;&#xA;        long myMaxValue;&#xA;        private long[] myValues;&#xA;        private bool myIsDrawing;&#xA;&#xA;        private float myYUnit; //this gives the vertical unit used to scale our values&#xA;        private float myXUnit; //this gives the horizontal unit used to scale our values&#xA;        private int myOffset = 20; //the offset, in pixels, from the control margins.&#xA;&#xA;        private Color myColor = Color.Black;&#xA;        private Font myFont = new Font("Tahoma",10);&#xA;&#xA;        [Category("Histogram Options")]&#xA;        [Description ("The distance from the margins for the histogram")]&#xA;        public int Offset&#xA;        {&#xA;            set&#xA;            {&#xA;                if (value>0)&#xA;                    myOffset= value;&#xA;            }&#xA;            get&#xA;            {&#xA;                return myOffset;&#xA;            }&#xA;        }&#xA;&#xA;        [Category("Histogram Options")]&#xA;        [Description ("The color used within the control")]&#xA;        public Color DisplayColor&#xA;        {&#xA;            set&#xA;            {&#xA;                myColor = value;&#xA;            }&#xA;            get&#xA;            {&#xA;                return myColor;&#xA;            }&#xA;        }&#xA;&#xA;        /// <summary>&#xA;        /// We draw the histogram on the control&#xA;        /// </summary>&#xA;        /// The values beeing draw&#xA;        public void DrawHistogram(long[] Values)&#xA;        {&#xA;            myValues = new long[Values.Length];&#xA;            Values.CopyTo(myValues,0);&#xA;&#xA;            myIsDrawing = true;&#xA;            myMaxValue = getMaxim(myValues);&#xA;&#xA;            ComputeXYUnitValues();&#xA;&#xA;            this.Refresh();&#xA;        }&#xA;&#xA;        /// <summary>&#xA;        /// We get the highest value from the array&#xA;        /// </summary>&#xA;        /// The array of values in which we look&#xA;        /// <returns>The maximum value</returns>&#xA;        private long getMaxim(long[] Vals)&#xA;        {&#xA;            if (myIsDrawing)&#xA;            {&#xA;                long max = 0;&#xA;                for (int i=0;i max)&#xA;                        max = Vals[i];&#xA;                }&#xA;                return max;&#xA;            }&#xA;            return 1;&#xA;        }&#xA;&#xA;        private void HistogramaDesenat_Resize(object sender, EventArgs e)&#xA;        {&#xA;            if (myIsDrawing)&#xA;            {&#xA;                ComputeXYUnitValues();&#xA;            }&#xA;            this.Refresh();&#xA;        }&#xA;&#xA;        private void ComputeXYUnitValues()&#xA;        {&#xA;            myYUnit = (float) (this.Height - (2 * myOffset)) / myMaxValue;&#xA;            myXUnit = (float) (this.Width - (2 * myOffset)) / (myValues.Length-1);&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;

    so in the end this is what i want to do :

    &#xA;

      &#xA;
    • extract the frames from the video file in memory using the ffmpeg.

      &#xA;

    • &#xA;

    • instead using Directory.GetFiles i want to make the histogram manipulation on each frame from the memory that is extracted by the ffmpeg.

      &#xA;

    • &#xA;

    • each extracted frame image to use the histogram to find if there is a lightning(weather lightning) in the image.

      &#xA;

    • &#xA;

    • if there is a lightning save the frame image to the hard disk.

      &#xA;

    • &#xA;

    &#xA;

  • FFmpeg WASM writeFile Stalls and Doesn't Complete in React App with Ant Design

    26 février, par raiyan khan

    I'm using FFmpeg WebAssembly (WASM) in a React app to process and convert a video file before uploading it. The goal is to resize the video to 720p using FFmpeg before sending it to the backend.

    &#xA;

    Problem :

    &#xA;

    Everything works up to fetching the file and confirming it's loaded into memory, but FFmpeg hangs at ffmpeg.writeFile() and does not proceed further. No errors are thrown.

    &#xA;

    Code Snippet :

    &#xA;

      &#xA;
    • Loading FFmpeg

      &#xA;

       const loadFFmpeg = async () => {&#xA; if (loaded) return; // Avoid reloading if &#xA; already loaded&#xA;&#xA; const baseURL = &#x27;https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd&#x27;;&#xA; const ffmpeg = ffmpegRef.current;&#xA; ffmpeg.on(&#x27;log&#x27;, ({ message }) => {&#xA;     messageRef.current.innerHTML = message;&#xA;     console.log(message);&#xA; });&#xA; await ffmpeg.load({&#xA;     coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, &#x27;text/javascript&#x27;),&#xA;     wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, &#x27;application/wasm&#x27;),&#xA; });&#xA; setLoaded(true);&#xA; };&#xA;&#xA; useEffect(() => {&#xA; loadFFmpeg()&#xA; }, [])&#xA;

      &#xA;

    • &#xA;

    • Fetching and Writing File

      &#xA;

        const convertVideoTo720p = async (videoFile) => {&#xA;       console.log("Starting video &#xA;     conversion...");&#xA;&#xA;&#xA;&#xA; const { height } = await getVideoMetadata(videoFile);&#xA; console.log(`Video height: ${height}`);&#xA;&#xA; if (height &lt;= 720) {&#xA;     console.log("No conversion needed.");&#xA;     return videoFile;&#xA; }&#xA;&#xA; const ffmpeg = ffmpegRef.current;&#xA; console.log("FFmpeg instance loaded. Writing file to memory...");&#xA;&#xA; const fetchedFile = await fetchFile(videoFile);&#xA; console.log("File fetched successfully:", fetchedFile);&#xA;&#xA; console.log("Checking FFmpeg memory before writing...");&#xA; console.log(`File size: ${fetchedFile.length} bytes (~${(fetchedFile.length / 1024 / 1024).toFixed(2)} MB)`);&#xA;&#xA; if (!ffmpeg.isLoaded()) {&#xA;     console.error("FFmpeg is not fully loaded yet!");&#xA;     return;&#xA; }&#xA;&#xA; console.log("Memory seems okay. Writing file to FFmpeg...");&#xA; await ffmpeg.writeFile(&#x27;input.mp4&#x27;, fetchedFile);  // ❌ This line hangs, nothing after runs&#xA; console.log("File successfully written to FFmpeg memory.");&#xA;      };&#xA;

      &#xA;

    • &#xA;

    &#xA;

    Debugging Steps I've Tried :

    &#xA;

      &#xA;
    • Ensured FFmpeg is fully loaded before calling writeFile()&#xA;✅ ffmpeg.isLoaded() returns true.
    • &#xA;

    • Checked file fetch process :&#xA;✅ fetchFile(videoFile) successfully returns a Uint8Array.
    • &#xA;

    • Tried renaming the file to prevent caching issues&#xA;✅ Used a unique file name like video_${Date.now()}.mp4, but no change
    • &#xA;

    • Checked browser console for errors :&#xA;❌ No errors are displayed.
    • &#xA;

    • Tried skipping FFmpeg and uploading the raw file instead :&#xA;✅ Upload works fine without FFmpeg, so the issue is specific to FFmpeg.
    • &#xA;

    &#xA;

    Expected Behavior

    &#xA;

      &#xA;
    • ffmpeg.writeFile(&#x27;input.mp4&#x27;, fetchedFile); should complete and allow FFmpeg to process the video.
    • &#xA;

    &#xA;

    Actual Behavior

    &#xA;

      &#xA;
    • Execution stops at writeFile, and no errors are thrown.
    • &#xA;

    &#xA;

    Environment :

    &#xA;

      &#xA;
    • React : 18.x
    • &#xA;

    • FFmpeg WASM Version : @ffmpeg/ffmpeg@0.12.15
    • &#xA;

    • Browser : Chrome 121, Edge 120
    • &#xA;

    • Operating System : Windows 11
    • &#xA;

    &#xA;

    Question :&#xA;Why is FFmpeg's writeFile() stalling and never completing ?&#xA;How can I fix or further debug this issue ?

    &#xA;

    Here is my full code :

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    import { useNavigate } from "react-router-dom";&#xA;import { useEffect, useRef, useState } from &#x27;react&#x27;;&#xA;import { Form, Input, Button, Select, Space } from &#x27;antd&#x27;;&#xA;const { Option } = Select;&#xA;import { FaAngleLeft } from "react-icons/fa6";&#xA;import { message, Upload } from &#x27;antd&#x27;;&#xA;import { CiCamera } from "react-icons/ci";&#xA;import { IoVideocamOutline } from "react-icons/io5";&#xA;import { useCreateWorkoutVideoMutation } from "../../../redux/features/workoutVideo/workoutVideoApi";&#xA;import { convertVideoTo720p } from "../../../utils/ffmpegHelper";&#xA;import { FFmpeg } from &#x27;@ffmpeg/ffmpeg&#x27;;&#xA;import { fetchFile, toBlobURL } from &#x27;@ffmpeg/util&#x27;;&#xA;&#xA;&#xA;const AddWorkoutVideo = () => {&#xA;    const [videoFile, setVideoFile] = useState(null);&#xA;    const [imageFile, setImageFile] = useState(null);&#xA;    const [loaded, setLoaded] = useState(false);&#xA;    const ffmpegRef = useRef(new FFmpeg());&#xA;    const videoRef = useRef(null);&#xA;    const messageRef = useRef(null);&#xA;    const [form] = Form.useForm();&#xA;    const [createWorkoutVideo, { isLoading }] = useCreateWorkoutVideoMutation()&#xA;    const navigate = useNavigate();&#xA;&#xA;    const videoFileRef = useRef(null); // Use a ref instead of state&#xA;&#xA;&#xA;    // Handle Video Upload&#xA;    const handleVideoChange = ({ file }) => {&#xA;        setVideoFile(file.originFileObj);&#xA;    };&#xA;&#xA;    // Handle Image Upload&#xA;    const handleImageChange = ({ file }) => {&#xA;        setImageFile(file.originFileObj);&#xA;    };&#xA;&#xA;    // Load FFmpeg core if needed (optional if you want to preload)&#xA;    const loadFFmpeg = async () => {&#xA;        if (loaded) return; // Avoid reloading if already loaded&#xA;&#xA;        const baseURL = &#x27;https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd&#x27;;&#xA;        const ffmpeg = ffmpegRef.current;&#xA;        ffmpeg.on(&#x27;log&#x27;, ({ message }) => {&#xA;            messageRef.current.innerHTML = message;&#xA;            console.log(message);&#xA;        });&#xA;        await ffmpeg.load({&#xA;            coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, &#x27;text/javascript&#x27;),&#xA;            wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, &#x27;application/wasm&#x27;),&#xA;        });&#xA;        setLoaded(true);&#xA;    };&#xA;&#xA;    useEffect(() => {&#xA;        loadFFmpeg()&#xA;    }, [])&#xA;&#xA;    // Helper: Get video metadata (width and height)&#xA;    const getVideoMetadata = (file) => {&#xA;        return new Promise((resolve, reject) => {&#xA;            const video = document.createElement(&#x27;video&#x27;);&#xA;            video.preload = &#x27;metadata&#x27;;&#xA;            video.onloadedmetadata = () => {&#xA;                resolve({ width: video.videoWidth, height: video.videoHeight });&#xA;            };&#xA;            video.onerror = () => reject(new Error(&#x27;Could not load video metadata&#x27;));&#xA;            video.src = URL.createObjectURL(file);&#xA;        });&#xA;    };&#xA;&#xA;    // Inline conversion helper function&#xA;    // const convertVideoTo720p = async (videoFile) => {&#xA;    //     // Check the video resolution first&#xA;    //     const { height } = await getVideoMetadata(videoFile);&#xA;    //     if (height &lt;= 720) {&#xA;    //         // No conversion needed&#xA;    //         return videoFile;&#xA;    //     }&#xA;    //     const ffmpeg = ffmpegRef.current;&#xA;    //     // Load ffmpeg if not already loaded&#xA;    //     // await ffmpeg.load({&#xA;    //     //     coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, &#x27;text/javascript&#x27;),&#xA;    //     //     wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, &#x27;application/wasm&#x27;),&#xA;    //     // });&#xA;    //     // Write the input file to the ffmpeg virtual FS&#xA;    //     await ffmpeg.writeFile(&#x27;input.mp4&#x27;, await fetchFile(videoFile));&#xA;    //     // Convert video to 720p (scale filter maintains aspect ratio)&#xA;    //     await ffmpeg.exec([&#x27;-i&#x27;, &#x27;input.mp4&#x27;, &#x27;-vf&#x27;, &#x27;scale=-1:720&#x27;, &#x27;output.mp4&#x27;]);&#xA;    //     // Read the output file&#xA;    //     const data = await ffmpeg.readFile(&#x27;output.mp4&#x27;);&#xA;    //     console.log(data, &#x27;data from convertVideoTo720p&#x27;);&#xA;    //     const videoBlob = new Blob([data.buffer], { type: &#x27;video/mp4&#x27; });&#xA;    //     return new File([videoBlob], &#x27;output.mp4&#x27;, { type: &#x27;video/mp4&#x27; });&#xA;    // };&#xA;    const convertVideoTo720p = async (videoFile) => {&#xA;        console.log("Starting video conversion...");&#xA;&#xA;        // Check the video resolution first&#xA;        const { height } = await getVideoMetadata(videoFile);&#xA;        console.log(`Video height: ${height}`);&#xA;&#xA;        if (height &lt;= 720) {&#xA;            console.log("No conversion needed. Returning original file.");&#xA;            return videoFile;&#xA;        }&#xA;&#xA;        const ffmpeg = ffmpegRef.current;&#xA;        console.log("FFmpeg instance loaded. Writing file to memory...");&#xA;&#xA;        // await ffmpeg.writeFile(&#x27;input.mp4&#x27;, await fetchFile(videoFile));&#xA;        // console.log("File written. Starting conversion...");&#xA;        console.log("Fetching file for FFmpeg:", videoFile);&#xA;        const fetchedFile = await fetchFile(videoFile);&#xA;        console.log("File fetched successfully:", fetchedFile);&#xA;        console.log("Checking FFmpeg memory before writing...");&#xA;        console.log(`File size: ${fetchedFile.length} bytes (~${(fetchedFile.length / 1024 / 1024).toFixed(2)} MB)`);&#xA;&#xA;        if (fetchedFile.length > 50 * 1024 * 1024) { // 50MB limit&#xA;            console.error("File is too large for FFmpeg WebAssembly!");&#xA;            message.error("File too large. Try a smaller video.");&#xA;            return;&#xA;        }&#xA;&#xA;        console.log("Memory seems okay. Writing file to FFmpeg...");&#xA;        const fileName = `video_${Date.now()}.mp4`; // Generate a unique name&#xA;        console.log(`Using filename: ${fileName}`);&#xA;&#xA;        await ffmpeg.writeFile(fileName, fetchedFile);&#xA;        console.log(`File successfully written to FFmpeg memory as ${fileName}.`);&#xA;&#xA;        await ffmpeg.exec([&#x27;-i&#x27;, &#x27;input.mp4&#x27;, &#x27;-vf&#x27;, &#x27;scale=-1:720&#x27;, &#x27;output.mp4&#x27;]);&#xA;        console.log("Conversion completed. Reading output file...");&#xA;&#xA;        const data = await ffmpeg.readFile(&#x27;output.mp4&#x27;);&#xA;        console.log("File read successful. Creating new File object.");&#xA;&#xA;        const videoBlob = new Blob([data.buffer], { type: &#x27;video/mp4&#x27; });&#xA;        const convertedFile = new File([videoBlob], &#x27;output.mp4&#x27;, { type: &#x27;video/mp4&#x27; });&#xA;&#xA;        console.log(convertedFile, "converted video from convertVideoTo720p");&#xA;&#xA;        return convertedFile;&#xA;    };&#xA;&#xA;&#xA;    const onFinish = async (values) => {&#xA;        // Ensure a video is selected&#xA;        if (!videoFileRef.current) {&#xA;            message.error("Please select a video file.");&#xA;            return;&#xA;        }&#xA;&#xA;        // Create FormData&#xA;        const formData = new FormData();&#xA;        if (imageFile) {&#xA;            formData.append("image", imageFile);&#xA;        }&#xA;&#xA;        try {&#xA;            message.info("Processing video. Please wait...");&#xA;&#xA;            // Convert the video to 720p only if needed&#xA;            const convertedVideo = await convertVideoTo720p(videoFileRef.current);&#xA;            console.log(convertedVideo, &#x27;convertedVideo from onFinish&#x27;);&#xA;&#xA;            formData.append("media", videoFileRef.current);&#xA;&#xA;            formData.append("data", JSON.stringify(values));&#xA;&#xA;            // Upload manually to the backend&#xA;            const response = await createWorkoutVideo(formData).unwrap();&#xA;            console.log(response, &#x27;response from add video&#x27;);&#xA;&#xA;            message.success("Video added successfully!");&#xA;            form.resetFields(); // Reset form&#xA;            setVideoFile(null); // Clear file&#xA;&#xA;        } catch (error) {&#xA;            message.error(error.data?.message || "Failed to add video.");&#xA;        }&#xA;&#xA;        // if (videoFile) {&#xA;        //     message.info("Processing video. Please wait...");&#xA;        //     try {&#xA;        //         // Convert the video to 720p only if needed&#xA;        //         const convertedVideo = await convertVideoTo720p(videoFile);&#xA;        //         formData.append("media", convertedVideo);&#xA;        //     } catch (conversionError) {&#xA;        //         message.error("Video conversion failed.");&#xA;        //         return;&#xA;        //     }&#xA;        // }&#xA;        // formData.append("data", JSON.stringify(values)); // Convert text fields to JSON&#xA;&#xA;        // try {&#xA;        //     const response = await createWorkoutVideo(formData).unwrap();&#xA;        //     console.log(response, &#x27;response from add video&#x27;);&#xA;&#xA;        //     message.success("Video added successfully!");&#xA;        //     form.resetFields(); // Reset form&#xA;        //     setFile(null); // Clear file&#xA;        // } catch (error) {&#xA;        //     message.error(error.data?.message || "Failed to add video.");&#xA;        // }&#xA;    };&#xA;&#xA;    const handleBackButtonClick = () => {&#xA;        navigate(-1); // This takes the user back to the previous page&#xA;    };&#xA;&#xA;    const videoUploadProps = {&#xA;        name: &#x27;video&#x27;,&#xA;        // action: &#x27;https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload&#x27;,&#xA;        // headers: {&#xA;        //     authorization: &#x27;authorization-text&#x27;,&#xA;        // },&#xA;        // beforeUpload: (file) => {&#xA;        //     const isVideo = file.type.startsWith(&#x27;video/&#x27;);&#xA;        //     if (!isVideo) {&#xA;        //         message.error(&#x27;You can only upload video files!&#x27;);&#xA;        //     }&#xA;        //     return isVideo;&#xA;        // },&#xA;        // onChange(info) {&#xA;        //     if (info.file.status === &#x27;done&#x27;) {&#xA;        //         message.success(`${info.file.name} video uploaded successfully`);&#xA;        //     } else if (info.file.status === &#x27;error&#x27;) {&#xA;        //         message.error(`${info.file.name} video upload failed.`);&#xA;        //     }&#xA;        // },&#xA;        beforeUpload: (file) => {&#xA;            const isVideo = file.type.startsWith(&#x27;video/&#x27;);&#xA;            if (!isVideo) {&#xA;                message.error(&#x27;You can only upload video files!&#x27;);&#xA;                return Upload.LIST_IGNORE; // Prevents the file from being added to the list&#xA;            }&#xA;            videoFileRef.current = file; // Store file in ref&#xA;            // setVideoFile(file); // Store the file in state instead of uploading it automatically&#xA;            return false; // Prevent auto-upload&#xA;        },&#xA;    };&#xA;&#xA;    const imageUploadProps = {&#xA;        name: &#x27;image&#x27;,&#xA;        action: &#x27;https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload&#x27;,&#xA;        headers: {&#xA;            authorization: &#x27;authorization-text&#x27;,&#xA;        },&#xA;        beforeUpload: (file) => {&#xA;            const isImage = file.type.startsWith(&#x27;image/&#x27;);&#xA;            if (!isImage) {&#xA;                message.error(&#x27;You can only upload image files!&#x27;);&#xA;            }&#xA;            return isImage;&#xA;        },&#xA;        onChange(info) {&#xA;            if (info.file.status === &#x27;done&#x27;) {&#xA;                message.success(`${info.file.name} image uploaded successfully`);&#xA;            } else if (info.file.status === &#x27;error&#x27;) {&#xA;                message.error(`${info.file.name} image upload failed.`);&#xA;            }&#xA;        },&#xA;    };&#xA;    return (&#xA;        &lt;>&#xA;            <div classname="flex items-center gap-2 text-xl cursor-pointer">&#xA;                <faangleleft></faangleleft>&#xA;                <h1 classname="font-semibold">Add Video</h1>&#xA;            </div>&#xA;            <div classname="rounded-lg py-4 border-[#79CDFF] border-2 shadow-lg mt-8 bg-white">&#xA;                <div classname="space-y-[24px] min-h-[83vh] bg-light-gray rounded-2xl">&#xA;                    <h3 classname="text-2xl text-[#174C6B] mb-4 border-b border-[#79CDFF]/50 pb-3 pl-16 font-semibold">&#xA;                        Adding Video&#xA;                    </h3>&#xA;                    <div classname="w-full px-16">&#xA;                        / style={{ maxWidth: 600, margin: &#x27;0 auto&#x27; }}&#xA;                        >&#xA;                            {/* Section 1 */}&#xA;                            {/* <space direction="vertical" style="{{"> */}&#xA;                            {/* <space size="large" direction="horizontal" classname="responsive-space"> */}&#xA;                            <div classname="grid grid-cols-2 gap-8 mt-8">&#xA;                                <div>&#xA;                                    <space size="large" direction="horizontal" classname="responsive-space-section-2">&#xA;&#xA;                                        {/* Video */}&#xA;                                        Upload Video}&#xA;                                            name="media"&#xA;                                            className="responsive-form-item"&#xA;                                        // rules={[{ required: true, message: &#x27;Please enter the package amount!&#x27; }]}&#xA;                                        >&#xA;                                            <upload maxcount="{1}">&#xA;                                                <button style="{{" solid="solid">&#xA;                                                    <span style="{{" 600="600">Select a video</span>&#xA;                                                    <iovideocamoutline size="{20}" color="#174C6B"></iovideocamoutline>&#xA;                                                </button>&#xA;                                            </upload>&#xA;                                        &#xA;&#xA;                                        {/* Thumbnail */}&#xA;                                        Upload Image}&#xA;                                            name="image"&#xA;                                            className="responsive-form-item"&#xA;                                        // rules={[{ required: true, message: &#x27;Please enter the package amount!&#x27; }]}&#xA;                                        >&#xA;                                            <upload maxcount="{1}">&#xA;                                                <button style="{{" solid="solid">&#xA;                                                    <span style="{{" 600="600">Select an image</span>&#xA;                                                    <cicamera size="{25}" color="#174C6B"></cicamera>&#xA;                                                </button>&#xA;                                            </upload>&#xA;                                        &#xA;&#xA;                                        {/* Title */}&#xA;                                        Video Title}&#xA;                                            name="name"&#xA;                                            className="responsive-form-item-section-2"&#xA;                                        >&#xA;                                            <input type="text" placeholder="Enter video title" style="{{&amp;#xA;" solid="solid" />&#xA;                                        &#xA;                                    </space>&#xA;                                </div>&#xA;                            </div>&#xA;&#xA;                            {/* </space> */}&#xA;                            {/* </space> */}&#xA;&#xA;&#xA;                            {/* Submit Button */}&#xA;                            &#xA;                                <div classname="p-4 mt-10 text-center mx-auto flex items-center justify-center">&#xA;                                    &#xA;                                        <span classname="text-white font-semibold">{isLoading ? &#x27;Uploading...&#x27; : &#x27;Upload&#x27;}</span>&#xA;                                    &#xA;                                </div>&#xA;                            &#xA;                        &#xA;                    </div>&#xA;                </div>&#xA;            </div>&#xA;        >&#xA;    )&#xA;}&#xA;&#xA;export default AddWorkoutVideo

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    Would appreciate any insights or suggestions. Thanks !

    &#xA;