Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

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

Autres articles (108)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, 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 (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (16409)

  • 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;

  • Problem with FFmpeg breaking when streaming the entire screen and switching tabs

    2 octobre 2024, par Ibad Ahmad

    I'm working on a screen recording and streaming setup where the user records their entire screen and streams it to Twitch. The setup works fine initially, but when I switch tabs during recording, the stream breaks on the backend, and I get the following FFmpeg errors :

    &#xA;

    FFmpeg STDERR: [matroska,webm @ 0x7f9dcb904580] EBML header parsing failed&#xA;[in#0 @ 0x7f9dcb904380] Error opening input: Invalid data found when processing input&#xA;Error opening input file -.&#xA;Error opening input files: Invalid data found when processing input&#xA;

    &#xA;

    My frontend code captures the screen and microphone and streams it via a WebSocket to the backend, where FFmpeg processes the stream. Below is my relevant frontend code :

    &#xA;

    const startRecording = async () => {&#xA;    try {&#xA;        const screenStream = await navigator.mediaDevices.getDisplayMedia({&#xA;            preferCurrentTab: true,&#xA;            systemAudio: &#x27;include&#x27;,&#xA;            surfaceSwitching: &#x27;include&#x27;,&#xA;            monitorTypeSurfaces: &#x27;include&#x27;,&#xA;            video: {&#xA;                displaySurface: &#x27;browser&#x27;,&#xA;                height: 720,&#xA;                width: 1280,&#xA;                frameRate: { ideal: 24, max: 30 },&#xA;            },&#xA;        });&#xA;&#xA;        screenStream.getVideoTracks()[0].onended = () => {&#xA;            console.log(&#x27;Screen sharing ended. Stopping the recorder.&#x27;);&#xA;            stopRecording();&#xA;        };&#xA;&#xA;        const micStream = await navigator.mediaDevices.getUserMedia({&#xA;            audio: true,&#xA;        });&#xA;&#xA;        const combinedStream = new MediaStream([&#xA;            ...screenStream.getVideoTracks(),&#xA;            ...micStream.getAudioTracks(),&#xA;        ]);&#xA;&#xA;        const recorder = new MediaRecorder(combinedStream, {&#xA;            mimeType: &#x27;video/webm; codecs=vp8,opus&#x27;,&#xA;            videoBitsPerSecond: 3 * 1024 * 1024,&#xA;        });&#xA;&#xA;        const timeslice = 1000;&#xA;&#xA;        recorder.ondataavailable = async (event) => {&#xA;            if (socket?.current?.connected &amp;&amp; event.data.size > 0) {&#xA;                console.log(&#x27;Sending chunk data:&#x27;, socket.current.id);&#xA;                socket?.current.send(event.data);&#xA;                recordedChunks.current.push(event.data);&#xA;            } else if (!socket?.current?.connected) {&#xA;                handleSocketDisconnection();&#xA;            }&#xA;        };&#xA;&#xA;        mediaRecorder.current = recorder;&#xA;        recorder.start(timeslice);&#xA;        setIsRecording(true);&#xA;    } catch (error) {&#xA;        console.log(&#x27;Error starting screen recording:&#x27;, error);&#xA;        toast.error(&#x27;Failed to start screen recording: &#x27; &#x2B; error);&#xA;    }&#xA;};&#xA;&#xA;const stopRecording = () => {&#xA;    if (socket?.current &amp;&amp; mediaRecorder) {&#xA;        mediaRecorder?.current?.stop();&#xA;        socket.current.close();&#xA;        setIsRecording(false);&#xA;        downloadRecordedVideo();&#xA;    }&#xA;};&#xA;&#xA;

    &#xA;

    And here’s my backend code with FFmpeg settings for Twitch streaming :

    &#xA;

    const inputSettings = [&#xA;    &#x27;-f&#x27;, &#x27;webm&#x27;, &#x27;-i&#x27;, &#x27;-&#x27;, &#x27;-v&#x27;, &#x27;error&#x27;, &#x27;-analyzeduration&#x27;, &#x27;1000000&#x27;, &#x27;-probesize&#x27;, &#x27;5000000&#x27;,&#xA;];&#xA;&#xA;const twitchSettings = (twitch) => {&#xA;    return [&#xA;        &#x27;-c:v&#x27;, &#x27;libx264&#x27;, &#x27;-preset&#x27;, &#x27;veryfast&#x27;, &#x27;-tune&#x27;, &#x27;zerolatency&#x27;,&#xA;        &#x27;-g&#x27;, &#x27;60&#x27;, &#x27;-b:v&#x27;, &#x27;2500k&#x27;, &#x27;-maxrate&#x27;, &#x27;3000k&#x27;, &#x27;-bufsize&#x27;, &#x27;8000k&#x27;,&#xA;        &#x27;-r&#x27;, &#x27;30&#x27;, &#x27;-vf&#x27;, &#x27;tpad=stop_mode=clone:stop_duration=2&#x27;,&#xA;        &#x27;-c:a&#x27;, &#x27;aac&#x27;, &#x27;-ar&#x27;, &#x27;44100&#x27;, &#x27;-b:a&#x27;, &#x27;96k&#x27;,&#xA;        &#x27;-use_wallclock_as_timestamps&#x27;, &#x27;1&#x27;, &#x27;-async&#x27;, &#x27;1&#x27;,&#xA;        &#x27;-err_detect&#x27;, &#x27;ignore_err&#x27;, &#x27;-reconnect&#x27;, &#x27;1&#x27;,&#xA;        &#x27;-reconnect_streamed&#x27;, &#x27;1&#x27;, &#x27;-reconnect_delay_max&#x27;, &#x27;5&#x27;,&#xA;        &#x27;-y&#x27;, &#x27;-f&#x27;, &#x27;flv&#x27;, twitch,&#xA;    ];&#xA;};&#xA;&#xA;

    &#xA;

    Problem : When switching tabs during screen sharing, it seems like the frame rate drops or the stream gets interrupted, leading to FFmpeg errors like EBML header parsing failed and Invalid data found when processing input. I suspect this happens because the browser deprioritizes resources when the tab is not active, which might lead to corrupt chunks being sent to FFmpeg.

    &#xA;

    Questions :

    &#xA;

      &#xA;
    1. Could switching tabs during screen capture be causing the issue by disrupting the frame rate or dropping frames ?
    2. &#xA;

    3. Is there a way to ensure FFmpeg doesn’t break due to these interruptions ?
    4. &#xA;

    5. Any suggestions on handling the stream more reliably when switching tabs or optimizing the FFmpeg setup for this scenario ?
    6. &#xA;

    &#xA;

    I tried adjusting the bitrate, frame rate, and buffer size but still experienced the same issue. I'm trying to figure out if the issue is related to how browsers handle screen capture when tab switching or something specific with FFmpeg handling the video stream.

    &#xA;

    Any insights would be greatly appreciated.&#xA;Thanks in advance !

    &#xA;

  • Try to concatenate videos using FFmpeg Package. My videos concatenate correctly but those that i record from fornt camera rotate 90' in concatenate

    24 avril 2024, par Ahmad Akram

    Here is my code where I pass a list of image paths that concatenate. I am facing an issue with the front camera video. When concatenated completely some videos rotate 90 degrees.

    &#xA;

    Future<void> mergeVideos(List<string> videoPaths) async {&#xA;    VideoHelper.showInSnackBar(&#x27;Videos merged Start&#x27;, context);&#xA;    String outputPath = await VideoHelper.generateOutputPath();&#xA;    FlutterFFmpeg flutterFFmpeg = FlutterFFmpeg();&#xA;&#xA;    // Create a text file containing the paths of the videos to concatenate&#xA;    String fileListPath =&#xA;        &#x27;${(await getTemporaryDirectory()).path}/fileList.txt&#x27;;&#xA;    File fileList = File(fileListPath);&#xA;    await fileList&#xA;        .writeAsString(videoPaths.map((path) => &#x27;file \&#x27;$path\&#x27;&#x27;).join(&#x27;\n&#x27;));&#xA;&#xA;    // Run FFmpeg command to concatenate videos&#xA;    // String command = &#x27;-f concat -safe 0 -i $fileListPath -c copy $outputPath&#x27;;&#xA;&#xA;    String command =&#xA;        &#x27;-f concat -safe 0 -i $fileListPath -vf "transpose=1" -c:a copy $outputPath&#x27;;&#xA;&#xA;    VideoHelper.showInSnackBar(&#x27;command Start&#x27;, context);&#xA;    await flutterFFmpeg.execute(command).then((value) {&#xA;      if (value == 0) {&#xA;        print("Output Path : $outputPath");&#xA;        VideoHelper.showInSnackBar(&#x27;Videos merged successfully&#x27;, context);&#xA;        Navigator.push(&#xA;            context,&#xA;            MaterialPageRoute(&#xA;                builder: (context) => VideoPlayerScreen(&#xA;                      videoFile: XFile(outputPath),&#xA;                    )));&#xA;      } else {&#xA;        VideoHelper.showInSnackBar(&#xA;            &#x27;Error merging videos  ::::: returnCode=== $value &#x27;, context);&#xA;      }&#xA;    });&#xA;  }&#xA;</string></void>

    &#xA;