Recherche avancée

Médias (91)

Sur d’autres sites (139)

  • Anomalie #1970 (Fermé) : Pas de crochets dans le HTML !

    26 mars 2011, par cedric -

    corrigé par r17527

  • Revision 34267 : {{{ #DATE_DEBUT }}} dans les forums, c’est le 1er janvier 1970, ce qui ne ...

    7 janvier 2010, par fil@… — Log

    #DATE_DEBUT dans les forums, c’est le 1er janvier 1970, ce qui ne m’arrange pas car je n’etais pas encore ne

  • Can I use the file buffer or stream as input for fluent-ffmpeg ? I am trying to avoid saving the video locally to get its path before removing

    22 avril 2023, par Moath Thawahreh

    I am receiving the file via an api, I was trying to process the file.buffer as input for FFmpeg but it did not work, I had to save the video locally first and then process the path and remove the saved video later on.
I don't want to believe that there is no other way to solve this and I have been looking for solutions and workarounds but it was all about ffmpeg input as a path.

    


    I would love to find a solution using fluent-ffmpeg because it has some other great features, but I won't mind any suggestions for compressing the video using any different approaches if it's more efficient

    


    Again my code below works fine but I have to save the video and then remove it I am hoping for a more efficient solution :

    


      fs.writeFileSync(&#x27;temp.mp4&#x27;, file.buffer);&#xA;&#xA;    // Resize the temporary file using ffmpeg&#xA;    ffmpeg(&#x27;temp.mp4&#x27;) // here I tried pass file.buffer as readable stream,it receives paths only &#xA;      .format(&#x27;mp4&#x27;)&#xA;      .size(&#x27;50%&#x27;)&#xA;      .save(&#x27;resized.mp4&#x27;)&#xA;      .on(&#x27;end&#x27;, async () => {&#xA;        // Upload the resized file to Firebase&#xA;        const resizedFileStream = bucket.file(`video/${uniqueId}`).createWriteStream();&#xA;        fs.createReadStream(&#x27;resized.mp4&#x27;).pipe(resizedFileStream);&#xA;&#xA;        await new Promise<void>((resolve, reject) => {&#xA;          resizedFileStream&#xA;            .on(&#x27;finish&#x27;, () => {&#xA;              // Remove the local files after they have been uploaded&#xA;              fs.unlinkSync(&#x27;temp.mp4&#x27;);&#xA;              fs.unlinkSync(&#x27;resized.mp4&#x27;);&#xA;              resolve();&#xA;            })&#xA;            .on(&#x27;error&#x27;, reject);&#xA;        });&#xA;&#xA;        // Get the URL of the uploaded resized version&#xA;        const resizedFile = bucket.file(`video/${uniqueId}`);&#xA;        const url = await resizedFile.getSignedUrl({&#xA;          action: &#x27;read&#x27;,&#xA;          expires: &#x27;03-17-2025&#x27;, // Change this to a reasonable expiration date&#xA;        });&#xA;&#xA;        console.log(&#x27;Resized file uploaded successfully.&#x27;);&#xA;      })&#xA;      .on(&#x27;error&#x27;, (err) => {&#xA;        console.log(&#x27;An error occurred: &#x27; &#x2B; err.message);&#xA;      });&#xA;</void>

    &#xA;