Recherche avancée

Médias (1)

Mot : - Tags -/embed

Autres articles (42)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (6962)

  • Spawned ffmpeg process in nodejs Transform stream with flow control doesn't process input stream

    30 septembre 2022, par user1832894

    I have implemented a node.js Transform stream class that spawns ffmpeg and streams out the transformed stream at a controlled realtime rate. Below is my _transform() method.

    


    this.rcvd += chunk.length
console.log('received bytes %d', this.rcvd)
const ready = this.ffmpeg.stdin.write(chunk, encoding, err => err
  ? cb(err)
  : ready
    ? cb
    : this.ffmpeg.stdin.once('drain', cb))


    


    I want to write to ffmpeg's stdin stream till it returns false, at which point I wait for the drain event to write more data.

    


    Concurrently, I have a timer that fires every 40 milliseconds that reads ffmpeg's stdout and pushes it to the Transform stream's output (the readable side). Code not complete, but the folllowing describes it well.

    


    const now = Date.now()
const bytesToTransmit = (now - this.lastTx) * 32

const buf = this.ffmpeg.stdout.read()

if (buf == null) return

if (buf.length <= bytesToTransmit) {
  this.push(buf)
  this.lastTx += buf.length * 32
  return
}

this.push(buf.slice(0, bytesToTransmit))
this.lastTx = now

// todo(handle pending buffer)
this.pending = buf.slice(bytesToTransmit)


    


    The issue I am facing is that the first write (of 65k bytes) returns false, and after that I never receive the drain event. FFMpeg doesn't start processing the data until certain amount of data (256k bytes in my case) has been written, and once I start waiting for the drain event, I never recover control.

    


    I've tried a few ffmpeg options like nobuffer but to no avail. What am I doing wrong ? Any ideas would be super helpful.

    


    Thanks !

    


  • How to stream Opus stream from Discord to RTP

    16 août 2018, par qxu21

    I’m using a Node.JS Discord bot to stream a voice call over RTP. Currently, in my speaking event handler, I have

    var cmd = child_process.spawn("ffmpeg", [
             '-protocol_whitelist', 'file,crypto,sdp,rtp,udp,pipe,opus',
             '-re',
             '-acodec', 'opus',
             '-i', '-',
             '-ar', '8000',
             '-acodec', 'pcm_mulaw',
             '-f', 'mulaw',
             '-f', 'rtp',
             `rtp://${rtp_ip}:${rtp_port}`]);
    reciever.createOpusStream(user).pipe(cmd.stdin);

    equivalent to running the ffmpeg command ffmpeg -protocol_whitelist file,crypto,sdp,rtp,udp,pipe,opus -re acodec opus -i - -ar 8000 -acodec pcm_mulaw -f mulaw -f rtp rtp://${rtp_ip}:${rtp_port}

    Variations of this command produce errors ranging from pipe:: Invalid input or pipe:: Invalid argument to Invalid data on input. to

    [mp3 @ 0x5615decebe60] Format mp3 detected only with low score of 1, misdetection possible!
    [mp3 @ 0x5615decebe60] Failed to read frame size: Could not seek to 16101.

    Could anyone help me with sending a ReadableStream (opus) to an RTP mulaw stream ? Thanks !

  • Overlaying a text stream on a video stream with ffmpeg in Node.js

    16 mai 2023, par Tchoune

    I am creating a streaming system with Node.js that uses ffmpeg to send video and text streams to a local RTMP server, then combines those streams and sends them to Twitch.

    


    I'm using canvas to create a text image with a transparent background, and I need to change that text every time a new video in the playlist starts.

    


    Currently in stream I see only the video stream of my video and not the text. But if I go via VLC to see each more separate, I see them

    


    However, I'm running into a problem where the text stream doesn't appear in the final video stream on Twitch. In addition, I get the following error message :

    


    Combine stderr: [NULL @ 0x1407069f0] Unable to find a suitable output format for 'rtmp://live.twitch.tv/app/streamKey'
rtmp://live.twitch.tv/app/streamKey: Invalid argument


    


    Here is my current Node.js code :

    


    
