Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (47)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

Sur d’autres sites (9125)

  • Fluent-ffmpeg and complex filter in Electron (node)

    9 juillet 2016, par Matt Sergej Rinc

    I want to use fluent-ffmpeg module to call ffmpeg with complex filter from Electron but have no success. The error ’[AVFilterGraph @ 0xb8.......] No such filter " Error initalizing complex filters . Invalid argument’ is the same as in this question Error : Running FFmpeg command in Android ,splitting command in array not working but the context is different.

    What is needed ?
    Run this ffmpeg command using fluent-ffmpeg :

    ffmpeg -i safework-background-0.mp4 -i image1.png -i image2.png -i
    image3.png -filter_complex "[0:v][1:v]
    overlay=1:1:enable=’between(t,5,8.5)’ [tmp] ; [tmp][2:v]
    overlay=1:1:enable=’between(t,8.5,12)’ [tmp] ; [tmp][3:v]
    overlay=1:1:enable=’between(t,12,15)’" test-video-safework3.mp4

    It uses a complex filter to overlay three images on a video in sequence and exports a new video.

    What doesn’t work ?
    Obviously fluent-ffmpeg chokes with required quotes for complex filter, that is my conclusion (and is the same as for the Android variant question above).

    What works without fluent-ffmpeg in Electron ?
    As you can guess I have to resort to calling ffmpeg directly. To help others, the following command, with input and output video filenames parametrized, translates to Electron as :

     var spawn = require('child_process').spawn
     var fargs = ['-y', '-i', sourceDir.path() + '/' + inVideoName, '-i', tempDir.path() + '/' + 'image1.png',
     '-i', tempDir.path() + '/' + 'image2.png', '-i', tempDir.path() + '/' + 'image3.png',
     '-filter_complex', '[0:v][1:v]overlay=1:1:enable=\'between(t,5,8.5)\'[tmp];' +
     '[tmp][2:v]overlay=1:1:enable=\'between(t,8.5,12)\'[tmp];[tmp][3:v]' +
     'overlay=1:1:enable=\'between(t,12,15)\'', targetDir.path() + '/' + outVideoName]
     var ffmpeg = spawn(ffmpegc, fargs, { cwd:jetpack.cwd(app.getPath('home')).path() })
    // some code ommitted
     ffmpeg.on('close', (code) => {
       console.log(`child process exited with code ${code}`)
       webContents.send('notify-user-reply', 'Video processing done.')
     })

    The above command already has removed spaces between various filters (in complex filter) for each image or it would also choke.

    I would really love to use fluent-ffmpeg in Electron, not just for the convenience of calling ffmpeg more elegantly but also for some additional features like easy progress reporting.

  • How to fetch from Node Js once

    6 septembre 2023, par Offeyicial

    I want to trim a video if it is longer than 10 minutes and fetch the trimmed video but it happens to work in an infinite loop, which is what i am trying to stop. i just dont know how

    


      

    1. Initially, the video processing is triggered when a video longer than 10 minutes is selected.

      


    2. 


    3. While the video processing is ongoing, the user interface (UI) code continues to execute, and if the video selection remains the same, it might trigger the processing again

      


    4. 


    5. This leads to multiple instances of FFmpeg processing the same video file concurrently, creating the infinite loop behavior.

      


    6. 


    


    function previewReels(event) {
                const videos = document.getElementById('videos').files;
                const previewItems = document.querySelector('.preview-items');
                const buttons = document.querySelector('.buttons');

                // Display videos
                for (let i = 0; i < videos.length; i++) {
                    // const videoElement = document.createElement('video');
                    // videoElement.controls = true;
                    // videoElement.autoplay = true;
                    const previewItem = document.createElement('div');
                    previewItem.className = 'preview-item';
                    previewItems.appendChild(previewItem);

                    const formData = new FormData();

                    const videoInput = document.getElementById('videos');

                    if (videoInput.files.length > 0) {
                        const videoFile = videoInput.files[0];
                        console.log('VideoFile:', videoFile);
                        console.log('Uploaded file mimetype:', videoFile.type);

                        formData.append('Video', videoFile);

                        const videoElement = document.createElement('video');
                        videoElement.src = URL.createObjectURL(videoFile);

                        videoElement.addEventListener('loadedmetadata', () => {
                            const videoDuration = videoElement.duration;
                            const videoinmins = videoDuration / 60;
                            console.log('Video Duration:', videoinmins);

                            if (videoDuration > 600) {
                                videoElement.style.display = "none";
                                const loader = document.createElement('img');
                                loader.src = 'icons/internet.gif';
                                loader.classList.add('loader');
                                previewItems.style.backgroundColor = "white";
                                previewItem.appendChild(loader);

                                fetch('http://localhost:8888/trimVideo', {
                                        method: 'POST',
                                        body: formData,
                                    })
                                    .then((response) => {
                                        if (!response.ok) {
                                            throw new Error('Error fetching trimmed video data.');
                                        }
                                        return response.blob(); // Get the video data as a Blob
                                    })
                                    .then((videoBlob) => {
                                        previewItem.removeChild(loader);
                                        videoElement.style.display = "block";
                                        loader.style.display = "none";
                                        buttons.style.display = "block";
                                        const trimmedVideoURL = URL.createObjectURL(videoBlob);
                                        videoElement.src = trimmedVideoURL;
                                        previewItem.appendChild(videoElement);
                                        previewItem.style.backgroundColor = "#333";
                                    })
                                    .catch((error) => {
                                        console.error(error);
                                    });
                            } else {
                                videoElement.controls = true;
                                buttons.style.display = "block";
                                previewItems.style.backgroundColor = "#333";
                                previewItem.appendChild(videoElement);
                            }
                        });
            }

            // Listen for file selection change
            document.getElementById('videos').addEventListener('change', previewReels);


    


    and for this server side

    


    app.post("/trimVideo", (req, res) => {
  console.log("Received a POST request to /trim-video");
  res.header("Access-Control-Allow-Origin", "*");
  res.header(
    "Access-Control-Allow-Headers",
    "Origin, X-Requested-With, Content-Type, Accept"
  );
  // Access the video file and log its details
  const videoFile = req.files.Video;
  console.log("Received video file:", videoFile);
  console.log(" - Name:", videoFile.name);
  console.log(" - Type:", videoFile.mimetype);
  console.log(" - Size:", videoFile.size, "bytes");
  console.log(" - Data length:", videoFile.data.length);

  if (!req.files || !req.files.Video) {
    console.log("not working");
    return res.status(400).send("No video file uploaded.");
  }

  console.log("started");

  if (videoFile.mimetype.startsWith("video/")) {
    const progressFilePath = 'progress.txt';
    fs.writeFileSync(videoFile.name, videoFile.data);
    const inputFormat = videoFile.name.split(".").pop().toLowerCase();
    console.log("Trimming video...");
    console.log(inputFormat);
    console.log(videoFile.data);
    ffmpeg()
      .input(videoFile.name)
      .inputFormat(inputFormat)
      .outputOptions("-t 600")
      .outputFormat("ismv")
      .on("end", () => {
        console.log("Video trimming completed.");

        // Read the trimmed video data from the temporary file
        const trimmedVideoBuffer = fs.readFileSync(videoFile.name);

        // Delete the temporary file
        fs.unlinkSync(videoFile.name);

        res.setHeader("Content-Type", "Video/ismv");
        res.setHeader("Content-Length", trimmedVideoBuffer.length);
        res.send(trimmedVideoBuffer);
      })
      .on("error", (err, stdout, stderr) => {
        console.error("Error trimming video:", err);
        console.error("FFmpeg stdout:", stdout);
        console.error("FFmpeg stderr:", stderr);
        res.status(500).send(`Error trimming the video: ${err.message}`);
      })
      .on("progress", (progress) => {
        console.log("trimming-progress", progress);
      })
      .save(progressFilePath);
  } else {
    res.status(400).send("Invalid video file format.");
  }
});


    


    


  • Save video to disk from WebRTC MediaStream in Node

    27 novembre 2020, par SAGBO Aimé

    I'm building an app where the user can connect to the server through a WebRTC (I'm using simple-peer library both server-side and client-side to set the peer-to-peer connection).
Once the client and the server are connected, the client app stream the user camera and micro to the server.

    


    Now, I want to save the streamed data to the filesystem server-side as an MP4 video file.

    


    I hear about ffmpeg and fluent-ffmpeg to achieve this but i don't know how to use them.

    


      

    • Server side code to set up the peer connection
    • 


    


    const Peer = require("simple-peer");
const wrtc = require("wrtc");

const peer = new Peer({ initiator: false, wrtc: wrtc, trickle: false });

peer.on("error", (err: any) => console.log("error", err));

  peer.on("signal", (data: any) => {
    if (data.type === "offer" || data.type === "answer")
      dispatchMessage(JSON.stringify(data));
    // if (data.renegotiate || data.transceiverRequest) return;
  });

  peer.on("connect", () => {
    console.log("CONNECTED");
    peer.send(JSON.stringify("HELLO DEER PEER FROM SERVER"));
  });

  peer.on("data", (data: any) => {
    console.log("data: ", data);
  });

  peer.on("stream", (stream: MediaStream) => {
    console.log("-------Stream received", stream);
  });

  peer.on("track", (track: MediaStreamTrack) => {
    console.log("-------trackEvent:", track);
  });


    


      

    • Client-side code
    • 


    


    const stream = await window.navigator.mediaDevices.getUserMedia({
    video: { width: { ideal: 4096 }, height: { ideal: 2160 }},
    audio: true,
});

const p = new SimplePeer({
    initiator: isInitiator,  
    trickle: false  
});

stream.getTracks().forEach(track => p.addTrack(
    track,  
    stream  
));

// Here I set up the listeners for the peer connection