Recherche avancée

Médias (1)

Mot : - Tags -/publicité

Autres articles (94)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-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

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

Sur d’autres sites (5293)

  • Fluent-ffmpeg won't create video file sometime it will create ?

    27 mai 2022, par Himanshu Thakur

    anyone know the reason of this problem ? what is the issue ?
in this code, i am trying to convert a blob into video format. but sometime it is working and sometime not. can anyone help me in this ?

    


    

    

    const recordVideo = require('../model/recordVideo_model')
const { join, dirname } = require('path');
const { fileURLToPath } = require('url')
const { mkdir, open, unlink, writeFile } = require('fs/promises');
const {Blob, Buffer} = require('buffer');
const { path } = require('@ffmpeg-installer/ffmpeg');
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(path)
// const __dirname = dirname(fileURLToPath(import.meta.url));
const saveData = async(data, roomid, course_id)=>{
     //console.log(data);
     const videoPath = join(__dirname, '../video');
    //final folder name
    //const dirName = new Date().toLocaleDateString().replace(/\./g, '_');
    const dirName = roomid;
    // console.log(`dirName: ${dirName}`);
    //const dirPath = `${videoPath}/${dirName}`;
     const dirPath = `./public/video/canvideo/${dirName}`;
   
    const fileName= `${Date.now()}-${roomid}.webm`;
    //const fileName= `${roomid}.webm`;
    const tempFilePath = `${dirPath}/temp-${fileName}`;
    const finalFilePath = `${dirPath}/${fileName}`;
    
    let fileHandle;  
    try {
      fileHandle = await open(dirPath);
      console.log(`open the file${fileHandle}`)
    } 
  
    catch {
      await mkdir(dirPath);
      console.log(`making directory${fileHandle}`)
    } 
    
    finally {
  
      if (fileHandle) {
        fileHandle.close();
        console.log(`closing ${fileHandle}`)
      }
  
    }

    try {
        const videoBlob = new Blob(data, {
          type: 'video/webm'
        })
        const videoBuffer = Buffer.from(await videoBlob.arrayBuffer())
        const res = await recordVideo.findOne({roomid:roomid, recordType:'canvas'})
        if(!res){ 
        await writeFile(tempFilePath, videoBuffer)
        
        await ffmpeg(tempFilePath)
          .outputOptions([
            '-c:v libvpx-vp9',
            '-c:a copy',
            '-crf 35',
            '-b:v 0',
            '-vf scale=1280:720','-max_muxing_queue_size 1024'
          ])
          .on('end', async () => {
            await unlink(tempFilePath)
            console.log(`*** File ${fileName} created`)
            //insert database entry (recorded video entry with same details roomid, finename, finalfilepath, created at)  
           await recordVideo.create({roomid:roomid,filename:fileName,filePath:finalFilePath,recordType:'canvas', courseid:course_id});
          
          }).on('error', function(err) {
            console.log('An error occurred: ' + err.message);
          })
          .save(finalFilePath, dirPath);

        }  

      } 
      
      catch (e) {
        console.log('*** Erro in code ', e)
      }

}

module.exports = {saveData,};

    


    


    

if any help me in this. it would be great for me.
in this code, i am trying to convert a blob into video format. but sometime it is working and sometime not. can anyone help me in this ?


  • Node.js - I keep getting the following error : Error : ffmpeg stream : write EPIPE

    14 août 2020, par Kyky

    I'm currently programming a Discord bot using discord.js, and I'm using ytdl-core to play music. Here is the program I'm using to play music :

    



    const {google} = require('googleapis');
const ytdl = require('ytdl-core');
// Initialise Google API
const youtube = google.youtube({
    version: 'v3',
    auth: MyAuth
});
musicQueue = [] // Queue for playing music
dispatcher = null; // Transmits voice packets from stream