const createTextImage = (runner) => {
    return new Promise((resolve, reject) => {
        const canvas = createCanvas(1920, 1080);
        const context = canvas.getContext('2d');

        // Fill the background with transparency
        context.fillStyle = 'rgba(0,0,0,0)';
        context.fillRect(0, 0, canvas.width, canvas.height);

        // Set the text options
        context.fillStyle = '#ffffff';
        context.font = '24px Arial';
        context.textAlign = 'start';
        context.textBaseline = 'middle';

        // Draw the text
        context.fillText(`Speedrun by ${runner}`, canvas.width / 2, canvas.height / 2);

        // Define the images directory
        const imagesDir = path.join(__dirname, 'images', 'runners');

        // Ensure the images directory exists
        fs.mkdirSync(imagesDir, { recursive: true });

        // Define the file path
        const filePath = path.join(imagesDir, runner + '.png');

        // Create the write stream
        const out = fs.createWriteStream(filePath);

        // Create the PNG stream
        const stream = canvas.createPNGStream();

        // Pipe the PNG stream to the write stream
        stream.pipe(out);

        out.on('finish', () => {
            console.log('The PNG file was created.');
            resolve();
        });

        out.on('error', reject);
    });
}
const streamVideo = (video) => {
    ffmpegLibrary.ffprobe(video.video, function (err, metadata) {
        if (err) {
            console.error(err);
            return;
        }
        currentVideoDuration = metadata.format.duration;

        // Annulez le délai précédent avant d'en créer un nouveau
        if (nextVideoTimeoutId) {
            clearTimeout(nextVideoTimeoutId);
        }

        // Déplacez votre appel setTimeout ici
        nextVideoTimeoutId = setTimeout(() => {
            console.log('Fin de la vidéo, passage à la suivante...');
            nextVideo();
        }, currentVideoDuration * 1000 + 10000);
    })


    ffmpegVideo = childProcess.spawn('ffmpeg', [
        '-nostdin', '-re', '-f', 'concat', '-safe', '0', '-i', 'playlist.txt',
        '-vcodec', 'libx264',
        '-s', '1920x1080',
        '-r', '30',
        '-b:v', '5000k',
        '-acodec', 'aac',
        '-preset', 'veryfast',
        '-f', 'flv',
        `rtmp://localhost:1935/live/video` // envoie le flux vidéo au serveur rtmp local
    ]);

    createTextImage(video.runner).then(() => {
        ffmpegText = childProcess.spawn('ffmpeg', [
            '-nostdin', '-re',
            '-loop', '1', '-i', `images/runners/${video.runner}.png`, // Utilise l'image créée par Puppeteer
            '-vcodec', 'libx264rgb', // Utilise le codec PNG pour conserver la transparence
            '-s', '1920x1080',
            '-r', '30',
            '-b:v', '5000k',
            '-acodec', 'aac',
            '-preset', 'veryfast',
            '-f', 'flv',
            `rtmp://localhost:1935/live/text` // envoie le flux de texte au serveur rtmp local
        ]);

        ffmpegText.stdout.on('data', (data) => {
            console.log(`text stdout: ${data}`);
        });

        ffmpegText.stderr.on('data', (data) => {
            console.error(`text stderr: ${data}`);
        });
    }).catch(error => {
        console.error(`Erreur lors de la création de l'image de texte: ${error}`);
    });

    ffmpegCombine = childProcess.spawn('ffmpeg', [
        '-i', 'rtmp://localhost:1935/live/video',
        '-i', 'rtmp://localhost:1935/live/text',
        '-filter_complex', '[0:v][1:v]overlay=main_w-overlay_w:0',
        '-s', '1920x1080',
        '-r', '30',
        '-vcodec', 'libx264',
        '-b:v', '5000k',
        '-acodec', 'aac',
        '-preset', 'veryfast',
        '-f', 'flv',
        `rtmp://live.twitch.tv/app/${twitchStreamKey}` // envoie le flux combiné à Twitch
    ]);

    ffmpegVideo.stdout.on('data', (data) => {
        console.log(`video stdout: ${data}`);
    });

    ffmpegVideo.stderr.on('data', (data) => {
        console.error(`video stderr: ${data}`);
    });

    ffmpegCombine.stdout.on('data', (data) => {
        console.log(`Combine stdout: ${data}`);
    });

    ffmpegCombine.stderr.on('data', (data) => {
        console.error(`Combine stderr: ${data}`);
    });

    ffmpegCombine.on('close', (code) => {
        console.log(`ffmpeg exited with code ${code}`);
        if (currentIndex >= playlist.length) {
            console.log('End of playlist');
            currentIndex = 0;
        }
    });
}



    


    Locally I use nginx with rtmp module to manage multi-streams and combined into one to send to twitch

    


    In NGINX it's my nginx.conf for module :

    


    rtmp {
    server {
        listen 1935; # le port pour le protocole RTMP
        
        application live {
            live on; # active le streaming en direct
            record off; # désactive l'enregistrement du flux
    
            # définit l'endroit où les flux doivent être envoyés
            push rtmp://live.twitch.tv/app/liveKey;
        }
    
        application text {
            live on; # active le streaming en direct
            record off; # désactive l'enregistrement du flux
        }
    }
}


    


    I have checked that the codecs, resolution and frame rate are the same for both streams. I am also overlaying the text stream on top of the video stream with the -filter_complex command, but I am not sure if it works correctly.

    


    Does each stream have to have the same parameters ?

    


    I would like to know if anyone has any idea what could be causing this problem and how to fix it. Should I use a different format for the output stream to Twitch ? Or is there another approach I should consider for layering a dynamic text stream over a video stream ?

    


    Also, I'm wondering if I'm handling updating the text stream correctly when the video changes. Currently, I create a new text image with Canvas every time the video changes, then create a new ffmpeg process for the text stream. Is this the right approach, or is there a better way to handle this ?

    


    Thanks in advance for any help or advice.