Recherche avancée

Médias (1)

Mot : - Tags -/intégration

Autres articles (106)

  • Qualité du média après traitement

    21 juin 2013, par

    Le bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
    Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

Sur d’autres sites (15783)

  • FFMPEG ERROR on streaming video generated from MediaRecorder API on RTMP url

    20 février 2024, par Prince Mishra

    Ref : https://www.mux.com/blog/the-state-of-going-live-from-a-browser

    


    The above blog states my problem in detail and presented a solution also.
I am trying to implement the solution which is using socketio

    


    Here is the description of the problem :

    


    I want to capture the video and audio from the browser using

    


    navigator.mediaDevices
    .getUserMedia({ video: true, audio: true })


    


    and i am using the

    


    const options = {
    mimeType: "video/webm;codecs=vp8",
};
const mediaRecorder = new MediaRecorder(stream, options);


    


    to record the video chunk by chunk from the stream given by getusermedia and then using the socket io to send the video to the backend. Where I am using the ffmpeg to stream the chunks on rtmp url.

    


    I am using the following ffmpeg commands :

    


    const { spawn } = require('child_process');

const ffmpegProcess = spawn('ffmpeg', [
    '-i', 'pipe:0',
    '-c:v', 'libx264',
    '-preset', 'veryfast',
    '-tune', 'zerolatency',
    '-c:a', 'aac',
    '-ar', '44100',
    '-f', 'flv',
    rtmpurl
]);


    


    And I am getting the following errors :

    


    Error Image 1

    


    Error Image 2

    


    Error Image 3

    


    Can anyone help me how to fix this. I am new to FFmpeg.

    


    Here is the complete frontend and Backend code :

    


    Frontend (App.jsx) :


    


    import { useEffect } from "react";&#xA;import "./App.css";&#xA;import io from "socket.io-client";&#xA;&#xA;function App() {&#xA;  let video;&#xA;&#xA;  useEffect(() => {&#xA;    video = document.getElementById("video");&#xA;  }, []);&#xA;&#xA;  const socket = io("http://localhost:3050");&#xA;  socket.on("connect", () => {&#xA;    console.log("Connected to server");&#xA;  });&#xA;&#xA;  let stream;&#xA;  navigator.mediaDevices&#xA;    .getUserMedia({ video: true, audio: true })&#xA;    .then((strea) => {&#xA;      video.srcObject = strea;&#xA;      stream = strea;&#xA;      const options = {&#xA;        mimeType: "video/webm;codecs=vp8",&#xA;      };&#xA;      const mediaRecorder = new MediaRecorder(stream, options);&#xA;      console.log(mediaRecorder);&#xA;      let chunks = [];&#xA;&#xA;      mediaRecorder.ondataavailable = function (e) {&#xA;        chunks.push(e.data);&#xA;        console.log(e.data);&#xA;      };&#xA;      mediaRecorder.onstop = function (e) {&#xA;        const blob = new Blob(chunks, { type: "video/webm;codecs=vp8" });&#xA;        console.log("emitted");&#xA;        socket.emit("videoChunk", blob);&#xA;        chunks = [];&#xA;        // const videoURL = URL.createObjectURL(blob);&#xA;        // const a = document.createElement(&#x27;a&#x27;);&#xA;        // a.href = videoURL;&#xA;        // a.download = &#x27;video.mp4&#x27;;&#xA;        // a.click();&#xA;        window.URL.revokeObjectURL(videoURL);&#xA;      };&#xA;      mediaRecorder.start();&#xA;      setInterval(() => {&#xA;        mediaRecorder.stop();&#xA;        mediaRecorder.start();&#xA;      }, 2000);&#xA;    })&#xA;    .catch((error) => {&#xA;      console.error("Error accessing camera:", error);&#xA;    });&#xA;&#xA;  // Capture video after 10 seconds&#xA;&#xA;  return (&#xA;    &lt;>&#xA;      <video width="640" height="480" autoplay="autoplay"></video>&#xA;      <button>Capture</button>&#xA;    >&#xA;  );&#xA;}&#xA;&#xA;export default App;&#xA;

    &#xA;

    Backend Code :

    &#xA;

    const express = require(&#x27;express&#x27;);&#xA;const http = require(&#x27;http&#x27;);&#xA;const socketIo = require(&#x27;socket.io&#x27;);&#xA;const { spawn } = require(&#x27;child_process&#x27;);&#xA;&#xA;const app = express();&#xA;&#xA;const server = http.createServer(app);&#xA;const io = socketIo(server, {&#xA;    cors: {&#xA;      origin: "*",&#xA;      methods: ["GET", "POST"]&#xA;    }, maxhttpBufferSize: 1e8&#xA;  });&#xA;&#xA;  const rtmpurl = &#x27;rtmp://localhost/live/test&#x27;;&#xA;&#xA;io.on(&#x27;connection&#x27;, (socket) => {&#xA;    console.log(&#x27;A user connected&#x27;);&#xA;&#xA;    const ffmpegProcess = spawn(&#x27;ffmpeg&#x27;, [&#xA;        &#x27;-i&#x27;, &#x27;pipe:0&#x27;,&#xA;        &#x27;-c:v&#x27;, &#x27;libx264&#x27;,&#xA;        &#x27;-preset&#x27;, &#x27;veryfast&#x27;,&#xA;        &#x27;-tune&#x27;, &#x27;zerolatency&#x27;,&#xA;        &#x27;-c:a&#x27;, &#x27;aac&#x27;,&#xA;        &#x27;-ar&#x27;, &#x27;44100&#x27;,&#xA;        &#x27;-f&#x27;, &#x27;flv&#x27;,&#xA;        rtmpurl&#xA;    ]);&#xA;&#xA;&#xA;    ffmpegProcess.stdin.on(&#x27;error&#x27;, (e) => {&#xA;        console.log(e);&#xA;    });&#xA;    &#xA;    ffmpegProcess.stderr.on(&#x27;data&#x27;, (data) => {&#xA;        console.log(data.toString());&#xA;    });&#xA;&#xA;    ffmpegProcess.on(&#x27;close&#x27;, (code) => {&#xA;        console.log(`child process exited with code ${code}`);&#xA;    });&#xA;&#xA;&#xA;    socket.on(&#x27;videoChunk&#x27;, (chunk) => {&#xA;        console.log(chunk)&#xA;        ffmpegProcess.stdin.write(chunk);&#xA;&#xA;    });&#xA;&#xA;    socket.on(&#x27;disconnect&#x27;, () => {&#xA;        console.log(&#x27;User disconnected&#x27;);&#xA;        ffmpegProcess.stdin.end();&#xA;    });&#xA;});&#xA;&#xA;const PORT = process.env.PORT || 3050;&#xA;&#xA;app.get(&#x27;/test&#x27;, (req, res) => {&#xA;    res.send(&#x27;Hello from /test route!&#x27;);&#xA;});&#xA;&#xA;&#xA;server.listen(PORT, () => {&#xA;    console.log(`Server is running on port ${PORT}`);&#xA;});&#xA;

    &#xA;

  • Unable to read video streams on FFMPEG and send it to youTube RTMP server

    29 août 2024, par Rahul Bundele

    I'm trying to send two video stream from browser as array buffer (webcam and screen share video) to server via Web RTC data channels and want ffmpeg to add webcam as overlay on screen share video and send it to youtube RTMP server, the RTC connections are established and server does receives buffer , Im getting error in Ffmpeg..error is at bottom , any tips on to add overlay and send it to youtube RTMP server would be appreciated.

    &#xA;

    Client.js

    &#xA;

    `&#xA;const webCamStream = await navigator.mediaDevices.getUserMedia( video : true ,audio:true ) ;&#xA;const screenStream = await navigator.mediaDevices.getDisplayMedia( video : true ) ;

    &#xA;

    const webcamRecorder = new MediaRecorder(webCamStream, { mimeType: &#x27;video/webm&#x27; });&#xA;webcamRecorder.ondataavailable = (event) => {&#xA;    if (event.data.size > 0 &amp;&amp; webcamDataChannel.readyState === &#x27;open&#x27;) {&#xA;        const reader = new FileReader();&#xA;        reader.onload = function () {&#xA;            const arrayBuffer = this.result;&#xA;            webcamDataChannel.send(arrayBuffer);&#xA;        };&#xA;        reader.readAsArrayBuffer(event.data);&#xA;    }&#xA;};&#xA;webcamRecorder.start(100);  // Adjust the interval as needed&#xA;&#xA;// Send screen share stream data&#xA;const screenRecorder = new MediaRecorder(screenStream, { mimeType: &#x27;video/webm&#x27; });&#xA;screenRecorder.ondataavailable = (event) => {&#xA;    if (event.data.size > 0 &amp;&amp; screenDataChannel.readyState === &#x27;open&#x27;) {&#xA;        const reader = new FileReader();&#xA;        reader.onload = function () {&#xA;            const arrayBuffer = this.result;&#xA;            screenDataChannel.send(arrayBuffer);&#xA;        };&#xA;        reader.readAsArrayBuffer(event.data);&#xA;    }&#xA;};&#xA;screenRecorder.start(100); &#xA;

    &#xA;

    `

    &#xA;

    Server.js

    &#xA;

    const youtubeRTMP = &#x27;rtmp://a.rtmp.youtube.com/live2/youtube key&#x27;;&#xA;&#xA;// Create PassThrough streams for webcam and screen&#xA;const webcamStream = new PassThrough();&#xA;const screenStream = new PassThrough();&#xA;&#xA;// FFmpeg arguments for processing live streams&#xA;const ffmpegArgs = [&#xA;  &#x27;-re&#x27;,&#xA;  &#x27;-i&#x27;, &#x27;pipe:3&#x27;,                  // Webcam input via pipe:3&#xA;  &#x27;-i&#x27;, &#x27;pipe:4&#x27;,                  // Screen share input via pipe:4&#xA;  &#x27;-filter_complex&#x27;,               // Complex filter for overlay&#xA;  &#x27;[0:v]scale=320:240[overlay];[1:v][overlay]overlay=10:10[out]&#x27;,&#xA;  &#x27;-map&#x27;, &#x27;[out]&#x27;,                 // Map the output video stream&#xA;  &#x27;-c:v&#x27;, &#x27;libx264&#x27;,               // Use H.264 codec for video&#xA;  &#x27;-preset&#x27;, &#x27;ultrafast&#x27;,          // Use ultrafast preset for low latency&#xA;  &#x27;-crf&#x27;, &#x27;25&#x27;,                    // Set CRF for quality/size balance&#xA;  &#x27;-pix_fmt&#x27;, &#x27;yuv420p&#x27;,           // Pixel format for compatibility&#xA;  &#x27;-c:a&#x27;, &#x27;aac&#x27;,                   // Use AAC codec for audio&#xA;  &#x27;-b:a&#x27;, &#x27;128k&#x27;,                  // Set audio bitrate&#xA;  &#x27;-f&#x27;, &#x27;flv&#x27;,                     // Output format (FLV for RTMP)&#xA;  youtubeRTMP                      // Output to YouTube RTMP server&#xA;];&#xA;&#xA;// Spawn the FFmpeg process&#xA;const ffmpegProcess = spawn(&#x27;ffmpeg&#x27;, ffmpegArgs, {&#xA;  stdio: [&#x27;pipe&#x27;, &#x27;pipe&#x27;, &#x27;pipe&#x27;, &#x27;pipe&#x27;, &#x27;pipe&#x27;]&#xA;});&#xA;&#xA;// Pipe the PassThrough streams into FFmpeg&#xA;webcamStream.pipe(ffmpegProcess.stdio[3]);&#xA;screenStream.pipe(ffmpegProcess.stdio[4]);&#xA;&#xA;ffmpegProcess.on(&#x27;close&#x27;, code => {&#xA;  console.log(`FFmpeg process exited with code ${code}`);&#xA;});&#xA;&#xA;ffmpegProcess.on(&#x27;error&#x27;, error => {&#xA;  console.error(`FFmpeg error: ${error.message}`);&#xA;});&#xA;&#xA;const handleIncomingData = (data, stream) => {&#xA;  const buffer = Buffer.from(data);&#xA;  stream.write(buffer);&#xA;};&#xA;

    &#xA;

    the server gets the video buffer via webrtc data channels

    &#xA;

    pc.ondatachannel = event => {&#xA;        const dataChannel = event.channel;&#xA;        pc.dc = event.channel;&#xA;        pc.dc.onmessage = event => {&#xA;            // Spawn the FFmpeg process&#xA;            // console.log(&#x27;Message from client:&#x27;, event.data);&#xA;            const data = event.data;&#xA;&#xA;            if (dataChannel.label === &#x27;webcam&#x27;) {&#xA;            handleIncomingData(data, webcamStream);&#xA;            } else if (dataChannel.label === &#x27;screen&#x27;) {&#xA;            handleIncomingData(data, screenStream);&#xA;            }&#xA;          &#xA;        };&#xA;        pc.dc.onopen = e=>{&#xA;            // recHead.innerText = "Waiting for user to send files"&#xA;            console.log("channel opened!")&#xA;        }&#xA;    };&#xA;

    &#xA;

    Im getting this error in ffmpeg

    &#xA;

    [in#0 @ 0000020e585a1b40] Error opening input: Bad file descriptor&#xA;Error opening input file pipe:3.&#xA;Error opening input files: Bad file descriptor&#xA;

    &#xA;

  • Issue with creating Video files from Binary files

    22 septembre 2022, par user20057686

    We have a bunch of binary files that represent Video data.&#xA;This is how the binary files were created :

    &#xA;

      &#xA;
    1. Used MediaRecorder from a React application to capture the browser window.&#xA;To capture the screen stream we used (Navigator.)MediaDevices.getDisplayMedia() API
    2. &#xA;

    3. Each video is recorded for 1-second duration
    4. &#xA;

    5. This data is then encoded with base64 and sent through a websocket. The server decodes the base64 string and stores the binary data in a file (without any extension)
    6. &#xA;

    &#xA;

    So we now have a bunch of binary files each containing 1 second worth of video data.

    &#xA;

    The issue is, we are not able to convert all the binary files back to a single video.

    &#xA;

      &#xA;
    1. We tried using ffmpeg

      &#xA;

      copy /b * merged.

      &#xA;

      ffmpeg -i merged merged.mp4

      &#xA;

    2. &#xA;

    &#xA;

    Basically first merging all the binary files and converting to mp4. It didn't work. The resulting video duration is not equal to the (number_of_files) in seconds.

    &#xA;

      &#xA;
    1. We also tried converting individual chunks with ffmpeg but we get the below error :

      &#xA;

      [h264 @ 000001522dc74b80] [error] non-existing PPS 0 referenced&#xA;[h264 @ 000001522dc74b80] [error] non-existing PPS 0 referenced&#xA;[h264 @ 000001522dc74b80] [error] decode_slice_header error&#xA;[h264 @ 000001522dc74b80] [error] no frame !&#xA;I can provide the complete logs if needed.

      &#xA;

    2. &#xA;

    3. Next thing we tried was to use MoviePy library in Python. We programmatically concatenated the files and saved them as WebM and imported it into MoviePy as a Video.

      &#xA;

    4. &#xA;

    &#xA;

    In all the above approaches, we couldn't get the full video.

    &#xA;