Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Autres articles (101)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Modifier la date de publication

    21 juin 2013, par

    Comment changer la date de publication d’un média ?
    Il faut au préalable rajouter un champ "Date de publication" dans le masque de formulaire adéquat :
    Administrer > Configuration des masques de formulaires > Sélectionner "Un média"
    Dans la rubrique "Champs à ajouter, cocher "Date de publication "
    Cliquer en bas de la page sur Enregistrer

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (9418)

  • JavaScript MediaSource && ffmpeg chunks

    17 mai 2023, par OmriHalifa

    I have written the following code for a player that can receive chunks sent by ffmpeg through stdout and display them using mediaSource :

    


    index.js (server of this request)

    


    const express = require('express')
const app = express()
const port = 4545
const cp = require('child_process')
const cors = require('cors')
const { Readable } = require('stream');



app.use(cors())

app.get('/startRecording', (req, res) => {
    const ffmpeg = cp.spawn('ffmpeg', ['-f', 'dshow', '-i', 'video=HP Wide Vision HD Camera', '-profile:v', 'high', '-pix_fmt', 'yuvj420p', '-level:v', '4.1', '-preset', 'ultrafast', '-tune', 'zerolatency', '-vcodec', 'libx264', '-r', '10', '-b:v', '512k', '-s', '640x360', '-acodec', 'aac', '-ac', '2', '-ab', '32k', '-ar', '44100', '-f', 'mpegts', '-flush_packets', '0', '-' /*'udp://235.235.235.235:12345?pkt_size=1316'*/ ]);
   
    ffmpeg.stdout.on('data', (data) => {
        //console.log(`stdout: ${data}`);
        res.write(data)
    });

    ffmpeg.stderr.on('data', (data) => {
      const byteData = Buffer.from(data, 'utf8');  // Replace with your actual byte data
      const byteStream = new Readable();
      byteStream.push(byteData);
      byteStream.push(null);
      const encoding = 'utf8';
      let text = '';
      byteStream.on('data', (chunk) => {
        text += chunk.toString(encoding);
      });

      byteStream.on('end', () => {
        console.log(text);  // Output the converted text
      });


      //console.log({data})
        //res.write(data)
    });

    ffmpeg.on('close', (code) => {
        console.log(`child process exited with code ${code}`);
    });
})

