Recherche avancée

Médias (0)

Mot : - Tags -/protocoles

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (46)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

Sur d’autres sites (7709)

  • NodeJS - efficiently and correctly convert from raw PCM to WAV at scale (without FFMPEG ?)

    13 juillet 2024, par Royi Bernthal

    I have a stream of raw PCM buffers I need to convert to playable WAV buffers.

    


    @ffmpeg.wasm can convert an individual buffer in the stream well, but it's limited to executing 1 command at a time, so it won't work in a real-life streaming scenario (streams x concurrent users). We can use it as a reference to a conversion that outputs a good playable wav.

    


    import { FFmpeg, createFFmpeg, fetchFile } from '@ffmpeg.wasm/main';

async pcmToWavFFMPEG(buffer: Buffer) {
    // bitDepth - PCM signed 16-bit little-endian
    const options = { sampleRate: '24k', channels: '1', bitDepth: 's16le' };

    this.ffmpeg.FS('writeFile', 'input.pcm', await fetchFile(buffer));

    await this.ffmpeg.run(
      '-f',
      options.bitDepth,
      '-ar',
      options.sampleRate,
      '-ac',
      options.channels,
      '-i',
      'input.pcm',
      'output.wav',
    );

    const wavBuffer = this.ffmpeg.FS('readFile', 'output.wav');

    this.ffmpeg.FS('unlink', `input.pcm`);
    this.ffmpeg.FS('unlink', `output.wav`);

    return Buffer.from(wavBuffer);
  }


    


    In order to get over the command execution limit, I've tried fluent-ffmpeg. I couldn't find a way to convert a single buffer, so I'm just passing the whole readable stream so that ffmpeg can convert all of its buffers to wav. The buffers I'm getting in on('data') aren't playable wav. The same is true for concatting the accumulated buffers in on('complete') - the result is not a playable wav.

    


    import ffmpeg from 'fluent-ffmpeg';
import internal from 'stream';

async pcmToWavFluentFFMPEG(
    readable: internal.Readable,
    callback: (chunk: Buffer) => void,
  ) {
    const options = { sampleRate: 24000, channels: 1, bitDepth: 's16le' };

    ffmpeg(readable)
      .inputFormat(options.bitDepth)
      .audioFrequency(options.sampleRate)
      .audioChannels(options.channels)
      .outputFormat('wav')
      .pipe()
      .on('data', callback);
  }


    


    I've also tried using node-wav to convert each buffer individually. It manages to convert everything to playable wavs that sound close to the desired result, however for some reason they're extremely loud and sound a bit weird.

    


    import wav from 'node-wav';

pcmToWavBad(buffer: Buffer) {
    const pcmData = new Int16Array(
      buffer.buffer,
      buffer.byteOffset,
      buffer.byteLength / Int16Array.BYTES_PER_ELEMENT,
    );

    const channelData = [pcmData]; // assuming mono channel

    return wav.encode(channelData, { sampleRate: 24000, bitDepth: 16 });
  }


    


    I've also tried wrapping the PCM as a WAV with wavefile without any actual conversion (which is redundant as PCM is contained as is in WAV), but it results in white noise :

    


    import { WaveFile } from 'wavefile';

