Recherche avancée

Médias (91)

Autres articles (43)

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

  • 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 !

  • Convert Webm to MP4 on the fly using ffmpeg for a Telegram bot using Typescript

    23 novembre 2022, par Hex

    I'm trying to make a very primitive telegram bot that get's a json and uploads the urls that are in the json to telegram.

    


    The problem is that there are urls that point to webm files I tried to see if there is a simple way to do this and I found this : https://www.npmjs.com/package/webm-to-mp4
but it doesn't seem to work sadly, it runs into this error : "

    


    


    


    throw new Error(`Conversion error: ${stderr}`)
                                ^

Error: Conversion error: ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with emcc (Emscripten gcc/clang-like replacement) 1.39.11
  configuration: --cc=emcc --ranlib=emranlib --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-safe-bitstream-reader --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avfilter --enable-swresample --enable-swscale --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vdpau --enable-decoder=vp8 --enable-decoder=h264 --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=aac --enable-decoder=pcm_s16le --enable-decoder=mjpeg --enable-decoder=png --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=wav --enable-demuxer=image2 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --enable-filter=hstack --enable-filter=vstack --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl2 --disable-securetransport --disable-xlib --enable-zlib --enable-encoder=libx264 --enable-encoder=libmp3lame --enable-encoder=aac --enable-muxer=mp4 --enable-muxer=mp3 --enable-muxer=null --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags='-s USE_ZLIB=1 -I../lame/dist/include' --extra-ldflags=-L../lame/dist/lib
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
input.webm: Invalid data found when processing input
exception thrown: Error: Conversion error: ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with emcc (Emscripten gcc/clang-like replacement) 1.39.11
  configuration: --cc=emcc --ranlib=emranlib --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-safe-bitstream-reader --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avfilter --enable-swresample --enable-swscale --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vdpau --enable-decoder=vp8 --enable-decoder=h264 --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=aac --enable-decoder=pcm_s16le --enable-decoder=mjpeg --enable-decoder=png --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=wav --enable-demuxer=image2 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --enable-filter=hstack --enable-filter=vstack --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl2 --disable-securetransport --disable-xlib --enable-zlib --enable-encoder=libx264 --enable-encoder=libmp3lame --enable-encoder=aac --enable-muxer=mp4 --enable-muxer=mp3 --enable-muxer=null --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags='-s USE_ZLIB=1 -I../lame/dist/include' --extra-ldflags=-L../lame/dist/lib
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
input.webm: Invalid data found when processing input
,Error: Conversion error: ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with emcc (Emscripten gcc/clang-like replacement) 1.39.11
  configuration: --cc=emcc --ranlib=emranlib --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-safe-bitstream-reader --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avfilter --enable-swresample --enable-swscale --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vdpau --enable-decoder=vp8 --enable-decoder=h264 --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=aac --enable-decoder=pcm_s16le --enable-decoder=mjpeg --enable-decoder=png --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=wav --enable-demuxer=image2 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --enable-filter=hstack --enable-filter=vstack --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl2 --disable-securetransport --disable-xlib --enable-zlib --enable-encoder=libx264 --enable-encoder=libmp3lame --enable-encoder=aac --enable-muxer=mp4 --enable-muxer=mp3 --enable-muxer=null --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags='-s USE_ZLIB=1 -I../lame/dist/include' --extra-ldflags=-L../lame/dist/lib
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
input.webm: Invalid data found when processing input


    


    I'm not sure what is causing it, my guess is that the webm-to.mp4 package was updated 2 years ago and something broke in the meantime.

    


    Is there a better way to do this then downloading the webm converting it and then sending it up to telegram ? If not how could I do the conversion using just ffmpeg ?

    


    Here is my current code :

    


    import { Telegram, MediaSource, HTML } from 'puregram'
import { HearManager } from '@puregram/hear'
import { createReadStream } from 'fs'
import postsJson from './posts.json';
const { promises: fs } = require("fs");
const webmToMp4 = require("webm-to-mp4");

const telegram = new Telegram({
  token: '********:AAEzriis6zNNjEQuw0BxF9M2RPA9V4lEqLA'
})
const hearManager = new HearManager()

telegram.updates.startPolling()
  .then(() => console.log(`started polling @${telegram.bot.username}`))
  .catch(console.error)

telegram.updates.on('message', hearManager.middleware)

var posts = postsJson;

telegram.updates.on('message', (context) => {
    posts.forEach( async data => {
      console.error(data.ext);
        if(data.ext == "jpg" || data.ext == "png"){
          context.sendPhoto(MediaSource.url(data.image), { caption: data.content  } );
          delay(1000);
        }
        if(data.ext == "gif"){
          context.sendAnimation(MediaSource.url(data.image), { caption: data.content  } );
          delay(1000);
        }
        if(data.ext == "webm"){
          //context.sendDocument(MediaSource.url(data.image), { caption: data.content  } );
          delay(1000);
        }
        delay(1000);
    })
})
fs.writeFile("file.mp4", Buffer.from(webmToMp4( fs.readFile("./file.webm"))));

function delay(ms: number) {
  return new Promise( resolve => setTimeout(resolve, ms) ); //This does not work either
}


    


    I wish everoyne a nice day !