Recherche avancée

Médias (33)

Mot : - Tags -/creative commons

Autres articles (38)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

Sur d’autres sites (6348)

  • FFMPEG send RTP audio at 8k bytes/sec [closed]

    10 mai, par Muzza

    I'm trying to use FFMPEG to mimick a device that transmits G711U audio over UDP/RTP at 8k bytes per second.
The device im mimicking sends rtp packets every 20ms with 160byte payload.

    


    I've had limited success using the following command

    


    ffmpeg -f dshow -i audio="Microphone (Realtek(R) Audio)" -ac 1 -ar 8000 -ab 8 -acodec pcm_mulaw -f rtp rtp://127.0.0.1:12345?pkt_size=160


    


    This sends G711U encoded audio, in 160byte chunks, but streams at 64kB/s, not the 8kB/s that my device is expected, so the device errors out ?

    


    Any idea's would be massively appreciated !

    


    Thank you

    


    Log from FFMPEG

    


    >ffmpeg -f dshow -i audio="Microphone (Realtek(R) Audio)" -ac 1 -ar 8000 -ab 8 -acodec pcm_mulaw -f rtp rtp://127.0.0.1:12345?pkt_size=160
ffmpeg version 2025-04-23-git-25b0a8e295-essentials_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 14.2.0 (Rev3, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      60.  2.100 / 60.  2.100
  libavcodec     62.  0.101 / 62.  0.101
  libavformat    62.  0.100 / 62.  0.100
  libavdevice    62.  0.100 / 62.  0.100
  libavfilter    11.  0.100 / 11.  0.100
  libswscale      9.  0.100 /  9.  0.100
  libswresample   6.  0.100 /  6.  0.100
  libpostproc    59.  1.100 / 59.  1.100
[aist#0:0/pcm_s16le @ 00000198256b73c0] Guessed Channel Layout: stereo
Input #0, dshow, from 'audio=Microphone (Realtek(R) Audio)':
  Duration: N/A, start: 135470.702000, bitrate: 1411 kb/s
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s, Start-Time 135470.702s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_mulaw (native))
Press [q] to stop, [?] for help
[pcm_mulaw @ 00000198256cf240] Bitrate 8 is extremely low, maybe you mean 8k
Output #0, rtp, to 'rtp://127.0.0.1:12345?pkt_size=160':
  Metadata:
    encoder         : Lavf62.0.100
  Stream #0:0: Audio: pcm_mulaw, 8000 Hz, mono, s16 (8 bit), 64 kb/s
    Metadata:
      encoder         : Lavc62.0.101 pcm_mulaw
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 62.0.100
m=audio 12345 RTP/AVP 0
b=AS:64

[out#0/rtp @ 00000198256cdd00] video:0KiB audio:973KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 8.467470%
size=    1055KiB time=00:02:04.51 bitrate=  69.4kbits/s speed=   1x
Exiting normally, received signal 2.


    


    Wireshark :
Wireshark Log

    


    Shows packets being sent every 0.20ms

    


  • ffmpeg pipe process ends right after writing first buffer data to input stream and does not keep running

    6 mai, par Taketo Matsunaga

    I have been trying to convert 16bit PCM (s16le) audio data to webm using ffmpeg in C#.
But the process ends right after the writing the first buffer data to standard input.
I has exited with the status 0, meaning success. But do not know why....
Could anyone tell me why ?

    


    I apprecite it if you could support me.

    


        public class SpeechService : ISpeechService&#xA;    {&#xA;        &#xA;        /// <summary>&#xA;        /// Defines the _audioInputStream&#xA;        /// </summary>&#xA;        private readonly MemoryStream _audioInputStream = new MemoryStream();&#xA;&#xA;        public async Task SendPcmAsWebmViaWebSocketAsync(&#xA;            MemoryStream pcmAudioStream,&#xA;            int sampleRate,&#xA;            int channels) &#xA;        {&#xA;            string inputFormat = "s16le";&#xA;&#xA;            var ffmpegProcessInfo = new ProcessStartInfo&#xA;            {&#xA;                FileName = _ffmpegPath,&#xA;                Arguments =&#xA;                    $"-f {inputFormat} -ar {sampleRate} -ac {channels} -i pipe:0 " &#x2B;&#xA;                    $"-f webm pipe:1",&#xA;                RedirectStandardInput = true,&#xA;                RedirectStandardOutput = true,&#xA;                RedirectStandardError = true,&#xA;                UseShellExecute = false,&#xA;                CreateNoWindow = true,&#xA;            };&#xA;&#xA;            _ffmpegProcess = new Process { StartInfo = ffmpegProcessInfo };&#xA;&#xA;            Console.WriteLine("Starting FFmpeg process...");&#xA;            try&#xA;            {&#xA;&#xA;                if (!await Task.Run(() => _ffmpegProcess.Start()))&#xA;                {&#xA;                    Console.Error.WriteLine("Failed to start FFmpeg process.");&#xA;                    return;&#xA;                }&#xA;                Console.WriteLine("FFmpeg process started.");&#xA;&#xA;            }&#xA;            catch (Exception ex)&#xA;            {&#xA;                Console.Error.WriteLine($"Error starting FFmpeg process: {ex.Message}");&#xA;                throw;&#xA;            }&#xA;&#xA;            var encodeAndSendTask = Task.Run(async () =>&#xA;            {&#xA;                try&#xA;                {&#xA;                    using var ffmpegOutputStream = _ffmpegProcess.StandardOutput.BaseStream;&#xA;                    byte[] buffer = new byte[8192]; // Temporary buffer to read data&#xA;                    byte[] sendBuffer = new byte[8192]; // Buffer to accumulate data for sending&#xA;                    int sendBufferIndex = 0; // Tracks the current size of sendBuffer&#xA;                    int bytesRead;&#xA;&#xA;                    Console.WriteLine("Reading WebM output from FFmpeg and sending via WebSocket...");&#xA;                    while (true)&#xA;                    {&#xA;                        if ((bytesRead = await ffmpegOutputStream.ReadAsync(buffer, 0, buffer.Length)) > 0)&#xA;                        {&#xA;                            // Copy data to sendBuffer&#xA;                            Array.Copy(buffer, 0, sendBuffer, sendBufferIndex, bytesRead);&#xA;                            sendBufferIndex &#x2B;= bytesRead;&#xA;&#xA;                            // If sendBuffer is full, send it via WebSocket&#xA;                            if (sendBufferIndex >= sendBuffer.Length)&#xA;                            {&#xA;                                var segment = new ArraySegment<byte>(sendBuffer, 0, sendBuffer.Length);&#xA;                                _ws.SendMessage(segment);&#xA;                                sendBufferIndex = 0; // Reset the index after sending&#xA;                            }&#xA;                        }&#xA;                    }&#xA;                }&#xA;                catch (OperationCanceledException)&#xA;                {&#xA;                    Console.WriteLine("Encode/Send operation cancelled.");&#xA;                }&#xA;                catch (IOException ex) when (ex.InnerException is ObjectDisposedException)&#xA;                {&#xA;                    Console.WriteLine("Stream was closed, likely due to process exit or cancellation.");&#xA;                }&#xA;                catch (Exception ex)&#xA;                {&#xA;                    Console.Error.WriteLine($"Error during encoding/sending: {ex}");&#xA;                }&#xA;            });&#xA;&#xA;            var errorReadTask = Task.Run(async () =>&#xA;            {&#xA;                Console.WriteLine("Starting to read FFmpeg stderr...");&#xA;                using var errorReader = _ffmpegProcess.StandardError;&#xA;                try&#xA;                {&#xA;                    string? line;&#xA;                    while ((line = await errorReader.ReadLineAsync()) != null) &#xA;                    {&#xA;                        Console.WriteLine($"[FFmpeg stderr] {line}");&#xA;                    }&#xA;                }&#xA;                catch (OperationCanceledException) { Console.WriteLine("FFmpeg stderr reading cancelled."); }&#xA;                catch (TimeoutException) { Console.WriteLine("FFmpeg stderr reading timed out (due to cancellation)."); }&#xA;                catch (Exception ex) { Console.Error.WriteLine($"Error reading FFmpeg stderr: {ex.Message}"); }&#xA;                Console.WriteLine("Finished reading FFmpeg stderr.");&#xA;            });&#xA;&#xA;        }&#xA;&#xA;        public async Task AppendAudioBuffer(AudioMediaBuffer audioBuffer)&#xA;        {&#xA;            try&#xA;            {&#xA;                // audio for a 1:1 call&#xA;                var bufferLength = audioBuffer.Length;&#xA;                if (bufferLength > 0)&#xA;                {&#xA;                    var buffer = new byte[bufferLength];&#xA;                    Marshal.Copy(audioBuffer.Data, buffer, 0, (int)bufferLength);&#xA;&#xA;                    _logger.Info("_ffmpegProcess.HasExited:" &#x2B; _ffmpegProcess.HasExited);&#xA;                    using var ffmpegInputStream = _ffmpegProcess.StandardInput.BaseStream;&#xA;                    await ffmpegInputStream.WriteAsync(buffer, 0, buffer.Length);&#xA;                    await ffmpegInputStream.FlushAsync(); // バッファをフラッシュ&#xA;                    _logger.Info("Wrote buffer data.");&#xA;&#xA;                }&#xA;            }&#xA;            catch (Exception e)&#xA;            {&#xA;                _logger.Error(e, "Exception happend writing to input stream");&#xA;            }&#xA;        }&#xA;&#xA;</byte>

    &#xA;

    Starting FFmpeg process...&#xA;FFmpeg process started.&#xA;Starting to read FFmpeg stderr...&#xA;Reading WebM output from FFmpeg and sending via WebSocket...&#xA;[FFmpeg stderr] ffmpeg version 7.1.1-essentials_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers&#xA;[FFmpeg stderr]   built with gcc 14.2.0 (Rev1, Built by MSYS2 project)&#xA;[FFmpeg stderr]   configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband&#xA;[FFmpeg stderr]   libavutil      59. 39.100 / 59. 39.100&#xA;[FFmpeg stderr]   libavcodec     61. 19.101 / 61. 19.101&#xA;[FFmpeg stderr]   libavformat    61.  7.100 / 61.  7.100&#xA;[FFmpeg stderr]   libavdevice    61.  3.100 / 61.  3.100&#xA;[FFmpeg stderr]   libavfilter    10.  4.100 / 10.  4.100&#xA;[FFmpeg stderr]   libswscale      8.  3.100 /  8.  3.100&#xA;[FFmpeg stderr]   libswresample   5.  3.100 /  5.  3.100&#xA;[FFmpeg stderr]   libpostproc    58.  3.100 / 58.  3.100&#xA;&#xA;[2025-05-06 15:44:43,598][INFO][XbLogger.cs:85] _ffmpegProcess.HasExited:False&#xA;[2025-05-06 15:44:43,613][INFO][XbLogger.cs:85] Wrote buffer data.&#xA;[2025-05-06 15:44:43,613][INFO][XbLogger.cs:85] Wrote buffer data.&#xA;[FFmpeg stderr] [aist#0:0/pcm_s16le @ 0000025ec8d36040] Guessed Channel Layout: mono&#xA;[FFmpeg stderr] Input #0, s16le, from &#x27;pipe:0&#x27;:&#xA;[FFmpeg stderr]   Duration: N/A, bitrate: 256 kb/s&#xA;[FFmpeg stderr]   Stream #0:0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s&#xA;[FFmpeg stderr] Stream mapping:&#xA;[FFmpeg stderr]   Stream #0:0 -> #0:0 (pcm_s16le (native) -> opus (libopus))&#xA;[FFmpeg stderr] [libopus @ 0000025ec8d317c0] No bit rate set. Defaulting to 64000 bps.&#xA;[FFmpeg stderr] Output #0, webm, to &#x27;pipe:1&#x27;:&#xA;[FFmpeg stderr]   Metadata:&#xA;[FFmpeg stderr]     encoder         : Lavf61.7.100&#xA;[FFmpeg stderr]   Stream #0:0: Audio: opus, 16000 Hz, mono, s16, 64 kb/s&#xA;[FFmpeg stderr]       Metadata:&#xA;[FFmpeg stderr]         encoder         : Lavc61.19.101 libopus&#xA;[FFmpeg stderr] [out#0/webm @ 0000025ec8d36200] video:0KiB audio:1KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 67.493113%&#xA;[FFmpeg stderr] size=       1KiB time=00:00:00.04 bitrate= 243.2kbits/s speed=2.81x&#xA;Finished reading FFmpeg stderr.&#xA;[2025-05-06 15:44:44,101][INFO][XbLogger.cs:85] _ffmpegProcess.HasExited:True&#xA;[2025-05-06 15:44:44,132][ERROR][XbLogger.cs:67] Exception happend writing to input stream&#xA;System.ObjectDisposedException: Cannot access a closed file.&#xA;   at System.IO.FileStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)&#xA;   at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count)&#xA;   at EchoBot.Media.SpeechService.AppendAudioBuffer(AudioMediaBuffer audioBuffer) in C:\Users\tm068\Documents\workspace\myprj\xbridge-teams-bot\src\EchoBot\Media\SpeechService.cs:line 242&#xA;

    &#xA;

    I am expecting the ffmpeg process keep running.

    &#xA;

  • Impossible to redirect video stream after conversion (mkv to mp4)

    17 décembre 2019, par elgrusko

    I’m currently realising a school project which aims a streaming video website (like Netflix) using torrent-stream (with the magnet link). I am using NodeJS for the stream part.

    My problem is : I can’t redirect the stream to the HTML 5 player while i’m trying to stream and converting (with ffmpeg) video at the same time. I think it’s because I just can’t know what’s will be the final size of the converted file.
    In browser’s console I have this message : net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

    I tried to put this in the header : Transfer-Encoding: chunked instead of Content-Length
    I specify that the stream (before conversion) works perfectly

    This is my code :

    getTorrentFile.then(function (file) {
                   res.setHeader('Content-Type', 'video/mp4');
                   res.setHeader('Content-Length', file.length);
                   const ranges = parseRange(file.length, '15' /* variable à comprendre */, { combine: true });
                   console.log(ranges);
                   if (ranges === -1) {
                       // 416 Requested Range Not Satisfiable
                       console.log('416')
                       res.statusCode = 416;
                       return res.end();
                   } else if (ranges === -2 || ranges.type !== 'bytes' || ranges.length > 1) {
                       // 200 OK requested range malformed or multiple ranges requested, stream ent'ire video
                       if (req.method !== 'GET') return res.end();
                       console.log('200')
                       stream = file.createReadStream()
                       ffmpeg(stream)
                       .videoCodec('libx264')
                       .audioCodec('aac')
                       .output(res)
                       .output('./video/' + film + '_s' + season + '_e' + episode + '.mp4')
                       .outputFormat('mp4')
                       .outputOptions('-movflags frag_keyframe+empty_moov')
                       .on('error', function(err) {
                           console.log('An error occurred: ' + err.message);
                       })
                       .on('progress', function(progress) {
                           console.log('Processing: ' + progress.targetSize + 'kb done');
                         })
                       .on('end', function() {
                           console.log('Processing finished !');
                       })
                       .addOutputOption('-acodec')
                       .run()

    Sorry if i’m not really clear, ask me some questions if you need more informations :)

    Thanks for your help, bye :)