Recherche avancée

Médias (1)

Mot : - Tags -/copyleft

Autres articles (76)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • XMP PHP

    13 mai 2011, par

    Dixit Wikipedia, XMP signifie :
    Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
    Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
    XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)

Sur d’autres sites (7473)

  • Capturing audio data (using javascript) and uploading on a server as MP3

    4 septembre 2018, par Michel

    Following a number of resources on the internet, I am trying to build a simple web page, where I can go to record something (my voice), then make a mp3 file out of the recording and finally upload that file to a server.

    At this point I can do the recording and also play back, but I haven’t gone as far as uploading, it seems like I cannot even make an mp3 file locally.
    Can someone tell me what I am doing wrong, or in the wrong order ?

    Below is all the code I have at this point.

       
       
       
       


    <div>
       <h2>Audio record and playback</h2>
       <p>
           <button></button></p><h3>Start</h3>
           <button disabled="disabled"><h3>Stop</h3></button>
           <audio controls="controls"></audio>
           <a></a>
       
    </div>

    <code class="echappe-js">&lt;script&gt;<br />
     var player = document.getElementById('player');<br />
    <br />
     var handleSuccess = function(stream) {<br />
       rec = new MediaRecorder(stream);<br />
    <br />
       rec.ondataavailable = e =&gt; {<br />
           audioChunks.push(e.data);<br />
           if (rec.state == &quot;inactive&quot;) {<br />
               let blob = new Blob(audioChunks,{type:'audio/x-mpeg-3'});<br />
               player.src = URL.createObjectURL(blob);<br />
               player.controls=true;<br />
               player.autoplay=true;<br />
               // audioDownload.href = player.src;<br />
               // audioDownload.download = 'sound.data';<br />
               // audioDownload.innerHTML = 'Download';<br />
               mp3Build();<br />
           }<br />
       }<br />
    <br />
       player.src = stream;<br />
     };<br />
    <br />
     navigator.mediaDevices.getUserMedia({audio:true/*, video: false */})<br />
         .then(handleSuccess);<br />
    <br />
    startRecord.onclick = e =&gt; {<br />
     startRecord.disabled = true;<br />
     stopRecord.disabled=false;<br />
     audioChunks = [];<br />
     rec.start();<br />
    }<br />
    <br />
    stopRecord.onclick = e =&gt; {<br />
     startRecord.disabled = false;<br />
     stopRecord.disabled=true;<br />
     rec.stop();<br />
    }<br />
    <br />
    <br />
    var ffmpeg = require('ffmpeg');<br />
    <br />
    function mp3Build() {<br />
    try {<br />
       var process = new ffmpeg('sound.data');<br />
       process.then(function (audio) {<br />
           // Callback mode.<br />
           audio.fnExtractSoundToMP3('sound.mp3', function (error, file) {<br />
               if (!error) {<br />
                   console.log('Audio file: ' + file);<br />
           audioDownload.href = player.src;<br />
           audioDownload.download = 'sound.mp3';<br />
           audioDownload.innerHTML = 'Download';<br />
         } else {<br />
           console.log('Error-fnExtractSoundToMP3: ' + error);<br />
         }<br />
           });<br />
       }, function (err) {<br />
           console.log('Error: ' + err);<br />
       });<br />
    } catch (e) {<br />
       console.log(e.code);<br />
       console.log(e.msg);<br />
    }<br />
    }<br />
    <br />
    &lt;/script&gt;

    When I try to investigate and see what is happening using the Debugger inside the Web Console ; on the line :

    var process = new ffmpeg('sound.data');

    I get this message :

    Paused on exception
    TypeError ffmpeg is not a contructor.

    And on the line :

    var ffmpeg = require('ffmpeg');

    I get this message :

    Paused on exception
    ReferenceError require is not defined.

    Beside when I watch the expression ffmpeg, I can see :

    ffmpeg: undefined

    After some further investigations, and using browserify I use the following code :

       
       
       
       


    <div>
       <h2>Audio record and playback</h2>
       <p>
           <button></button></p><h3>Start</h3>
           <button disabled="disabled"><h3>Stop</h3></button>
           <audio controls="controls"></audio>
           <a></a>
       
    </div>

    <code class="echappe-js">&lt;script src='http://stackoverflow.com/feeds/tag/bundle.js'&gt;&lt;/script&gt;
    &lt;script&gt;<br />
     var player = document.getElementById('player');<br />
    <br />
     var handleSuccess = function(stream) {<br />
       rec = new MediaRecorder(stream);<br />
    <br />
       rec.ondataavailable = e =&gt; {<br />
           if (rec.state == &quot;inactive&quot;) {<br />
               let blob = new Blob(audioChunks,{type:'audio/x-mpeg-3'});<br />
               //player.src = URL.createObjectURL(blob);<br />
               //player.srcObject = URL.createObjectURL(blob);<br />
               //player.srcObject = blob;<br />
               player.srcObject = stream;<br />
               player.controls=true;<br />
               player.autoplay=true;<br />
               // audioDownload.href = player.src;<br />
               // audioDownload.download = 'sound.data';<br />
               // audioDownload.innerHTML = 'Download';<br />
               mp3Build();<br />
           }<br />
       }<br />
    <br />
       //player.src = stream;<br />
       player.srcObject = stream;<br />
     };<br />
    <br />
     navigator.mediaDevices.getUserMedia({audio:true/*, video: false */})<br />
         .then(handleSuccess);<br />
    <br />
    startRecord.onclick = e =&gt; {<br />
     startRecord.disabled = true;<br />
     stopRecord.disabled=false;<br />
     audioChunks = [];<br />
     rec.start();<br />
    }<br />
    <br />
    stopRecord.onclick = e =&gt; {<br />
     startRecord.disabled = false;<br />
     stopRecord.disabled=true;<br />
     rec.stop();<br />
    }<br />
    <br />
    <br />
    var ffmpeg = require('ffmpeg');<br />
    <br />
    function mp3Build() {<br />
    try {<br />
       var process = new ffmpeg('sound.data');<br />
       process.then(function (audio) {<br />
           // Callback mode.<br />
           audio.fnExtractSoundToMP3('sound.mp3', function (error, file) {<br />
               if (!error) {<br />
                   console.log('Audio file: ' + file);<br />
           //audioDownload.href = player.src;<br />
           audioDownload.href = player.srcObject;<br />
           audioDownload.download = 'sound.mp3';<br />
           audioDownload.innerHTML = 'Download';<br />
         } else {<br />
           console.log('Error-fnExtractSoundToMP3: ' + error);<br />
         }<br />
           });<br />
       }, function (err) {<br />
           console.log('Error: ' + err);<br />
       });<br />
    } catch (e) {<br />
       console.log(e.code);<br />
       console.log(e.msg);<br />
    }<br />
    }<br />
    <br />
    &lt;/script&gt;

    That solved the problem of :

    the expression ffmpeg being: undefined

    But the play back is no longer working. I may not be doing the right thing with player.srcObject and maybe some other things too.

    When I use this line :

    player.srcObject = URL.createObjectURL(blob);

    I get this message :

    Paused on exception
    TypeError: Value being assigned to HTMLMediaElement.srcObject is not an object.

    And when I use this line :

    player.srcObject = blob;

    I get this message :

    Paused on exception
    TypeError: Value being assigned to HTMLMediaElement.srcObject does not implement interface MediaStream.

    Finally, if I use this :

    player.srcObject = stream;

    I do not get any error message but the voice recording still does not work.

  • How to convert a video and audio file to be smoothly played via Media Source Extension API ?

    4 octobre 2018, par Aman

    I have built a web video player using the Media Source Extension API. I have been testing my video player using local video and audio files on my PC. Everything works perfectly expect the video keeps buffering. I’m playing a 4k 60fps video, which I downloaded from YouTube. My PC is not 4k resolution, but the video smoothly plays through YouTube and VLC Media Player. I’m just surprised to why my Media Source Extension Video Player buffers even through the video and audio file are not being retrieved via network. I’m assuming that the video and audio files I’m using are causing this problem. So I will explain how I created my video and audio files first :

    1. I downloaded the video from https://www.youtube.com/watch?v=KaCQ8SQ6ZHQ&t=3s using the 4K Video Downloader https://www.4kdownload.com/products/product-videodownloader.

    2. Convert the mkv (the 4K Video Downloader only allows the 4k 60fps video to be downloaded in mkv format, for me) file to mp4 using ffmpeg in CMD : ffmpeg -i test.mkv -codec copy test.mp4.

    3. Converting the test.mp4 file to my preferred 4K resolution 3840x2160 from 3840x1632 using ffmpeg in CMD : ffmpeg -i test.mp4 -s 3840x2160 -c:a copy test_changed.mp4. (NOT SO IMPORTANT)

    4. Separating the video and audio of test_changed.mp4 to video.mp4 for video and audio.mp4 for audio using MP4Box in CMD : Video - MP4Box -single 1 test_changed.mp4 -out video.mp4 and Audio - MP4Box -single 2 test_changed.mp4 -out audio.mp4.

    5. Splitting both video.mp4 and audio.mp4 into 30 split parts each containing 5 seconds of the video and audio file. So I end up having (video_1.mp4,audio_1.mp4), (video_2.mp4,audio_2.mp4), (video_3.mp4,audio_3.mp4), ..... (video_29.mp4,audio_29.mp4), (video_30.mp4,audio_30.mp4). Using ffmpeg and one by one specifying the time range for each part in CMD :

      [For Part 1 : ffmpeg -ss 00:00:00 -to 00:00:05 -i video.mp4 video_1.mp4, ffmpeg -ss 00:00:00 -to 00:00:05 -i audio.mp4 audio_1.mp4],

      [For Part 2 : ffmpeg -ss 00:00:05 -to 00:00:10 -i video.mp4 video_2.mp4, ffmpeg -ss 00:00:05 -to 00:00:10 -i audio.mp4 audio_2.mp4],

      [For Part 3 : ffmpeg -ss 00:00:10 -to 00:00:15 -i video.mp4 video_3.mp4, ffmpeg -ss 00:00:10 -to 00:00:15 -i audio.mp4 audio_3.mp4],

      .....

      [For Part 29 : ffmpeg -ss 00:02:20 -to 00:02:25 -i video.mp4 video_29.mp4, ffmpeg -ss 00:02:20 -to 00:02:25 -i audio.mp4 audio_29.mp4],

      [For Part 30 : ffmpeg -ss 00:02:25 -to 00:02:30 -i video.mp4 video_30.mp4, ffmpeg -ss 00:02:25 -to 00:02:30 -i audio.mp4 audio_30.mp4].

    6. Fragmenting each of the video and audio parts using MP4Box in CMD(As far as I know, fragmented mp4 files are only files played via Media Source Extension API) :

      [For Part 1 : MP4Box -dash 1000 -rap -frag-rap video_1.mp4, MP4Box -dash 1000 -rap -frag-rap audio_1.mp4],

      [For Part 2 : MP4Box -dash 1000 -rap -frag-rap video_2.mp4, MP4Box -dash 1000 -rap -frag-rap audio_2.mp4],

      [For Part 3 : MP4Box -dash 1000 -rap -frag-rap video_3.mp4, MP4Box -dash 1000 -rap -frag-rap audio_3.mp4],

      .....

      [For Part 29 : MP4Box -dash 1000 -rap -frag-rap video_29.mp4, MP4Box -dash 1000 -rap -frag-rap audio_29.mp4],

      [For Part 30 : MP4Box -dash 1000 -rap -frag-rap video_30.mp4, MP4Box -dash 1000 -rap -frag-rap audio_30.mp4].

    7. I receive a fragmented file for each file with "_dashinit" being in it e.g. For Part 1 : video_1_dashinit.mp4 and audio_1_dashinit.mp4. These are the files I’m playing through Media Source Extension API.

    So I’m appending these files into my sourceBuffers and playing it with the video. I have given the test.zip file here (https://drive.google.com/file/d/1tyPBTxgpS601Xs5VEWznYhWw9PwhMHsB/view?usp=sharing) containing the test sample.

    I’m using this command in CMD to run Chrome and test my file : chrome.exe --allow-file-access-from-files

    Anyone can use this test sample and see if the video is buffering for them too. Please comment about anything I’m doing wrong, or help me construct a better 5 seconds video and audio files for MSE playable. Thanks

  • download youtube video as audio file, with URL in filename, to a specific output directory

    9 octobre 2018, par thanks_in_advance

    I do this to download a video as an audio file (mp3), with the video’s youtube URL (URI actually) in the audio file’s filename (I like having the URI in the filename because it helps me identify which video I grabbed the audio from) :

    youtube-dl --extract-audio --audio-format mp3 --prefer-ffmpeg --ffmpeg-location "C:\FFMPEG" "https://www.youtube.com/watch?v=k1-TrAvp_xs" --audio-quality 0

    The con with this approach : with this command, the file downloads to the same directory that contains youtube-dl.exe


    I do this to download a youtube video as an audio file (mp3) to a specific output directory :

    youtube-dl -o "C:\Documents\Downloads\%(title)s.%(ext)s" --extract-audio --audio-format mp3 --prefer-ffmpeg --ffmpeg-location "C:\FFMPEG" "https://www.youtube.com/watch?v=k1-TrAvp_xs" --audio-quality 0

    The con with this approach : with this command, the downloaded audio file’s filename doesn’t contain the youtube video’s URI.


    My Question : How can I combine the above 2 commands such that the downloaded audio file doesn’t have either of the cons mentioned above ?