Recherche avancée

Médias (91)

Autres articles (42)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (6351)

  • mpeg-dash live streaming can't fetch chunks

    27 juin 2020, par user1902653

    I'm trying to create a live stream of mpeg-dash with ffmpeg.

    


    I'm streaming with python the frames to the ffmpeg process.

    


    This is the current command I'm using for creating the mpeg-dash manifest and m4s files :

    


    ffmpeg -re -f rawvideo -pix_fmt bgr24 -video_size 640x360 -i - -vcodec libx264 -preset ultrafast -tune zerolatency -f dash -window_size 10 -use_template 1 -use_timeline 0 -live 1 /srv/http/dash/stream.mpd


    


    I'm using nginx as a server for now and I've created a simple index.html using shaka player, but the problem is I couldn't get it to load and play more then the first chunk. (checked with dev-tools in chrome in the network tab)

    


    This is how I'm using shaka player right now :

    


    

    

    &#xA;    &#xA;        <code class="echappe-js">&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.1.4/shaka-player.compiled.js&quot;&gt;&lt;/script&gt;&#xA;        &lt;script&gt;&amp;#xA;            var manifestUri = &amp;#x27;stream.mpd&amp;#x27;;&amp;#xA;            function initApp() {&amp;#xA;                shaka.polyfill.installAll();&amp;#xA;                if (shaka.Player.isBrowserSupported()) {&amp;#xA;                    initPlayer();&amp;#xA;                } else {&amp;#xA;                    console.error(&amp;#x27;Browser not supported!&amp;#x27;);&amp;#xA;                }&amp;#xA;            }&amp;#xA;            function initPlayer() {&amp;#xA;                var video = document.getElementById(&amp;#x27;video&amp;#x27;);&amp;#xA;                var player = new shaka.Player(video);&amp;#xA;                window.player = player;&amp;#xA;                player.addEventListener(&amp;#x27;error&amp;#x27;, onErrorEvent);&amp;#xA;                player.load(manifestUri).then(function() {&amp;#xA;                    console.log(&amp;#x27;The video has now been loaded!&amp;#x27;);&amp;#xA;                }).catch(onError);&amp;#xA;            }&amp;#xA;            function onErrorEvent(event) {&amp;#xA;                onError(event.detail);&amp;#xA;            }&amp;#xA;            function onError(error) {&amp;#xA;                console.error(&amp;#x27;Error code&amp;#x27;, error.code, &amp;#x27;object&amp;#x27;, error);&amp;#xA;            }&amp;#xA;            document.addEventListener(&amp;#x27;DOMContentLoaded&amp;#x27;, initApp);&amp;#xA;        &lt;/script&gt;&#xA;    &#xA;    &#xA;        &#xA;    &#xA;

    &#xD;&#xA;

    &#xD;&#xA;

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

    For some reason the stream is only playing the first chunk and never requesting for the next chunk. How can I make it load the next chunks ?

    &#xA;

    When tried using dash.js I couldn't get it to load even the first chunk.

    &#xA;

    Thanks in advance.

    &#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;

  • ffmpeg-static Trimming a merging audio and viddeo having a freeza at the first second

    13 avril 2023, par sol

    I am using FFmpeg-static in my express server to merge audio and video coming from Youtube Readable Stream then Trim. seems ok and working but im getting an error

    &#xA;

    ffmpeg video input stream error : Error : write EPIPE&#xA;ffmpeg audio input stream error : Error : write EPIPE

    &#xA;

    then the triiming process has a glitch like freeze on the first second of the video output

    &#xA;

    here is my code

    &#xA;

    res.setHeader("Content-Disposition", attachment;  filename="${encodeURIComponent(info.videoDetails.title)}.mp4") ;

    &#xA;

      let ffmpegArgs = [&#xA;      &#x27;-y&#x27;, // Overwrite output file without asking&#xA;      &#x27;-i&#x27;, &#x27;pipe:3&#x27;, // Read video stream from pipe 3&#xA;      &#x27;-i&#x27;, &#x27;pipe:4&#x27;,&#xA;      &#x27;-map&#x27;, &#x27;0:v&#x27;,&#xA;      &#x27;-map&#x27;, &#x27;1:a&#x27;,&#xA;      &#x27;-c:v&#x27;, &#x27;copy&#x27;,&#xA;      &#x27;-preset&#x27;, &#x27;ultrafast&#x27;,&#xA;      &#x27;-b:v&#x27;, &#x27;5000k&#x27;,&#xA;      &#x27;-maxrate&#x27;, &#x27;5000k&#x27;,&#xA;      &#x27;-bufsize&#x27;, &#x27;10000k&#x27;,&#xA;      &#x27;-c:a&#x27;, &#x27;libmp3lame&#x27;,&#xA;      &#x27;-crf&#x27;, &#x27;18&#x27;,&#xA;      &#x27;-preset&#x27;, &#x27;veryfast&#x27;,&#xA;      &#x27;-movflags&#x27;, &#x27;frag_keyframe&#x2B;empty_moov&#x27;,&#xA;      &#x27;-f&#x27;, &#x27;mp4&#x27;,&#xA;      &#x27;-loglevel&#x27;, &#x27;error&#x27;&#xA;  ];&#xA;&#xA;  if (startTime &amp;&amp; endTime) {&#xA;      ffmpegArgs = ffmpegArgs.concat([&#x27;-ss&#x27;, startTime, &#x27;-to&#x27;, endTime]); // Duration of the trimmed video&#xA;  }&#xA;&#xA;  ffmpegArgs.push(&#x27;-&#x27;);&#xA;&#xA;  let video = ytdl(url, { filter: &#x27;videoonly&#x27;, format: selectedFormat , highWaterMark: 1 &lt;&lt; 25 })&#xA;  let audio = ytdl(url, { filter: &#x27;audioonly&#x27;, quality: &#x27;highestaudio&#x27;, highWaterMark: 1 &lt;&lt; 25  });&#xA;  const ffmpegProcess = cp.spawn(ffmpeg, ffmpegArgs, {&#xA;      stdio: [&#x27;pipe&#x27;, &#x27;pipe&#x27;, &#x27;pipe&#x27;, &#x27;pipe&#x27;, &#x27;pipe&#x27;],&#xA;  });&#xA;&#xA;  video.pipe(ffmpegProcess.stdio[3]); // Video stream to stdin (fd 3)&#xA;  audio.pipe(ffmpegProcess.stdio[4]);&#xA;      // Output the resulting merged and trimmed video to a file&#xA;      ffmpegProcess.stdio[1].pipe(res);&#xA;&#xA;      // Handle the close event of the ffmpeg process&#xA;      ffmpegProcess.on(&#x27;close&#x27;, (code) => {&#xA;          if (code !== 0) {&#xA;            console.error(`ffmpeg process exited with code ${code}`);&#xA;          } else {&#xA;            console.log(&#x27;ffmpeg process completed successfully&#x27;);&#xA;            downloadedVideos.push({&#xA;              title: info.videoDetails.title,&#xA;              url: url,&#xA;              format: format&#xA;            });&#xA;          }&#xA;        });&#xA;

    &#xA;

    to the trim process i tried to move the -ss and -to to different lines but the freeze issue is still there

    &#xA;

    i did try to add and error handling event but the output error is still the same error : write EPIPE

    &#xA;

      // Pipe the video and audio streams to the ffmpeg process&#xA;          video.on(&#x27;error&#x27;, (err) => {&#xA;            console.error(`video stream error: ${err}`);&#xA;           });&#xA;            &#xA;          audio.on(&#x27;error&#x27;, (err) => {&#xA;            console.error(`audio stream error: ${err}`);&#xA;          });&#xA;            &#xA;          ffmpegProcess.stdio[3].on(&#x27;error&#x27;, (err)=> {&#xA;            console.error(`ffmpeg video input stream error: ${err} `);&#xA;          });&#xA;            &#xA;          ffmpegProcess.stdio[4].on(&#x27;error&#x27;, (err) => {&#xA;            console.error(`ffmpeg audio input stream error: ${err} `);&#xA;          });&#xA;

    &#xA;