
Recherche avancée
Autres articles (59)
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Soumettre améliorations et plugins supplémentaires
10 avril 2011Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)
Sur d’autres sites (8498)
-
How to broadcast a video stream without reloading the page ?
16 novembre 2024, par promo 69I created a Node.js server to :


- 

- Receive images in udp and transform them into video and
- Display it on a website
- I tried but I don't understand how to broadcast the video live without having to reload the page








Node.js server code :


const express = require('express');
const dgram = require('dgram');
const fs = require('fs');
const ffmpeg = require('fluent-ffmpeg');
const path = require('path');
const WebSocket = require('ws');

const app = express();
const httpPort = 3000;

const imageDir = path.join(__dirname, 'images');
if (!fs.existsSync(imageDir)) {
 fs.mkdirSync(imageDir);
}

let imageCount = 0;

const udpPort = 15002;
const udpHost = '127.0.0.1';
const server = dgram.createSocket('udp4');

const wss = new WebSocket.Server({ noServer: true });


const createVideo = () => {
 const outputVideo = path.join(__dirname, 'output_video.mp4');

 ffmpeg()
 .input(path.join(imageDir, '%d.jpg'))
 .inputOptions('-framerate 30')
 .output(outputVideo)
 .outputOptions('-c:v libx264')
 .on('end', () => {
 console.log('Vidéo créée avec succès !');

 wss.clients.forEach(client => {
 if (client.readyState === WebSocket.OPEN) {
 client.send('new-video');
 }
 });
 })
 .on('error', (err) => {
 console.log('Erreur lors de la création de la vidéo:', err);
 })
 .run();
};


app.get('/feed-video', (req, res) => {
 const videoPath = path.join(__dirname, 'output_video.mp4');
 res.sendFile(videoPath);
});

server.on('message', (msg, rinfo) => {
 console.log(`Reçu message de ${rinfo.address}:${rinfo.port}`);

 const imageFilePath = path.join(imageDir, `${imageCount}.jpg`);
 fs.writeFileSync(imageFilePath, msg);

 console.log(`Image ${imageCount}.jpg reçue et sauvegardée`);


 imageCount++;


 if (imageCount > 100) {
 createVideo();
 imageCount = 0;
 }
});


server.on('listening', () => {
 const address = server.address();
 console.log(`Serveur UDP en écoute sur ${address.address}:${address.port}`);
});


app.server = app.listen(httpPort, () => {
 console.log(`Serveur HTTP et WebSocket démarré sur http://localhost:${httpPort}`);
});

app.server.on('upgrade', (request, socket, head) => {
 wss.handleUpgrade(request, socket, head, (ws) => {
 wss.emit('connection', ws, request);
 });
});


server.bind(udpPort, udpHost);




The html page :





 
 
 
 


<h1>Drone Video Feed</h1>
<video controls="controls" autoplay="autoplay"></video>

<code class="echappe-js"><script>&#xA; const video = document.getElementById(&#x27;video&#x27;);&#xA; const ws = new WebSocket(&#x27;ws://localhost:3000&#x27;);&#xA;&#xA; ws.onmessage = (event) => {&#xA; const blob = new Blob([event.data], { type: &#x27;video/mp4&#x27; });&#xA; video.src = URL.createObjectURL(blob);&#xA; video.play();&#xA; };&#xA;</script>






I tried with websocket but I didn't succeed.
The video is correctly created and when I reload the page the new video is played by the player.


However I would have been able to see the live stream without having to reload my page all the time.


