Recherche avancée

Médias (91)

Autres articles (29)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • 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 (...)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

Sur d’autres sites (4411)

  • stream mp4 video with node fluent-ffmpeg

    28 février 2016, par rchristian

    I’m trying to create video stream server and client with node fluent-ffmpeg, express and ejs. And a haven’t solve this for a while.
    What I want to do is to play video beginning by certain time.
    The following codes make it with Safari browser on windows but with others it makes a loop of a few seconds or it says

    video format not supported

    server code (run.js) :

    app.get('/video', function(req, res) {

     //define file path,time to seek the beegining and set ffmpeg binary
     var pathToMovie = '../videos/test.mp4';
     var seektime = 100;
     proc.setFfmpegPath(__dirname + "/ffmpeg/ffmpeg");


     //encoding the video source
     var proc = new ffmpeg({source: pathToMovie})
            .seekInput(seektime)
            .withVideoBitrate(1024)
            .withVideoCodec('libx264')
            .withAspect('16:9')
            .withFps(24)
            .withAudioBitrate('128k')
            .withAudioCodec('libfaac')
            .toFormat('mp4');

     //pipe
            .pipe(res, {end: true});
    });

    client code (index.ejs) :

     

     
       <video>
         <source src="video/" type="video/mp4"></source>
       </video>
     

    Help please. I searched everywhere solution but I didn’t find

  • I received connection refused error while trying to stream live video through RTMP with FFMPEG

    25 septembre 2020, par Femzy

    I am working on a nodeJs app that can send camera stream to third party plartform i.e Facebook and Youtube using the RTMP protoco ;.. It works well on my localhost but once i deploy to the server, it only give me errors. The error I get is below on this content..&#xA;Here is my codes

    &#xA;

    server.js

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    const child_process = require(&#x27;child_process&#x27;); // To be used later for running FFmpeg&#xA;const express = require(&#x27;express&#x27;);&#xA;const http = require(&#x27;http&#x27;);&#xA;const WebSocketServer = require(&#x27;ws&#x27;).Server;&#xA;&#xA;const app = express();&#xA;const server = http.createServer(app).listen(4000, () => {&#xA;  console.log(&#x27;Listening...&#x27;);&#xA;});&#xA;&#xA;// Serve static files out of the www directory, where we will put our HTML page&#xA;app.use(express.static(__dirname &#x2B; &#x27;/www&#x27;));&#xA;&#xA;&#xA;const wss = new WebSocketServer({&#xA;  server: server&#xA;});&#xA;wss.on(&#x27;connection&#x27;, (ws, req) => {&#xA;  &#xA;  &#xA;  &#xA;  const rtmpUrl = &#x27;rtmp://a.rtmp.youtube.com/live2/MyStreamId&#x27;;&#xA;  console.log(&#x27;Target RTMP URL:&#x27;, rtmpUrl);&#xA;  &#xA;  // Launch FFmpeg to handle all appropriate transcoding, muxing, and RTMP.&#xA;  // If &#x27;ffmpeg&#x27; isn&#x27;t in your path, specify the full path to the ffmpeg binary.&#xA;  const ffmpeg = child_process.spawn(&#x27;ffmpeg&#x27;, [&#xA;    // Facebook requires an audio track, so we create a silent one here.&#xA;    // Remove this line, as well as `-shortest`, if you send audio from the browser.&#xA;    //&#x27;-f&#x27;, &#x27;lavfi&#x27;, &#x27;-i&#x27;, &#x27;anullsrc&#x27;,&#xA;    &#xA;    // FFmpeg will read input video from STDIN&#xA;    &#x27;-i&#x27;, &#x27;-&#x27;,&#xA;    &#xA;    // Because we&#x27;re using a generated audio source which never ends,&#xA;    // specify that we&#x27;ll stop at end of other input.  Remove this line if you&#xA;    // send audio from the browser.&#xA;    //&#x27;-shortest&#x27;,&#xA;    &#xA;    // If we&#x27;re encoding H.264 in-browser, we can set the video codec to &#x27;copy&#x27;&#xA;    // so that we don&#x27;t waste any CPU and quality with unnecessary transcoding.&#xA;    // If the browser doesn&#x27;t support H.264, set the video codec to &#x27;libx264&#x27;&#xA;    // or similar to transcode it to H.264 here on the server.&#xA;    &#x27;-vcodec&#x27;, &#x27;copy&#x27;,&#xA;    &#xA;    // AAC audio is required for Facebook Live.  No browser currently supports&#xA;    // encoding AAC, so we must transcode the audio to AAC here on the server.&#xA;    &#x27;-acodec&#x27;, &#x27;aac&#x27;,&#xA;    &#xA;    // FLV is the container format used in conjunction with RTMP&#xA;    &#x27;-f&#x27;, &#x27;flv&#x27;,&#xA;    &#xA;    // The output RTMP URL.&#xA;    // For debugging, you could set this to a filename like &#x27;test.flv&#x27;, and play&#xA;    // the resulting file with VLC.  Please also read the security considerations&#xA;    // later on in this tutorial.&#xA;    rtmpUrl &#xA;  ]);&#xA;  &#xA;  // If FFmpeg stops for any reason, close the WebSocket connection.&#xA;  ffmpeg.on(&#x27;close&#x27;, (code, signal) => {&#xA;    console.log(&#x27;FFmpeg child process closed, code &#x27; &#x2B; code &#x2B; &#x27;, signal &#x27; &#x2B; signal);&#xA;    ws.terminate();&#xA;  });&#xA;  &#xA;  // Handle STDIN pipe errors by logging to the console.&#xA;  // These errors most commonly occur when FFmpeg closes and there is still&#xA;  // data to write.  If left unhandled, the server will crash.&#xA;  ffmpeg.stdin.on(&#x27;error&#x27;, (e) => {&#xA;    console.log(&#x27;FFmpeg STDIN Error&#x27;, e);&#xA;  });&#xA;  &#xA;  // FFmpeg outputs all of its messages to STDERR.  Let&#x27;s log them to the console.&#xA;  ffmpeg.stderr.on(&#x27;data&#x27;, (data) => {&#xA;    console.log(&#x27;FFmpeg STDERR:&#x27;, data.toString());&#xA;  });&#xA;&#xA;  // When data comes in from the WebSocket, write it to FFmpeg&#x27;s STDIN.&#xA;  ws.on(&#x27;message&#x27;, (msg) => {&#xA;    console.log(&#x27;DATA&#x27;, msg);&#xA;    ffmpeg.stdin.write(msg);&#xA;  });&#xA;  &#xA;  // If the client disconnects, stop FFmpeg.&#xA;  ws.on(&#x27;close&#x27;, (e) => {&#xA;    ffmpeg.kill(&#x27;SIGINT&#x27;);&#xA;  });&#xA;  &#xA;});

    &#xD;&#xA;

    &#xD;&#xA;

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

    On the server.js file i create a websocket to receive stream data from the client side and then use FFMPEG to send the stream data over to youtube via the RTMP url

    &#xA;

    Here is my client.js code

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    const ws = new WebSocket(&#xA;             &#x27;wss://my-websocket-server.com&#x27;&#xA;&#xA;        );&#xA;         ws.addEventListener(&#x27;open&#x27;, (e) => {&#xA;             console.log(&#x27;WebSocket Open&#x27;, e);&#xA;             drawVideosToCanvas();&#xA;             mediaStream = getMixedVideoStream(); // 30 FPS&#xA;             mediaRecorder = new MediaRecorder(mediaStream, {&#xA;               mimeType: &#x27;video/webm;codecs=h264&#x27;,&#xA;               //videoBitsPerSecond : 3000000000&#xA;               bitsPerSecond: 6000000&#xA;             });&#xA;&#xA;             mediaRecorder.addEventListener(&#x27;dataavailable&#x27;, (e) => {&#xA;               ws.send(e.data);&#xA;             });&#xA;             mediaRecorder.onstop = function() {&#xA;              ws.close.bind(ws);&#xA;              isRecording = false;&#xA;              actionBtn.textContent = &#x27;Start Streaming&#x27;;&#xA;              actionBtn.onclick = startRecording;&#xA;             }&#xA;             mediaRecorder.onstart = function() {&#xA;              isRecording = true;&#xA;              actionBtn.textContent = &#x27;Stop Streaming&#x27;;&#xA;              actionBtn.onclick = stopRecording;&#xA;              screenShareBtn.onclick = startSharing;&#xA;              screenShareBtn.disabled = false;&#xA;             }&#xA;             //mediaRecorder.addEventListener(&#x27;stop&#x27;, ws.close.bind(ws));&#xA;&#xA;             mediaRecorder.start(1000); // Start recording, and dump data every second&#xA;&#xA;           });

    &#xD;&#xA;

    &#xD;&#xA;

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

    On my client.js file, i captured users camera and then open the websocket server to send the data to the server.. Every thing works fine on local host expect for when i deploy it to live server..&#xA;i am wondering if there is a bad configuration on the server.. The server is Centos 7.8 and the app was runing on Apache software&#xA;Here is how i configured the virtual host for the websocket domain

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    ServerName my-websocket.com&#xA;&#xA;  RewriteEngine on&#xA;  RewriteCond %{HTTP:Upgrade} websocket [NC]&#xA;  RewriteCond %{HTTP:Connection} upgrade [NC]&#xA;  RewriteRule .* "ws://127.0.0.1:3000/$1" [P,L]&#xA;&#xA;  ProxyPass "/" "http://127.0.0.1:3000/$1"&#xA;  ProxyPassReverse "/" "http://127.0.0.1:3000/$1"&#xA;  ProxyRequests off

    &#xD;&#xA;

    &#xD;&#xA;

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

    I don't know much about server configuration but i just thought may be the configuration has to do with why FFMPEg can not open connection to RTMP protocol on the server.

    &#xA;

    here is the error am getting

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    FFmpeg STDERR: Input #0, lavfi, from &#x27;anullsrc&#x27;:&#xA;  Duration:&#xA;FFmpeg STDERR: N/A, start: 0.000000, bitrate: 705 kb/s&#xA;    Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s&#xA;&#xA;DATA <buffer 1a="1a">&#xA;DATA <buffer 45="45" df="df" a3="a3" 42="42" 86="86" 81="81" 01="01" f7="f7" f2="f2" 04="04" f3="f3" 08="08" 82="82" 88="88" 6d="6d" 61="61" 74="74" 72="72" 6f="6f" 73="73" 6b="6b" 87="87" 0442="0442" 85="85" 02="02" 18="18" 53="53" 80="80" 67="67" ff="ff" 53991="53991" more="more" bytes="bytes">&#xA;DATA <buffer 40="40" c1="c1" 81="81" 00="00" f0="f0" 80="80" 7b="7b" 83="83" 3e="3e" 3b="3b" 07="07" d6="d6" 4e="4e" 1c="1c" 11="11" b4="b4" 7f="7f" cb="cb" 5e="5e" 68="68" 9b="9b" d5="d5" 2a="2a" e3="e3" 06="06" c6="c6" f3="f3" 94="94" ff="ff" 29="29" 16="16" b2="b2" 60="60" 04ac="04ac" 37="37" fb="fb" 1a="1a" 15="15" ea="ea" 39="39" a0="a0" cd="cd" 02="02" b8="b8" 56206="56206" more="more" bytes="bytes">&#xA;FFmpeg STDERR: Input #1, matroska,webm, from &#x27;pipe:&#x27;:&#xA;  Metadata:&#xA;    encoder         :&#xA;FFmpeg STDERR: Chrome&#xA;  Duration: N/A, start: 0.000000, bitrate: N/A&#xA;    Stream #1:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)&#xA;    Stream #1:1(eng): Video: h264 (Constrained Baseline), yuv420p(progressive), 1366x768, SAR 1:1 DAR 683:384, 30.30 fps, 30 tbr, 1k tbn, 60 tbc (default)&#xA;&#xA;FFmpeg STDERR: [tcp @ 0xe5fac0] Connection to tcp://a.rtmp.youtube.com:1935 failed (Connection refused), trying next address&#xA;[rtmp @ 0xe0fb80] Cannot open connection tcp://a.rtmp.youtube.com:1935&#xA;&#xA;FFmpeg STDERR: rtmp://a.rtmp.youtube.com/live2/mystreamid: Network is unreachable&#xA;&#xA;FFmpeg child process closed, code 1, signal null</buffer></buffer></buffer>

    &#xD;&#xA;

    &#xD;&#xA;

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

    I will really appreciate if I could get some insight on what may be causing this issue or what i can do to solve it..Thanks in advance..

    &#xA;

  • FFmpeg stream video results into net::ERR_CONTENT_LENGTH_MISMATCH 206

    7 septembre 2021, par Red

    I am trying to convert a mkv video to an mp4 format using FFmpeg, the output should be piped to a writeableStream, in this case I am using express.js

    &#xA;

    This is the actual code

    &#xA;

    const pathToVideo = &#x27;./path-to/video.mkv&#x27;;&#xA;const stats = fs.statSync(pathToVideo);&#xA;&#xA;const range = req.headers.range;&#xA;&#xA;if (!range) res.status(400).send("Requires Range header");&#xA;&#xA;const CHUNK_SIZE = 10 ** 6; // 1MB&#xA;const start = Number(range?.replace(/\D/g, ""));&#xA;const end = Math.min(start &#x2B; CHUNK_SIZE, stats.size - 1);&#xA;&#xA;const stream = fs.createReadStream(pathToMovie, { start: start, end: end })&#xA;&#xA;const contentLength = end - start &#x2B; 1;&#xA;const headers = {&#xA;    "Content-Range": `bytes ${start}-${end}/${stats.size &#x2B; 1}`,&#xA;    "Accept-Ranges": "bytes",&#xA;    "Content-Length": contentLength,&#xA;    "Content-Type": "video/mp4",&#xA;};&#xA;&#xA;res.writeHead(206, headers); &#xA;&#xA;ffmpeg(stream)&#xA;    .format(&#x27;mp4&#x27;)&#xA;    .videoCodec(&#x27;libx264&#x27;)&#xA;    .audioCodec(&#x27;libmp3lame&#x27;)&#xA;    .outputOptions(&#x27;-movflags frag_keyframe&#x2B;empty_moov&#x27;)&#xA;    .pipe(res, { end: true })&#xA;

    &#xA;

    In Chrome this results into an error

    &#xA;

    &#xA;

    GET http://localhost/video net::ERR_CONTENT_LENGTH_MISMATCH 206 (Partial Content)

    &#xA;

    &#xA;

    If I save the result into a file, instead of piping it, the video is playable and works fine. What do I forget in the above code ? I tried to play with the headers, without luck.

    &#xA;