pcmToWav(buffer: Buffer) {
    const wav = new WaveFile();

    wav.fromScratch(1, 24000, '16', buffer); // 's16le' is invalid

    return Buffer.from(wav.toBuffer());
  }


    


  • Adding A New System To The Game Music Website

    1er août 2012, par Multimedia Mike — General

    At first, I was planning to just make a little website where users could install a Chrome browser extension and play music from old 8-bit NES games. But, like many software projects, the goal sort of ballooned. I created a website where users can easily play old video game music. It doesn’t cover too many systems yet, but I have had individual requests to add just about every system you can think of.

    The craziest part is that I know it’s possible to represent most of the systems. Eventually, it would be great to reach Chipamp parity (a combination plugin for Winamp that packages together plugins for many of these chiptunes). But there is a process to all of this. I have taken to defining a number of phases that are required to get a new system covered.

    Phase 0 informally involves marveling at the obscurity of some of the console systems for which chiptune collections have evolved. WonderSwan ? Sharp X68000 ? PC-88 ? I may be viewing this through a terribly Ameri-centric lens. I’ve at least heard of the ZX Spectrum and the Amstrad CPC even if I’ve never seen either.

    No matter. The goal is to get all their chiptunes cataloged and playable.

    Phase 1 : Finding A Player
    The first step is to find a bit of open source code that can play a particular format. If it’s a library that can handle many formats, like Game Music Emu or Audio Overload SDK, even better (probably). The specific open source license isn’t a big concern for me. I’m almost certain that some of the libraries that SaltyGME currently mixes are somehow incompatible, license-wise. I’ll worry about it when I encounter someone who A) cares, and B) is in a position to do something about it. Historical preservation comes first, and these software libraries aren’t getting any younger (I’m finding some that haven’t been touched in a decade).

    Phase 2 : Test Program
    The next phase is to create a basic test bench program that sends a music file into the library, generates a buffer of audio, and shoves it out to the speakers via PulseAudio’s simple API (people like to rip on PulseAudio, but its simple API really lives up to its name and requires pages less boilerplate code to play a few samples than ALSA).

    Phase 3 : Plug Into Web Player
    After successfully creating the test bench and understanding exactly which source files need to be built, the next phase is to hook it up to the main SaltyGME program via the ad-hoc plugin API I developed. This API requires that a player backend can, at the very least, initialize itself based on a buffer of bytes and generate audio samples into an array of 16-bit numbers. The API also provides functions for managing files with multiple tracks and toggling individual voices/channels if the library supports such a feature. Having the test bench application written beforehand usually smooths out this step.

    But really, I’m just getting started.

    Phase 4 : Collecting A Song Corpus
    Then there is the matter of staging a collection of songs for a given system. It seems like it would just be a matter of finding a large collection of songs for a given format, downloading them in bulk, and mirroring them. Honestly, that’s the easy part. People who are interested in this stuff have been lovingly curating massive collections of these songs for years (see SNESmusic.org for one of the best examples, and they also host a torrent of all their music for really quick and easy hoarding).

    In my drive to make this game music website more useful for normal people, the goal is to extract as much metadata as possible to make searching better, and to package the data so that it’s as convenient as possible for users. Whenever I seek to add a new format to the collection, this is the phase where I invariably find that I have to fundamentally modify some of the assumptions I originally made in the player.

    First, there were the NES Sound Format (NSF) files, the original format I wanted to play. These are files that have any number of songs packed into a single file. Playback libraries expose APIs to jump to individual tracks. So the player was designed around that. Game Boy GBS files also fall into this category but present a different challenge vis-à-vis metadata, addressed in the next phase.

    Then, there were the SPC files. Each SPC file is its own song and multiple SPC files are commonly bundled as RAR files. Not wanting to deal with RAR, or any format where I interacted with a general compression API to pull a few files out, I created a custom resource format (inspired by so many I have studied and documented) and compressed it with a simpler compression API. I also had to modify some of the player’s assumptions to deal with this archive format. Genesis VGMs, bundled either in .zip or .7z, followed the same model as SPC in RAR.

    Then it was suggested that I attempt to bring SaltyGME closer to feature parity with Chipamp, rather than just being a Chrome browser frontend for Game Music Emu. When I studied the Portable Sound Format (PSF), I realized it didn’t fit into the player model I already had. PSF uses a sort of shared library model for code execution and I developed another resource archive format to cope with it. So that covers quite a few formats.

    One more architecture challenge arose when I started to study one of the prevailing metadata formats, explained in the next phase.

    Phase 5 : Metadata
    Finally, for the collections to really be useful, I need to harvest that juicy metadata for search and presentation.

    I have created a series of programs and scripts to scrape metadata out of these music files and store it all in a database that drives the website and search engine. I recognize that it’s no good to have a large corpus of songs with minimal metadata and while importing bulk quantities of music, the scripts harshly reject songs that have too little metadata.

    Again, challenges abound. One of the biggest challenges I’m facing is the peculiar quasi-freeform metadata format that emerged as .m3u that takes a form similar to :

    #################################################################
    #
    # GRADIUS2
    # (c) KONAMI  by Furukawa Motoaki, IKACHAN
    #
    #################################################################
    

    nemesis2.kss::KSS,62,[Nemesis2] (Opening),2:23,,0
    nemesis2.kss::KSS,61,[Nemesis2] (Start),7,,0
    nemesis2.kss::KSS,43,[Nemesis2] (Air Battle),34,0-
    nemesis2.kss::KSS,44,[Nemesis2] (1st. BGM),51,0-
    [...]

    A lot of file formats (including Game Boy GBS mentioned earlier) store their metadata separately using this format. I have some ideas about tools I can use to help me process this data but I’m pretty sure each one will require some manual intervention.

    As alluded to in phase 4, .m3u presents another architectural challenge : Notice the second field in the CSV .m3u data. That’s a track number. A player can’t expect every track in a bundled chiptune file to be valid, nor to be in any particular order. Thus, I needed to alter the architecture once more to take this into account. However, instead of modifying the SaltyGME player, I simply extended the metadata database to include a playback order which, by default, is the same as the track order but can also accommodate this new issue. This also has the bonus of providing a facility to exclude playback of certain tracks. This comes in handy for many PSF archives which tend to include files that only provide support for other files and aren’t meant to be played on their own.

    Bright Side
    The reward for all of this effort is that the data lands in a proper database in the end. None of it goes back into the chiptune files themselves. This makes further modification easier as all of the data that is indexed and presented on the site comes from the database. Somewhere down the road, I should probably create an API for accessing this metadata.

  • Creating a continuous stream for RTMP in Node.js

    9 mars 2023, par hankthetank27

    I'm working on an app that downloads audio from youtube that will be streamed sequentially, similar to radio broadcast. I'm having trouble getting the individual tracks to stream continuously. My idea was to write the tracks sequentially into a readable stream that then is read by FFMPEG. Here is the code I'm having trouble with...

    


    import ytdl from "ytdl-core";&#xA;import ffmpeg from &#x27;fluent-ffmpeg&#x27;;&#xA;import { Readable } from "node:stream"&#xA;&#xA;export async function startAudioStream(): Promise<void>{&#xA;&#xA;  const mainStream = await createStreamedQueue()&#xA;&#xA;  ffmpeg(mainStream)&#xA;    .inputOptions([&#xA;      &#x27;-re&#x27;&#xA;    ])&#xA;    .outputOption([&#xA;      // &#x27;-c:v libx264&#x27;,&#xA;      // &#x27;-preset veryfast&#x27;,&#xA;      // &#x27;-tune zerolatency&#x27;,&#xA;      &#x27;-c:a aac&#x27;,&#xA;      &#x27;-ar 44100&#x27;,&#xA;    ])&#xA;    .save(&#x27;rtmp://localhost/live/main.flv&#x27;);&#xA;};&#xA;&#xA;async function createStreamedQueue(): Promise<readable>{&#xA;&#xA;  function createStream(): Readable{&#xA;    const stream = new Readable({&#xA;      read(){},&#xA;      highWaterMark: 1024 * 512,&#xA;    });&#xA;    stream._destroy = () => { stream.destroyed = true };&#xA;    return stream;&#xA;  }&#xA;&#xA;  const mainStream = createStream();&#xA;&#xA;  const ref1 = &#x27;https://youtu.be/lLCEUpIg8rE&#x27;&#xA;  const ref2 = &#x27;https://youtu.be/bRdyzdXJ0KA&#x27;;&#xA;&#xA;  function queueSong(src: string, stream: Readable): Promise<void>{&#xA;    return new Promise<void>((resolve, reject) => {&#xA;      ytdl(src, {&#xA;          filter: &#x27;audioonly&#x27;,&#xA;          quality: &#x27;highestaudio&#x27;&#xA;        })&#xA;        .on(&#x27;data&#x27;, (data) => {&#xA;          stream.push(data);&#xA;        })&#xA;        .on(&#x27;end&#x27;, () => {&#xA;          resolve();&#xA;        })&#xA;        .on(&#x27;error&#x27;, (err) => {&#xA;          console.error(&#x27;Error downloading file from YouTube.&#x27;, err);&#xA;          reject(err);&#xA;        })&#xA;    })&#xA;  }&#xA;  &#xA;  await queueSong(ref1, mainStream);&#xA;  // console.log(&#x27;after firsrt: &#x27;, mainStream)&#xA;  await queueSong(ref2, mainStream);&#xA;  // console.log(&#x27;after second: &#x27;, mainStream)&#xA;  return mainStream;&#xA;};&#xA;</void></void></readable></void>

    &#xA;

    To start, startAudioStream is called to initiate a readable stream of audio to an RTMP server via FFMPEG. That is working fine. The part I'm having trouble with is "queuing" the tracks into the stream that's being fed into FFMPEG. Right now, I have a "main" stream that each songs data is being pushed into, as you can see in queueSong. At the end of ytdl stream, the promise is resolved, allowing for the next song to be queued and its data to be pushed into mainStream. The issue that I'm experiencing is that the audio from ref1 is only every played.

    &#xA;

    I can see in the logs that mainStream does grow in length after each call to queueSong, but still will only stream the audio from the first track. My initial thought was that there is a terminating character at the of the last data chunk thats being written to the steam for each song ? But maybe im getting screwed up on how streams work...

    &#xA;