app.listen(port, () => {
  console.log(`Video's Server listening on port ${port}`); 
});


    


    App.js (In react, the side of the player) :

    


    import { useEffect } from &#x27;react&#x27;;&#xA;&#xA;function App() {&#xA;  async function transcode() {&#xA;    const mediaSource = new MediaSource();&#xA;    const videoElement = document.getElementById(&#x27;videoElement&#x27;);&#xA;    videoElement.src = URL.createObjectURL(mediaSource);&#xA;  &#xA;    &#xA;    mediaSource.addEventListener(&#x27;sourceopen&#x27;, async () => {&#xA;      console.log(&#x27;MediaSource open&#x27;);&#xA;      const sourceBuffer = mediaSource.addSourceBuffer(&#x27;video/mp4; codecs="avc1.42c01e"&#x27;);&#xA;      try {&#xA;        const response = await fetch(&#x27;http://localhost:4545/startRecording&#x27;);&#xA;        const reader = response.body.getReader();&#xA;  &#xA;        reader.read().then(async function processText({ done, value }) {&#xA;          if (done) {&#xA;            console.log(&#x27;Stream complete&#x27;);&#xA;            return;&#xA;          }&#xA;&#xA;          console.log("B4 append", videoElement)&#xA;          await sourceBuffer.appendBuffer(value);&#xA;          console.log("after append",value);&#xA;          // Display the contents of the sourceBuffer&#xA;          sourceBuffer.addEventListener(&#x27;updateend&#x27;, function(e) {         if (!sourceBuffer.updating &amp;&amp; mediaSource.readyState === &#x27;open&#x27;) {           mediaSource.endOfStream();         }       });&#xA;  &#xA;          // Call next read and repeat the process&#xA;          return reader.read().then(processText);&#xA;        });&#xA;      } catch (error) {&#xA;        console.error(error);&#xA;      }&#xA;    });&#xA;&#xA;    console.log("B4 play")&#xA;    await videoElement.play();&#xA;    console.log("after play")&#xA;&#xA;  }&#xA;  &#xA;  &#xA;  useEffect(() => {}, []);&#xA;&#xA;  return (&#xA;    <div classname="App">&#xA;      <div>&#xA;        <video></video>&#xA;      </div>&#xA;      <button>start streaming</button>&#xA;    </div>&#xA;  );&#xA;}&#xA;&#xA;export default App;&#xA;&#xA;

    &#xA;

    this what i get :&#xA;what i get

    &#xA;

    the chunks are being received and passed to the Uint8Array correctly, but the video is not being displayed. why can be the result of this and how to correct it ?

    &#xA;

  • Create a 44-byte header with ffmpeg

    13 juillet 2015, par Joe Allen

    I made a program using ffmpeg libraries that converts an audio file to a wav file. Except the only problem is that it doesn’t create a 44-byte header. When input the file into Kaldi Speech Recognition, it produces the error :

    ERROR (online2-wav-nnet2-latgen-faster:Read4ByteTag():wave-reader.cc:74) WaveData: expected 4-byte chunk-name, got read errror

    I ran the file thru shntool and it reports a 78-byte header. Is there anyway I can get the standard 44-byte header using ffmpeg libraries ?

  • How to save python compatible audio file from JavaScript blob

    16 septembre 2020, par Talha Anwar

    I am trying to save an audio blob to the backend.&#xA;Here is an audio blob

    &#xA;

     const blob = new Blob(chunks, { &#x27;type&#x27; : &#x27;audio/wav; codecs=0&#x27; });&#xA;

    &#xA;

    Here is the upload function

    &#xA;

    function uploadAudio( blob ) {&#xA;  var reader = new FileReader();&#xA;  reader.onload = function(event){&#xA;    var fd = {};&#xA;    fd["data"] = event.target.result;&#xA;    $.ajax({&#xA;     // contentType:"application/x-www-form-urlencoded; charset=UTF-8",&#xA;      type: &#x27;POST&#x27;,&#xA;      url: &#x27;testing/&#x27;,&#xA;      data: fd,&#xA;      dataType: &#x27;text&#x27;&#xA;    }).done(function(data) {&#xA;        console.log(data);&#xA;        document.getElementById("response").innerHTML=data;&#xA;       // alert(data);&#xA;    });&#xA;  };&#xA;

    &#xA;

    Here is the function to save the file.

    &#xA;

    def upload_audio(request):&#xA;    print(&#x27;upload_audio&#x27;)&#xA;    if request.is_ajax():&#xA;        &#xA;        req=request.POST.get(&#x27;data&#x27;)&#xA;        d=req.split(",")[1]&#xA;        print("Yes, AJAX!")&#xA;        #print(request.body)&#xA;        f = open(&#x27;./file.wav&#x27;, &#x27;wb&#x27;)&#xA;        &#xA;        f.write(base64.b64decode(d))&#xA;        #f.write(request.body)&#xA;        f.close()&#xA;    return HttpResponse(&#x27;audio received&#x27;)&#xA;

    &#xA;

    When I try to read it in python for converting to text. I got following error

    &#xA;

    ValueError: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format&#xA;

    &#xA;

    I tried to convert the file

    &#xA;

    import ffmpeg&#xA;stream = ffmpeg.input(&#x27;file.wav&#x27;)&#xA;stream = ffmpeg.output(stream, &#x27;filen.wav&#x27;)&#xA;ffmpeg.run(stream)&#xA;

    &#xA;

    I got following error

    &#xA;

    Traceback (most recent call last):&#xA;  File "script.py", line 8, in <module>&#xA;    ffmpeg.run(stream)&#xA;  File "C:\Anaconda3\envs\VA\lib\site-packages\ffmpeg\_run.py", line 320, in run&#xA;    overwrite_output=overwrite_output,&#xA;  File "C:\Anaconda3\envs\VA\lib\site-packages\ffmpeg\_run.py", line 285, in run_async&#xA;    args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream&#xA;  File "C:\Anaconda3\envs\VA\lib\subprocess.py", line 729, in __init__&#xA;    restore_signals, start_new_session)&#xA;  File "C:\Anaconda3\envs\VA\lib\subprocess.py", line 1017, in _execute_child&#xA;    startupinfo)&#xA;FileNotFoundError: [WinError 2] The system cannot find the file specified&#xA;</module>

    &#xA;