-
ffmpeg - how can I get a specific channel using channel masks (e.g. : get only surround left channel)
26 novembre 2013, par awfulcodeI'm trying to build a mixer that allows users to toggle specific channels on and off. I know that different codecs encode those channels in different orders (it's not as simple as getting channel #3 as the center channel every time), so the challenge is to properly identify the channel position in surround audio tracks.
ffmpeg does list the in the beginning of libavutil/channel_layout.h :
#define AV_CH_FRONT_LEFT 0x00000001
#define AV_CH_FRONT_RIGHT 0x00000002
#define AV_CH_FRONT_CENTER 0x00000004
#define AV_CH_LOW_FREQUENCY 0x00000008
#define AV_CH_BACK_LEFT 0x00000010
#define AV_CH_BACK_RIGHT 0x00000020
#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040
#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080
#define AV_CH_BACK_CENTER 0x00000100
#define AV_CH_SIDE_LEFT 0x00000200
#define AV_CH_SIDE_RIGHT 0x00000400
#define AV_CH_TOP_CENTER 0x00000800
#define AV_CH_TOP_FRONT_LEFT 0x00001000
#define AV_CH_TOP_FRONT_CENTER 0x00002000
#define AV_CH_TOP_FRONT_RIGHT 0x00004000
#define AV_CH_TOP_BACK_LEFT 0x00008000
#define AV_CH_TOP_BACK_CENTER 0x00010000
#define AV_CH_TOP_BACK_RIGHT 0x00020000
#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT.
#define AV_CH_WIDE_LEFT 0x0000000080000000ULL
#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL
#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL
#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL
#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULLBut looking over the header files and whatever little documentation about ffmpeg I couldn't find anything that tells me how to assign a specific channel position (or mask, as it's described in the header file) to a specific bus in a mixer audio unit.
Do you know how to do that ? Please let me know if you want to look at the code I'm using right now.
And as always, thank you so much.
-
How to combine 2 images with ffmpeg ?
7 octobre 2018, par senopsI have 2 images which I’d like to place one on top of the other. I made this line :
ffmpeg -i "C:\image_1.jpg" -i "C:\image_2.jpg" -q:v 1 -filter_complex "[0:v]scale=800:-1[v0];[v0][1:v]vstack" C:\combined.jpg
and it works when they have the same resolution 800x800 and when the resolution of the first one is smaller than
image_2
.Is it possible to add some mathematics instead of 800 to make this line suitable for any type of resolutions when the first one is bigger or the second is bigger (width and height separately) ?
I want to find a maximal dimension and scale another image to it preserving aspect ratio. If the aspect ratio of 2 images is not the same fill the holes with plain white (255,255,255).
I suppose the mathematics should be like this :
w1, h1 - width and height of the 1st img
w2, h2 - width and height of the 2st img
w1', h1', w2', h2' - width and height of resulted images
if w1 max{w1, h1, w2, h2} -> if w2/h2>=1 -> w2'=w1; h2'=h2*w2'/w2
if w1 max{w1, h1, w2, h2} -> if w2/h2<1 -> h2'=w1; w2'=w2*h2'/h2
if h1 max{w1, h1, w2, h2} -> if w2/h2>=1 -> w2'=h1; h2'=h2*w2'/w2
if h1 max{w1, h1, w2, h2} -> if w2/h2<1 -> h2'=h1; w2'=w2*h2'/h2
if w2 max{w1, h1, w2, h2} -> if w1/h1>=1 -> w1'=w2; h1'=h1*w1'/w1
if w2 max{w1, h1, w2, h2} -> if w1/h1<1 -> h1'=w2; w1'=w1*h1'/h1
if h2 max{w1, h1, w2, h2} -> if w1/h1>=1 -> w1'=h2; h1'=h1*w1'/w1
if h2 max{w1, h1, w2, h2} -> if w1/h1<1 -> h1'=h2; w1'=w1*h1'/h1If the two images i1 and i2 are 800x800 and - 436x800 resp :
the combined image will be 800x1600.If the two images i1 and i2 are 300x400 and 200x500 resp :
max(300,400,200,500)=500 ; 300x400 -> (300*500/400=375)x500 ; 200x500 -> 200x500. Align the smallest one (200x500) to center, fill the gaps (2 gaps : (375-200)/2=88) with white (255,255,255).