Recherche avancée

Médias (1)

Mot : - Tags -/belgique

Autres articles (40)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (8133)

  • Cannot convert video file to audio file inside AWS lambda function using Node js

    21 février 2019, par Arun

    I cannot convert a video file into an audio file inside AWS lambda function using Node JS. While running my lambda function it doesn’t throw any error it executes without any error. But the audio file size is still 0 MB size. I am not able to find bugs or any issues in my code.

    Here is my code,

    const fs = require('fs');
    const childProcess = require('child_process');
    const AWS = require('aws-sdk');
    const path = require('path');
    AWS.config.update({
       region : 'us-east-2'
    });
    const s3 = new AWS.S3({apiVersion: '2006-03-01'});


    exports.handler = (event, context, callback) => {
       process.env.PATH = process.env.PATH + ':/tmp/';
       process.env['FFMPEG_PATH'] = '/tmp/ffmpeg';
       const BIN_PATH = process.env['LAMBDA_TASK_ROOT'];
       process.env['PATH'] = process.env['PATH'] + ':' + BIN_PATH;

       childProcess.exec(
           'cp /var/task/ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg;',
           function (error, stdout, stderr) {
               if (error) {
                   console.log('Error occured',error);
               } else {
                   var ffmpeg = '/tmp/ffmpeg';
                   var createStream = fs.createWriteStream("/tmp/video.mp3");
                   createStream.end();
                   var params = {
                       Bucket: "test-bucket",
                       Key: event.Records[0].s3.object.key
                   };
                   s3.getObject(params, function(err, data) {
                       if (err) {
                           console.log("Error", err);
                       }
                       fs.writeFile("/tmp/vid.mp4", data.Body, function (err) {
                           if (err) console.log(err.code, "-", err.message);
                           return callback(err);
                       }, function() {
                           try {
                               var stats = fs.statSync("/tmp/vid.mp4");
                               console.log("size of the file1 ", stats["size"]);
                               try {
                                   console.log("Yeah");
                                   const inputFilename = "/tmp/vid.mp4";
                                   const mp3Filename = "/tmp/video.mp3";
                                   // // Convert the FLV file to an MP3 file using ffmpeg.
                                   const ffmpegArgs = [
                                       '-i', inputFilename,
                                       '-vn', // Disable the video stream in the output.
                                       '-acodec', 'libmp3lame', // Use Lame for the mp3 encoding.
                                       '-ac', '2', // Set 2 audio channels.
                                       '-q:a', '6', // Set the quality to be roughly 128 kb/s.
                                       mp3Filename,
                                   ];
                                   try {
                                       const process = childProcess.spawnSync(ffmpeg, ffmpegArgs);
                                       console.log("stdout ", process.stdout);
                                       console.log("stderr ", process.stderr);
                                       console.log("tmp files ");
                                       fs.readdir('/tmp/', (err, files) => {
                                           files.forEach(file => {
                                               var stats = fs.statSync(`/tmp/${file}`);
                                               console.log("size of the file2 ", stats["size"]);
                                             console.log(file);
                                           });
                                         });

                                   } catch (e) {
                                       console.log("error while converting video to audio ", e);
                                   }

                                   // return process;
                               } catch (e) {
                                   console.log(e);
                               }
                           } catch (e) {
                               console.log("file is not complete", e);
                           }
                       }, function () {
                           console.log("checking ");
                           var stats = fs.statSync("/tmp/video.mp3");
                           console.log("size of the file2 ", stats["size"]);
                       });

                       return callback(err);
                   });
               }
           }
       )
    }

    Code workflow

    First of all, I have downloaded ffmpeg binary exec file and put into my project directory. After that, I compressed my project and put it into the lambda function. This lambda function will be triggered whenever the new files are uploaded into an S3 bucket. I have checked /tmp/ storage files and the audio file .mp3 present but the size is 0 MB.

    Note

    And also, in my code the below is not calling or this part is not reaching. When I look into Cloudwatch logs I can’t see this console log messages. I don’t know why this function is not calling.

    function () {
           console.log("checking ");
           var stats = fs.statSync("/tmp/video.mp3");
           console.log("size of the file2 ", stats["size"]);
       });

    Please help me to find the solution of this issue. I have spent a lot of times to figure out this issue. But I am not able to find the solution. Any suggestions are welcome !!
    Thanks,

  • Stream webm to node.js from c# application in chunks

    29 mai 2018, par Dan-Levi Tømta

    I am in the process of learning about streaming between node.js with socket.io and c#.

    I have code that successfully records the screen with ffmpeg, redirects it StandardOutput.BaseStream and stores it into a Memorybuffer, when i click stop in my application it sends the memorystream as a byte array to the node.js server which are storing the file so the clients can play it. This are working just fine and here are my setup for that :

    C#

    bool ffWorkerIsWorking = false;
    private void btnFFMpeg_Click(object sender, RoutedEventArgs e)
    {
       BackgroundWorker ffWorker = new BackgroundWorker();
       ffWorker.WorkerSupportsCancellation = true;
       ffWorker.DoWork += ((ffWorkerObj,ffWorkerEventArgs) =>
       {
           ffWorkerIsWorking = true;
           using (var FFProcess = new Process())
           {
               var processStartInfo = new ProcessStartInfo
               {
                   FileName = "ffmpeg.exe",
                   RedirectStandardInput = true,
                   RedirectStandardOutput = true,
                   UseShellExecute = false,
                   CreateNoWindow = false,
                   Arguments = " -loglevel panic -hide_banner -y -f gdigrab -draw_mouse 1 -i desktop -threads 2 -deadline realtime  -f webm -"
               };
               FFProcess.StartInfo = processStartInfo;
               FFProcess.Start();

               byte[] buffer = new byte[32768];
               using (MemoryStream ms = new MemoryStream())
               {
                   while (!FFProcess.HasExited)
                   {
                       int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
                       if (read <= 0)
                           break;
                       ms.Write(buffer, 0, read);
                       Console.WriteLine(ms.Length);
                       if (!ffWorkerIsWorking)
                       {                                
                           clientSocket.Emit("video", ms.ToArray());                                
                           ffWorker.CancelAsync();
                           break;
                       }
                   }
               }
           }
       });
       ffWorker.RunWorkerAsync();
    }

    JS (Server)

    socket.on('video', function(data) {
       fs.appendFile('public/fooTest.webm', data, function (err) {
         if (err) throw err;
         console.log('File uploaded');
       });
    });

    Now i need to change this code so it instead of sending the whole file it should sends chunks of byte arrays instead of the whole video, and node will then initially create a file and then append those chunks of byte arrays as they are received. Ok sound easy enough, but apparently not.

    I need to somehow instruct the code to use a offset and just the bytes after that offset and then update the offset.

    On the server side i think the best approach is to create a file and append the byte arrays to that file as they are received.

    On the server side i would do something like this :

    JS (Server)

    var buffer = new Buffer(32768);
    var isBuffering = false;
    socket.on('video', function(data) {
       //concatenate the buffer with the incoming data and broadcast.emit to clients

    });

    How am i able to setup the offset for the bytes to be sent and update that offset, and how would i approach the way of concatenating the data to the initialized buffer ?

    I have tried to write some code that only reads from the offset to the end and it seems like this is working although the video when added up in node is just black :

    C#

    while (!FFProcess.HasExited)
    {
       int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
       if (read <= 0)
           break;
       int offset = (read - buffer.Length > 0 ? read - buffer.Length : 0);
       ms.Write(buffer, offset, read);
       clientSocket.Emit("videoChunk", buffer.ToArray());
       if (!ffWorkerIsWorking)
       {                                
           ffWorker.CancelAsync();
           break;
       }
    }

    Node console output

    Bytes read

    JS (Server)

    socket.on('videoChunk', function(data) {
       if (!isBufferingDone) {
           buffer = Buffer.concat([buffer, data]);
           console.log(data.length);
       }
    });

    socket.on('cancelVideo', function() {
       isBufferingDone = true;
       setTimeout(function() {
           fs.writeFile("public/test.webm", buffer, function(err) {
               if(err) {
                   return console.log(err);
               }
               console.log("The file was saved!");
               buffer = new Buffer(32768);
           });
       }, 1000);
    });

    JS (Client)

    socket.on('video', function(filePath) {
      console.log('path: ' + filePath);
      $('#videoSource').attr('src',filePath);
      $('#video').play();
    });

    Thanks !

  • Stream webm to node.js from c# application in chunks

    7 août 2015, par Dan-Levi Tømta

    I am in the process of learning about streaming between node.js with socket.io and c#.

    I have code that successfully records the screen with ffmpeg, redirects it StandardOutput.BaseStream and stores it into a Memorybuffer, when i click stop in my application it sends the memorystream as a byte array to the node.js server which are storing the file so the clients can play it. This are working just fine and here are my setup for that :

    C#

    bool ffWorkerIsWorking = false;
    private void btnFFMpeg_Click(object sender, RoutedEventArgs e)
    {
       BackgroundWorker ffWorker = new BackgroundWorker();
       ffWorker.WorkerSupportsCancellation = true;
       ffWorker.DoWork += ((ffWorkerObj,ffWorkerEventArgs) =>
       {
           ffWorkerIsWorking = true;
           using (var FFProcess = new Process())
           {
               var processStartInfo = new ProcessStartInfo
               {
                   FileName = "ffmpeg.exe",
                   RedirectStandardInput = true,
                   RedirectStandardOutput = true,
                   UseShellExecute = false,
                   CreateNoWindow = false,
                   Arguments = " -loglevel panic -hide_banner -y -f gdigrab -draw_mouse 1 -i desktop -threads 2 -deadline realtime  -f webm -"
               };
               FFProcess.StartInfo = processStartInfo;
               FFProcess.Start();

               byte[] buffer = new byte[32768];
               using (MemoryStream ms = new MemoryStream())
               {
                   while (!FFProcess.HasExited)
                   {
                       int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
                       if (read <= 0)
                           break;
                       ms.Write(buffer, 0, read);
                       Console.WriteLine(ms.Length);
                       if (!ffWorkerIsWorking)
                       {                                
                           clientSocket.Emit("video", ms.ToArray());                                
                           ffWorker.CancelAsync();
                           break;
                       }
                   }
               }
           }
       });
       ffWorker.RunWorkerAsync();
    }

    JS (Server)

    socket.on('video', function(data) {
       fs.appendFile('public/fooTest.webm', data, function (err) {
         if (err) throw err;
         console.log('File uploaded');
       });
    });

    Now i need to change this code so it instead of sending the whole file it should sends chunks of byte arrays instead of the whole video, and node will then initially create a file and then append those chunks of byte arrays as they are received. Ok sound easy enough, but apparently not.

    I need to somehow instruct the code to use a offset and just the bytes after that offset and then update the offset.

    On the server side i think the best approach is to create a file and append the byte arrays to that file as they are received.

    On the server side i would do something like this :

    JS (Server)

    var buffer = new Buffer(32768);
    var isBuffering = false;
    socket.on('video', function(data) {
       //concatenate the buffer with the incoming data and broadcast.emit to clients

    });

    How am i able to setup the offset for the bytes to be sent and update that offset, and how would i approach the way of concatenating the data to the initialized buffer ?

    I have tried to write some code that only reads from the offset to the end and it seems like this is working although the video when added up in node is just black :

    C#

    while (!FFProcess.HasExited)
    {
       int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
       if (read <= 0)
           break;
       int offset = (read - buffer.Length > 0 ? read - buffer.Length : 0);
       ms.Write(buffer, offset, read);
       clientSocket.Emit("videoChunk", buffer.ToArray());
       if (!ffWorkerIsWorking)
       {                                
           ffWorker.CancelAsync();
           break;
       }
    }

    Node console output

    Bytes read

    JS (Server)

    socket.on('videoChunk', function(data) {
       if (!isBufferingDone) {
           buffer = Buffer.concat([buffer, data]);
           console.log(data.length);
       }
    });

    socket.on('cancelVideo', function() {
       isBufferingDone = true;
       setTimeout(function() {
           fs.writeFile("public/test.webm", buffer, function(err) {
               if(err) {
                   return console.log(err);
               }
               console.log("The file was saved!");
               buffer = new Buffer(32768);
           });
       }, 1000);
    });

    JS (Client)

    socket.on('video', function(filePath) {
      console.log('path: ' + filePath);
      $('#videoSource').attr('src',filePath);
      $('#video').play();
    });

    Thanks !