module.exports = {
    name: "play",

    async execute(msg, args) { // msg is a Discord Message
        // Play music and music queued after
        async function playAndQueue(stream) {

            // Join voice channel
            voiceChannel = client.channels.cache.find(channel => channel.type === "voice" && channel.name === "music-channel");
            voiceConnection = voiceChannel.join();

            dispatcher = await voiceConnection.play(stream, {volume: 0.3}); // Decrease volume to prevent clipping

            // When music stops
            dispatcher.on("finish", async reason => {
                if (musicQueue[0]) { // Still have music queued
                    const nextVideoLink = musicQueue[0]; // Next video to play
                    const stream = ytdl(nextVideoLink, {filter: 'audioonly'});

                    playAndQueue(stream);
                    dispatcherInfo = await ytdl.getInfo(nextVideoLink);
                    musicQueue.shift();
                } else { // No music to play
                    dispatcher = null;
                    dispatcherInfo = null;
                }
            });

            dispatcher.on("error", console.log);
            dispatcher.on("debug", console.log);

        }

        // Search Youtube using args
        const youtubeSearchResult = await youtube.search.list({
            part: 'snippet',
            type: 'video', // We do not want channels or playlists
            q: args.join(' '),
            maxResults: 1 // We only need first search result
        });
        const youtubeVideo = youtubeSearchResult.data.items[0];
        if (! youtubeVideo) {
            msg.channel.send("Error: Could not find any music matching search.");
            return;
        }

        const videoLink = `https://www.youtube.com/watch?v=${youtubeVideo.id.videoId}`; // Link to video

        const stream = ytdl(videoLink, {filter: 'audioonly'});
        const videoInfo = await ytdl.getInfo(videoLink);


        if (dispatcher) { // Currently playing music
            musicQueue.push(videoLink);
            msg.channel.send(`**${videoInfo.title}** has been added into the queue!`);
        } else {
            playAndQueue(stream);
            dispatcherInfo = videoInfo;
            msg.channel.send(`Currently playing **${videoInfo.title}**!`);
        }
    }
}


    



    However, when I try to run the program on Heroku, I get this error :

    



    ffmpeg stream: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete (internal/stream_base_commons.js:92:16) {
  errno: 'EPIPE',
  code: 'EPIPE',
  syscall: 'write'
}


    



    What can I do ?

    


  • Decoding a FFMPEG Buffer video Streaming using websocket for processing with OpenCV ?

    4 octobre 2019, par Alexis Meneses

    I am having a problem trying to get a frame from a streaming that I am doing on a web socket.
    I am sending my data from a webcam with ffmpeg using this command :

    ffmpeg -s 320x240 -f video4linux2 -i /dev/video0 -f mpeg1video -b:v 800k -r 30 http://localhost:8092

    Later, I get that stream and broadcast on a node js server with the following code :

    var childProcess = require('child_process')
     , express = require('express')
     , http = require('http')
     , morgan = require('morgan')
     , ws = require('ws');

    // configuration files
    var configServer = require('./lib/config/server');

    // app parameters
    var app = express();
    app.set('port', configServer.httpPort);
    app.use(express.static(configServer.staticFolder));
    app.use(morgan('dev'));

    // serve index
    require('./lib/routes').serveIndex(app, configServer.staticFolder);

    // HTTP server
    http.createServer(app).listen(app.get('port'), function () {
     console.log('HTTP server listening on port ' + app.get('port'));
    });


    var STREAM_MAGIC_BYTES = 'jsmp'; // Must be 4 bytes
    var width = 320;
    var height = 240;

    // WebSocket server
    var wsServer = new (ws.Server)({ port: configServer.wsPort });
    console.log('WebSocket server listening on port ' + configServer.wsPort);

    wsServer.on('connection', function(socket) {

     var streamHeader = new Buffer(8);

     streamHeader.write(STREAM_MAGIC_BYTES);
     streamHeader.writeUInt16BE(width, 4);
     streamHeader.writeUInt16BE(height, 6);
     socket.send(streamHeader, { binary: true });
     console.log(streamHeader);

     console.log('New WebSocket Connection (' + wsServer.clients.length + ' total)');

     socket.on('close', function(code, message){
       console.log('Disconnected WebSocket (' + wsServer.clients.length + ' total)');
     });
    });

    wsServer.broadcast = function(data, opts) {
     for(var i in this.clients) {
       if(this.clients[i].readyState == 1) {
         this.clients[i].send(data, opts);
       }
       else {
         console.log('Error: Client (' + i + ') not connected.');
       }
     }


    };

    // HTTP server to accept incoming MPEG1 stream
    http.createServer(function (req, res) {
     console.log(
       'Stream Connected: ' + req.socket.remoteAddress +
       ':' + req.socket.remotePort + ' size: ' + width + 'x' + height
     );

     req.on('data', function (data) {
       wsServer.broadcast(data, { binary: true });
     });
    }).listen(configServer.streamPort, function () {
     console.log('Listening for video stream on port ' + configServer.streamPort);


    });

    module.exports.app = app;

    I am getting successfully the data from this.clients[i].send(data, opts) on my python program, but I dont know how to decode the information to process the image with opencv. Any idea ?

    What I want to do is :

    import asyncio
    import websockets
    import cv2

    async def hello():
       uri = "ws://192.168.1.170:8094" #URL of the websocket server
       async with websockets.connect(uri) as websocket:
               inf = await websocket.recv()
               # Process the data in order to showimg with opencv.

               print(inf)


    asyncio.get_event_loop().run_until_complete(hello())