Recherche avancée

Médias (1)

Mot : - Tags -/bug

Autres articles (43)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

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

Sur d’autres sites (4712)

  • NodeJS : Fail to write byte array input from webcam to ffmpeg spawn process

    23 mai 2024, par Thanesh Prabaghan

    I'm using NodeJS server to display an HTML page which has webcam option. Once user visited to my NodeJS server, it will serve html page. User can allow webcam option and see webcam view on the page.

    


    In the backend, I send webcam stream (byte array) using socket.io. I receive byte array successfully in backend with the help of socket.io. BUT MY PROBLEM IS, I can't pipe this byte array to the ffmpeg spawn process. I don't know how to properly pipe this data to the ffmpeg. Once it done, all my problem will be solved.

    


    On the other side, I have node-media-server as RTMP server to publish this stream to VLC player and other devices. Kindly help me to complete this task. I will attach all my code to this question. Kindly run this in your environment and answer the question.

    


    MY HTML PAGE

    


    &#xA;&#xA;  &#xA;    &#xA;      &#xA;&#xA;      &#xA;&#xA;      <code class="echappe-js">&lt;script src=&quot;https://cdn.socket.io/4.7.5/socket.io.min.js&quot; &amp;#xA;        integrity=&quot;integrity_code&quot; &amp;#xA;        crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&#xA;    &#xA;    &#xA;      
    &#xA; &#xA;&#xA; &lt;script&gt;&amp;#xA;          const socket = io(&amp;#x27;http://localhost:8080/&amp;#x27;);&amp;#xA;          var video = document.getElementById(&quot;video&quot;);&amp;#xA;&amp;#xA;          if (navigator.mediaDevices.getUserMedia) {&amp;#xA;            navigator.mediaDevices.getUserMedia({ video: true, audio:true })&amp;#xA;            .then(function (stream) {&amp;#xA;              const recorder = new MediaRecorder(stream);&amp;#xA;&amp;#xA;              recorder.ondataavailable = event =&gt; {&amp;#xA;                socket.emit(&amp;#x27;VideoStream&amp;#x27;, event.data);&amp;#xA;              };&amp;#xA;              recorder.start(1000);      &amp;#xA;              video.srcObject = stream;&amp;#xA;            }).catch(function (error) {&amp;#xA;              console.log(&quot;Something went wrong!&quot;);&amp;#xA;            });&amp;#xA;         }  &amp;#xA;       &lt;/script&gt;&#xA; &#xA;&#xA;&#xA;

    &#xA;

    FFMPEG IMPLEMENTATION

    &#xA;

    const express = require(&#x27;express&#x27;);&#xA;const app = express();&#xA;const http = require(&#x27;http&#x27;);&#xA;const server = http.createServer(app);&#xA;const { Server } = require("socket.io");&#xA;const io = new Server(server);&#xA;const path = require(&#x27;node:path&#x27;); &#xA;const { spawn } = require(&#x27;node:child_process&#x27;);&#xA;&#xA;let cmd = spawn(&#x27;ffmpeg.exe&#x27;, [&#xA;    &#x27;-c:v&#x27;, &#x27;copy&#x27;, &#x27;-preset&#x27;, &#x27;ultrafast&#x27;, &#x27;-tune&#x27;, &#x27;zerolatency&#x27;,&#xA;    &#x27;-c:a&#x27;, &#x27;aac&#x27;, &#x27;-strict&#x27;, &#x27;-2&#x27;, &#x27;-ar&#x27;, &#x27;44100&#x27;, &#x27;-b:a&#x27;, &#x27;64k&#x27;,&#xA;    &#x27;-y&#x27;,&#xA;    &#x27;-use_wallclock_as_timestamps&#x27;, &#x27;1&#x27;,&#xA;    &#x27;-async&#x27;, &#x27;1&#x27;,&#xA;    &#x27;-flush_packets&#x27;, &#x27;1&#x27;,&#xA;    &#x27;-rtbufsize&#x27;, &#x27;1000&#x27;,&#xA;    &#x27;-bufsize&#x27;, &#x27;1000&#x27;,&#xA;    &#x27;-f&#x27;, &#x27;flv&#x27;,&#xA;     &#x27;-i&#x27;,&#x27;-&#x27;,&#xA;    &#x27;rtmp://localhost:1935&#x27;,&#xA;  ]);&#xA;&#xA;app.use(express.static(path.join(__dirname, &#x27;public&#x27;)));&#xA;&#xA;app.get(&#x27;/&#x27;, (req, res) => {&#xA;  res.sendFile(path.join(__dirname &#x2B; &#x27;index.html&#x27;));&#xA;});&#xA;&#xA;io.on(&#x27;connection&#x27;, (socket) => {&#xA;  socket.on("VideoStream", (data) => {&#xA;    cmd.stdin.write(data);&#xA;  });&#xA;});&#xA;&#xA;server.listen(8080, () => {&#xA;  console.log(&#x27;listening on *:8080&#x27;);&#xA;});&#xA;&#xA;```&#xA;**NODE MEDIA SERVER IMPLEMENTATION**&#xA;&#xA;```&#xA;const NodeMediaServer = require(&#x27;node-media-server&#x27;);&#xA;&#xA;const config = {&#xA;  rtmp: {&#xA;    port: 1935,&#xA;    chunk_size: 60000,&#xA;    gop_cache: true,&#xA;    ping: 30,&#xA;    ping_timeout: 60&#xA;  },&#xA;  http: {&#xA;    port: 8000,&#xA;    allow_origin: &#x27;*&#x27;&#xA;  }&#xA;};&#xA;&#xA;var nms = new NodeMediaServer(config)&#xA;nms.run();&#xA;```&#xA;&#xA;&#xA;

    &#xA;

  • Tiny node js video convert server, best way to manage the threads

    23 juin 2017, par efirvida

    I am developing a small server to convert videos for the web, I started with a TCP server (maybe it is not the best solution, but it is not the part of my problem right now) to which I send the path of videos to convert and then Add to a queue in a database system, in this case mysql, but I’m thinking of migrating to MongoDB when it works

    var net = require('net'),
       Sequelize = require('sequelize'),
       async = require('async'),
       JsonSocket = require('json-socket'),
       ffmpeg = require('fluent-ffmpeg');

    var configDB = require('./config/database.js');
    var sequelize = new Sequelize(configDB.url);

    var Videos    = sequelize.import('app/models/video');
    Videos.sync();

    var port = 9838;

    var server = net.createServer();
    server.listen(port);
    server.on('connection', function(socket) {
       socket = new JsonSocket(socket);
       socket.on('message', function(video) {
           console.log(video.video);
           db_data = {
               'name': video.video,
               'converted': false,
               'progress': 0,
               'status': 'Q',
           }
           Videos.create(db_data).then(function () {
               socket.sendMessage('New Video Added');
           }).catch(function () {
               console.log('Error adding Video');
               socket.sendMessage('Error adding video')
           });
       });
    });

    Once I have a list of videos on the database the process begin with this code :

    // Function to update the video status on the database
    var databaseUpdate = function(status, callback) {
       name = status.name;
       delete status["name"];
       Videos.update(status, {
           where: {
               name: name
           }
       }).then(function (video) {
           if (typeof callback === 'function' &amp;&amp; callback) callback();
       });
    }

    //convert the video:
    // If the video status are:
    //   - 'Q' for in queue
    //   - 'R' for running conversion
    //   - 'C' for complete
    //   - 'E' for error on the conversion proccess
    function ffmpegConvert(video, output, callback)
    {
       var filename = video.split('/').reverse()[0].split('.')[0],
           output = output  + filename + '.mp4';  

       ffmpeg(video)
           .videoCodec('libx264')
           .audioCodec('libmp3lame')
           .on('error', function(err) {
               db_data = {
                   'name': video,
                   'status': 'E',   //&lt;- set status if error ocurre
               }
               databaseUpdate(db_data)
               console.log('An error occurred: ' + err.message);
           })
           .on('end', function(stdout, stderr) {
               db_data = {
                   'name': video,
                   'converted': true,       //&lt;- set status complete conversion
                   'status': 'C',           //&lt;- set status complete conversion
               }
               databaseUpdate(db_data, function(){convertVideos(1)}) // &lt;- put a next video in the queue to convert
           })
           .on('progress', function(progress) {
               db_data = {
                   'name': video,
                   'status': 'R',                //&lt;- set status ass running conversion
                   'progress': progress.percent, //&lt;- set the video processes %
               }
               databaseUpdate(db_data)
           })
           .save(output);
    }

    // get videos not converted `converted: false` and with
    // queque status `status: 'Q'` from the database
    // the send to the ffmpegConvert function in a num of async task
    var convertVideos = function(num){
       Videos.findAll(
           {
               where: {
                   converted: false,
                   status: 'Q'
               },
               limit : num,
               order: '"createdAt" DESC'
           }
       ).then(function (videos) {
           if (videos &amp;&amp; videos.length){
               async.each(videos,
                   function(item){
                       ffmpegConvert(item.name, output_folder )
                   },
               function(err){
               });
           }
       });
    }


    // Start vidieo conversion with threads number equal to number of cpu    
    threads  = require('os').cpus().length,
    convertVideos(threads);

    So at this point All works great, and all the videos on the queue are converted, but my questions are :

    1 - How to put new videos to convert if they are added to the database after the first run on the server ?

    I can’t put it to run the socket.on('message', function(video) {} because if I send a new video when the queue is not completed this going to start a new separated thread. I also think that I have to find a way to monitor the async task to see how many task are running before send new one

    2 - How to manage uncompleted videos if server goes down ?

    If I turn off the server for some reason, the status of the current video in the database stay in ’R’ so the query to add it to the conversion prosses didn not see it, and left it corrupted.

  • avformat/unix : set is_streamed to true

    6 février, par dank074
    avformat/unix : set is_streamed to true
    

    Currently when a Unix Domain Socket is used as input there is a loss
    of data when data is consumed from the stream. Setting is_streamed to
    true fixes this, since the unix domain socket is now treated like a
    consumable stream.

    Fixes : #9346
    Signed-off-by : dank074 <torresefrain10@gmail.com>
    Reviewed-by : Leo Izen <leo.izen@gmail.com>

    • [DH] libavformat/unix.c