Recherche avancée

Médias (0)

Mot : - Tags -/performance

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

Autres articles (112)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

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

  • ffmpeg Audiosegment error in get audio chunks in socketIo server in python

    26 janvier 2024, par a_crszkvc30Last_NameCol

    I want to send each audio chunk every minute.
this is the test code and i want to save audiofile and audio chunk file.
then, i will combine two audio files stop button was worked correctly but with set time function is not worked in python server.
there is python server code with socketio

    


    def handle_voice(sid,data): # blob 으로 들어온 데이터 
    # BytesIO를 사용하여 메모리 상에서 오디오 데이터를 로드
    audio_segment = AudioSegment.from_file(BytesIO(data), format="webm")
    directory = "dddd"
    # 오디오 파일로 저장
    #directory = str(names_sid.get(sid))
    if not os.path.exists(directory):
        os.makedirs(directory)
 
    # 오디오 파일로 저장
    file_path = os.path.join(directory, f'{sid}.wav')
    audio_segment.export(file_path, format='wav') 
    print('오디오 파일 저장 완료')`
 


    


    and there is client

    


    &#xA;&#xA;&#xA;&#xA;    &#xA;    &#xA;    <code class="echappe-js">&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.2/socket.io.js&quot;&gt;&lt;/script&gt;&#xA;&#xA;&#xA;&#xA;    &#xA;    
    

    &#xA;

    &#xA;

    &#xA; &lt;script&gt;&amp;#xA;        var socket = io(&amp;#x27;http://127.0.0.1:5000&amp;#x27;);&amp;#xA;        const record = document.getElementById(&quot;record&quot;)&amp;#xA;        const stop = document.getElementById(&quot;stop&quot;)&amp;#xA;        const soundClips = document.getElementById(&quot;sound-clips&quot;)&amp;#xA;        const chkHearMic = document.getElementById(&quot;chk-hear-mic&quot;)&amp;#xA;&amp;#xA;        const audioCtx = new(window.AudioContext || window.webkitAudioContext)() // 오디오 컨텍스트 정의&amp;#xA;&amp;#xA;        const analyser = audioCtx.createAnalyser()&amp;#xA;        //        const distortion = audioCtx.createWaveShaper()&amp;#xA;        //        const gainNode = audioCtx.createGain()&amp;#xA;        //        const biquadFilter = audioCtx.createBiquadFilter()&amp;#xA;&amp;#xA;        function makeSound(stream) {&amp;#xA;            const source = audioCtx.createMediaStreamSource(stream)&amp;#xA;            socket.connect()&amp;#xA;            source.connect(analyser)&amp;#xA;            //            analyser.connect(distortion)&amp;#xA;            //            distortion.connect(biquadFilter)&amp;#xA;            //            biquadFilter.connect(gainNode)&amp;#xA;            //            gainNode.connect(audioCtx.destination) // connecting the different audio graph nodes together&amp;#xA;            analyser.connect(audioCtx.destination)&amp;#xA;&amp;#xA;        }&amp;#xA;&amp;#xA;        if (navigator.mediaDevices) {&amp;#xA;            console.log(&amp;#x27;getUserMedia supported.&amp;#x27;)&amp;#xA;&amp;#xA;            const constraints = {&amp;#xA;                audio: true&amp;#xA;            }&amp;#xA;            let chunks = []&amp;#xA;&amp;#xA;            navigator.mediaDevices.getUserMedia(constraints)&amp;#xA;                .then(stream =&gt; {&amp;#xA;&amp;#xA;                    const mediaRecorder = new MediaRecorder(stream)&amp;#xA;                    &amp;#xA;                    chkHearMic.onchange = e =&gt; {&amp;#xA;                        if(e.target.checked == true) {&amp;#xA;                            audioCtx.resume()&amp;#xA;                            makeSound(stream)&amp;#xA;                        } else {&amp;#xA;                            audioCtx.suspend()&amp;#xA;                        }&amp;#xA;                    }&amp;#xA;                    &amp;#xA;                    record.onclick = () =&gt; {&amp;#xA;                        mediaRecorder.start(1000)&amp;#xA;                        console.log(mediaRecorder.state)&amp;#xA;                        console.log(&quot;recorder started&quot;)&amp;#xA;                        record.style.background = &quot;red&quot;&amp;#xA;                        record.style.color = &quot;black&quot;&amp;#xA;                    }&amp;#xA;&amp;#xA;                    stop.onclick = () =&gt; {&amp;#xA;                        mediaRecorder.stop()&amp;#xA;                        console.log(mediaRecorder.state)&amp;#xA;                        console.log(&quot;recorder stopped&quot;)&amp;#xA;                        record.style.background = &quot;&quot;&amp;#xA;                        record.style.color = &quot;&quot;&amp;#xA;                    }&amp;#xA;&amp;#xA;                    mediaRecorder.onstop = e =&gt; {&amp;#xA;                        console.log(&quot;data available after MediaRecorder.stop() called.&quot;)&amp;#xA;                        const bb = new Blob(chunks, { &amp;#x27;type&amp;#x27; : &amp;#x27;audio/wav&amp;#x27; })&amp;#xA;                        socket.emit(&amp;#x27;voice&amp;#x27;,bb)&amp;#xA;                        const clipName = prompt(&quot;오디오 파일 제목을 입력하세요.&quot;, new Date())&amp;#xA;&amp;#xA;                        const clipContainer = document.createElement(&amp;#x27;article&amp;#x27;)&amp;#xA;                        const clipLabel = document.createElement(&amp;#x27;p&amp;#x27;)&amp;#xA;                        const audio = document.createElement(&amp;#x27;audio&amp;#x27;)&amp;#xA;                        const deleteButton = document.createElement(&amp;#x27;button&amp;#x27;)&amp;#xA;&amp;#xA;                        clipContainer.classList.add(&amp;#x27;clip&amp;#x27;)&amp;#xA;                        audio.setAttribute(&amp;#x27;controls&amp;#x27;, &amp;#x27;&amp;#x27;)&amp;#xA;                        deleteButton.innerHTML = &quot;삭제&quot;&amp;#xA;                        clipLabel.innerHTML = clipName&amp;#xA;&amp;#xA;                        clipContainer.appendChild(audio)&amp;#xA;                        clipContainer.appendChild(clipLabel)&amp;#xA;                        clipContainer.appendChild(deleteButton)&amp;#xA;                        soundClips.appendChild(clipContainer)&amp;#xA;&amp;#xA;                        audio.controls = true&amp;#xA;                        const blob = new Blob(chunks, {&amp;#xA;                            &amp;#x27;type&amp;#x27;: &amp;#x27;audio/ogg codecs=opus&amp;#x27;&amp;#xA;                        })&amp;#xA;&amp;#xA;                        chunks = []&amp;#xA;                        const audioURL = URL.createObjectURL(blob)&amp;#xA;                        audio.src = audioURL&amp;#xA;                        console.log(&quot;recorder stopped&quot;)&amp;#xA;&amp;#xA;                        deleteButton.onclick = e =&gt; {&amp;#xA;                            evtTgt = e.target&amp;#xA;                            evtTgt  .parentNode.parentNode.removeChild(evtTgt.parentNode)&amp;#xA;                        }&amp;#xA;                    }&amp;#xA;&amp;#xA;                  mediaRecorder.ondataavailable = function(e) {&amp;#xA;                    chunks.push(e.data)&amp;#xA;                    if (chunks.length &gt;= 5)&amp;#xA;                    {&amp;#xA;                        const bloddb = new Blob(chunks, { &amp;#x27;type&amp;#x27; : &amp;#x27;audio/wav&amp;#x27; })&amp;#xA;                        socket.emit(&amp;#x27;voice&amp;#x27;, bloddb)&amp;#xA;                         &amp;#xA;                        chunks = []&amp;#xA;                    }&amp;#xA;                    mediaRecorder.sendData = function(buffer) {&amp;#xA;                        const bloddb = new Blob(buffer, { &amp;#x27;type&amp;#x27; : &amp;#x27;audio/wav&amp;#x27; })&amp;#xA;                        socket.emit(&amp;#x27;voice&amp;#x27;, bloddb)&amp;#xA;}&amp;#xA;};&amp;#xA;                })&amp;#xA;                .catch(err =&gt; {&amp;#xA;                    console.log(&amp;#x27;The following error occurred: &amp;#x27; &amp;#x2B; err)&amp;#xA;                })&amp;#xA;        }&amp;#xA;    &lt;/script&gt;&#xA;&#xA;

    &#xA;

    ask exception was never retrieved&#xA;future: <task finished="finished" coro="<InstrumentedAsyncServer._handle_event_internal()" defined="defined" at="at"> exception=CouldntDecodeError(&#x27;Decoding failed. ffmpeg returned error code: 3199971767\n\nOutput from ffmpeg/avlib:\n\nffmpeg version 6.1.1-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers\r\n  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)\r\n  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint\r\n  libavutil      58. 29.100 / 58. 29.100\r\n  libavcodec     60. 31.102 / 60. 31.102\r\n  libavformat    60. 16.100 / 60. 16.100\r\n  libavdevice    60.  3.100 / 60.  3.100\r\n  libavfilter     9. 12.100 /  9. 12.100\r\n  libswscale      7.  5.100 /  7.  5.100\r\n  libswresample   4. 12.100 /  4. 12.100\r\n  libpostproc    57.  3.100 / 57.  3.100\r\n[cache @ 000001d9828efe40] Inner protocol failed to seekback end : -40\r\n[matroska,webm @ 000001d9828efa00] EBML header parsing failed\r\n[cache @ 000001d9828efe40] Statistics, cache hits:0 cache misses:3\r\n[in#0 @ 000001d9828da3c0] Error opening input: Invalid data found when processing input\r\nError opening input file cache:pipe:0.\r\nError opening input files: Invalid data found when processing input\r\n&#x27;)>&#xA;Traceback (most recent call last):&#xA;  File "f:\fastapi-socketio-wb38\.vent\Lib\site-packages\socketio\async_admin.py", line 276, in _handle_event_internal&#xA;    ret = await self.sio.__handle_event_internal(server, sid, eio_sid,&#xA;          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#xA;  File "f:\fastapi-socketio-wb38\.vent\Lib\site-packages\socketio\async_server.py", line 597, in _handle_event_internal&#xA;    r = await server._trigger_event(data[0], namespace, sid, *data[1:])&#xA;        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#xA;  File "f:\fastapi-socketio-wb38\.vent\Lib\site-packages\socketio\async_server.py", line 635, in _trigger_event&#xA;    ret = handler(*args)&#xA;          ^^^^^^^^^^^^^^&#xA;  File "f:\fastapi-socketio-wb38\Python-Javascript-Websocket-Video-Streaming--main\poom2.py", line 153, in handle_voice&#xA;    audio_segment = AudioSegment.from_file(BytesIO(data), format="webm")&#xA;                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#xA;  File "f:\fastapi-socketio-wb38\.vent\Lib\site-packages\pydub\audio_segment.py", line 773, in from_file&#xA;    raise CouldntDecodeError(&#xA;pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 3199971767&#xA;&#xA;Output from ffmpeg/avlib:&#xA;&#xA;ffmpeg version 6.1.1-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)&#xA;  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint&#xA;  libavutil      58. 29.100 / 58. 29.100&#xA;  libavcodec     60. 31.102 / 60. 31.102&#xA;  libavformat    60. 16.100 / 60. 16.100&#xA;  libavdevice    60.  3.100 / 60.  3.100&#xA;  libavfilter     9. 12.100 /  9. 12.100&#xA;  libswscale      7.  5.100 /  7.  5.100&#xA;  libswresample   4. 12.100 /  4. 12.100&#xA;  libpostproc    57.  3.100 / 57.  3.100&#xA;[cache @ 000001d9828efe40] Inner protocol failed to seekback end : -40&#xA;[matroska,webm @ 000001d9828efa00] EBML header parsing failed&#xA;[cache @ 000001d9828efe40] Statistics, cache hits:0 cache misses:3&#xA;[in#0 @ 000001d9828da3c0] Error opening input: Invalid data found when processing input&#xA;Error opening input file cache:pipe:0.&#xA;Error opening input files: Invalid data found when processing input&#xA;</task>

    &#xA;

    im using version of ffmpeg-6.1.1-full_build.&#xA;i dont know this error exist the stop button sent event correctly. but chunk data was not work correctly in python server.&#xA;my english was so bad. sry

    &#xA;

  • Transcode webcam blob to RTMP using ffmpeg.wasm

    29 novembre 2023, par hassan moradnezhad

    I'm trying transcode webcam blob data to a rtmp server from browser by using ffmpeg.wasm .
    &#xA;first, i create a MediaStream.

    &#xA;

            const stream = await navigator.mediaDevices.getUserMedia({&#xA;            video: true,&#xA;        });&#xA;

    &#xA;

    then, i create a MediaRecorder.

    &#xA;

            const recorder = new MediaRecorder(stream, {mimeType: "video/webm; codecs:vp9"});&#xA;        recorder.ondataavailable = handleDataAvailable;&#xA;        recorder.start(0)&#xA;

    &#xA;

    when data is available, i call a function called handleDataAvailable.
    &#xA;here is the function.

    &#xA;

        const handleDataAvailable = (event: BlobEvent) => {&#xA;        console.log("data-available");&#xA;        if (event.data.size > 0) {&#xA;            recordedChunksRef.current.push(event.data);&#xA;            transcode(event.data)&#xA;        }&#xA;    };&#xA;

    &#xA;

    in above code, i use another function which called transcode it's goal is going to send data to rtmp server using use ffmpeg.wasm.
    &#xA;here it is.

    &#xA;

    const transcode = async (inputVideo: Blob | undefined) => {&#xA;        const ffmpeg = ffmpegRef.current;&#xA;        const fetchFileOutput = await fetchFile(inputVideo)&#xA;        ffmpeg?.writeFile(&#x27;input.webm&#x27;, fetchFileOutput)&#xA;&#xA;        const data = await ffmpeg?.readFile(&#x27;input.webm&#x27;);&#xA;        if (videoRef.current) {&#xA;            videoRef.current.src =&#xA;                URL.createObjectURL(new Blob([(data as any)?.buffer], {type: &#x27;video/webm&#x27;}));&#xA;        }&#xA;&#xA;        // execute by node-media-server config 1&#xA;        await ffmpeg?.exec([&#x27;-re&#x27;, &#x27;-i&#x27;, &#x27;input.webm&#x27;, &#x27;-c&#x27;, &#x27;copy&#x27;, &#x27;-f&#x27;, &#x27;flv&#x27;, "rtmp://localhost:1935/live/ttt"])&#xA;&#xA;        // execute by node-media-server config 2&#xA;        // await ffmpeg?.exec([&#x27;-re&#x27;, &#x27;-i&#x27;, &#x27;input.webm&#x27;, &#x27;-c:v&#x27;, &#x27;libx264&#x27;, &#x27;-preset&#x27;, &#x27;veryfast&#x27;, &#x27;-tune&#x27;, &#x27;zerolatency&#x27;, &#x27;-c:a&#x27;, &#x27;aac&#x27;, &#x27;-ar&#x27;, &#x27;44100&#x27;, &#x27;-f&#x27;, &#x27;flv&#x27;, &#x27;rtmp://localhost:1935/live/ttt&#x27;]);&#xA;&#xA;        // execute by stack-over-flow config 1&#xA;        // await ffmpeg?.exec([&#x27;-re&#x27;, &#x27;-i&#x27;, &#x27;input.webm&#x27;, &#x27;-c:v&#x27;, &#x27;h264&#x27;, &#x27;-c:a&#x27;, &#x27;aac&#x27;, &#x27;-f&#x27;, &#x27;flv&#x27;, "rtmp://localhost:1935/live/ttt"]);&#xA;&#xA;        // execute by stack-over-flow config 2&#xA;        // await ffmpeg?.exec([&#x27;-i&#x27;, &#x27;input.webm&#x27;, &#x27;-c:v&#x27;, &#x27;libx264&#x27;, &#x27;-flags:v&#x27;, &#x27;&#x2B;global_header&#x27;, &#x27;-c:a&#x27;, &#x27;aac&#x27;, &#x27;-ac&#x27;, &#x27;2&#x27;, &#x27;-f&#x27;, &#x27;flv&#x27;, "rtmp://localhost:1935/live/ttt"]);&#xA;&#xA;        // execute by stack-over-flow config 3&#xA;        // await ffmpeg?.exec([&#x27;-i&#x27;, &#x27;input.webm&#x27;, &#x27;-acodec&#x27;, &#x27;aac&#x27;, &#x27;-ac&#x27;, &#x27;2&#x27;, &#x27;-strict&#x27;, &#x27;experimental&#x27;, &#x27;-ab&#x27;, &#x27;160k&#x27;, &#x27;-vcodec&#x27;, &#x27;libx264&#x27;, &#x27;-preset&#x27;, &#x27;slow&#x27;, &#x27;-profile:v&#x27;, &#x27;baseline&#x27;, &#x27;-level&#x27;, &#x27;30&#x27;, &#x27;-maxrate&#x27;, &#x27;10000000&#x27;, &#x27;-bufsize&#x27;, &#x27;10000000&#x27;, &#x27;-b&#x27;, &#x27;1000k&#x27;, &#x27;-f&#x27;, &#x27;flv&#x27;, &#x27;rtmp://localhost:1935/live/ttt&#x27;]);&#xA;&#xA;    }&#xA;

    &#xA;

    after running app and start streaming, console logs are as below.

    &#xA;

    ffmpeg >>>  ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers index.tsx:81:20&#xA;ffmpeg >>>    built with emcc (Emscripten gcc/clang-like replacement &#x2B; linker emulating GNU ld) 3.1.40 (5c27e79dd0a9c4e27ef2326841698cdd4f6b5784) index.tsx:81:20&#xA;ffmpeg >>>    configuration: --target-os=none --arch=x86_32 --enable-cross-compile --disable-asm --disable-stripping --disable-programs --disable-doc --disable-debug --disable-runtime-cpudetect --disable-autodetect --nm=emnm --ar=emar --ranlib=emranlib --cc=emcc --cxx=em&#x2B;&#x2B; --objcc=emcc --dep-cc=emcc --extra-cflags=&#x27;-I/opt/include -O3 -msimd128&#x27; --extra-cxxflags=&#x27;-I/opt/include -O3 -msimd128&#x27; --disable-pthreads --disable-w32threads --disable-os2threads --enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libopus --enable-zlib --enable-libwebp --enable-libfreetype --enable-libfribidi --enable-libass --enable-libzimg index.tsx:81:20&#xA;ffmpeg >>>    libavutil      57. 28.100 / 57. 28.100 index.tsx:81:20&#xA;ffmpeg >>>    libavcodec     59. 37.100 / 59. 37.100 index.tsx:81:20&#xA;ffmpeg >>>    libavformat    59. 27.100 / 59. 27.100 index.tsx:81:20&#xA;ffmpeg >>>    libavdevice    59.  7.100 / 59.  7.100 index.tsx:81:20&#xA;ffmpeg >>>    libavfilter     8. 44.100 /  8. 44.100 index.tsx:81:20&#xA;ffmpeg >>>    libswscale      6.  7.100 /  6.  7.100 index.tsx:81:20&#xA;ffmpeg >>>    libswresample   4.  7.100 /  4.  7.100 index.tsx:81:20&#xA;ffmpeg >>>    libpostproc    56.  6.100 / 56.  6.100 index.tsx:81:20&#xA;ffmpeg >>>  Input #0, matroska,webm, from &#x27;input.webm&#x27;: index.tsx:81:20&#xA;ffmpeg >>>    Metadata: index.tsx:81:20&#xA;ffmpeg >>>      encoder         : QTmuxingAppLibWebM-0.0.1 index.tsx:81:20&#xA;ffmpeg >>>    Duration: N/A, start: 0.000000, bitrate: N/A index.tsx:81:20&#xA;ffmpeg >>>    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 15.50 tbr, 1k tbn (default)&#xA;

    &#xA;

    the problem is when ffmpeg.wasm try to execute the last command.
    &#xA;await ffmpeg?.exec([&#x27;-re&#x27;, &#x27;-i&#x27;, &#x27;input.webm&#x27;, &#x27;-c&#x27;, &#x27;copy&#x27;, &#x27;-f&#x27;, &#x27;flv&#x27;, "rtmp://localhost:1935/live/ttt"]).
    &#xA;it just calls a GET Request, I will send further details about this request.
    &#xA;as u can see, i try to use lots of arg sample with ffmpeg?.exec, but non of them works.

    &#xA;

    the network tab in browser, after ffmpeg.wasm execute the command is as below.

    &#xA;

    enter image description here

    &#xA;

    it send a GET request to ws://localhost:1935/&#xA;and nothing happened after that.

    &#xA;

    for backend, i use node-media-server and here is my output logs when ffmpeg.wasm trying to execute the args

    &#xA;

    11/28/2023 19:33:18 55301 [INFO] [rtmp disconnect] id=JL569YOF&#xA;[NodeEvent on doneConnect] id=JL569YOF args=undefined&#xA;

    &#xA;

    at last here are my ques

    &#xA;

    &#xA;
      &#xA;
    • how can i achive this option ?
    • &#xA;

    • is it possible to share webcam to rtmp server ?
    • &#xA;

    &#xA;

    &#xA;

  • How do i play an HLS stream when playlist.m3u8 file is constantly being updated ?

    3 janvier 2021, par Adnan Ahmed

    I am using MediaRecorder to record chunks of my live video in webm format from MediaStream and converting these chunks to .ts files on the server using ffmpeg and then updating my playlist.m3u8 file with this code :

    &#xA;

    function generateM3u8Playlist(fileDataArr, playlistFp, isLive, cb) {&#xA;    var durations = fileDataArr.map(function(fd) {&#xA;        return fd.duration;&#xA;    });&#xA;    var maxT = maxOfArr(durations);&#xA;&#xA;    var meta = [&#xA;        &#x27;#EXTM3U&#x27;,&#xA;        &#x27;#EXT-X-VERSION:3&#x27;,&#xA;        &#x27;#EXT-X-MEDIA-SEQUENCE:0&#x27;,&#xA;        &#x27;#EXT-X-ALLOW-CACHE:YES&#x27;,&#xA;        &#x27;#EXT-X-TARGETDURATION:&#x27; &#x2B; Math.ceil(maxT),&#xA;    ];&#xA;&#xA;    fileDataArr.forEach(function(fd) {&#xA;        meta.push(&#x27;#EXTINF:&#x27; &#x2B; fd.duration.toFixed(2) &#x2B; &#x27;,&#x27;);&#xA;        meta.push(fd.fileName2);&#xA;    });&#xA;&#xA;    if (!isLive) {&#xA;        meta.push(&#x27;#EXT-X-ENDLIST&#x27;);&#xA;    }&#xA;&#xA;    meta.push(&#x27;&#x27;);&#xA;    meta = meta.join(&#x27;\n&#x27;);&#xA;&#xA;    fs.writeFile(playlistFp, meta, cb);&#xA;}&#xA;

    &#xA;

    Here fileDataArr holds information for all the chunks that have been created.

    &#xA;

    After that i use this code to create a hls server :

    &#xA;

    var runStreamServer = (function(streamFolder) {&#xA;    var executed = false;&#xA;    return function(streamFolder) {&#xA;        if (!executed) {&#xA;            executed = true;&#xA;            var HLSServer = require(&#x27;hls-server&#x27;)&#xA;            var http = require(&#x27;http&#x27;)&#xA;&#xA;            var server = http.createServer()&#xA;            var hls = new HLSServer(server, {&#xA;                path: &#x27;/stream&#x27;, // Base URI to output HLS streams&#xA;                dir: &#x27;C:\\Users\\Work\\Desktop\\live-stream\\webcam2hls\\videos\\&#x27; &#x2B; streamFolder // Directory that input files are stored&#xA;            })&#xA;            console.log("We are going to stream from folder:" &#x2B; streamFolder);&#xA;            server.listen(8000);&#xA;            console.log(&#x27;Server Listening on Port 8000&#x27;);&#xA;        }&#xA;    };&#xA;})();&#xA;

    &#xA;

    The problem is that if i stop creating new chunks and then use the hls server link :&#xA;http://localhost:8000/stream/playlist.m3u8 then the video plays in VLC but if i try to play during the recording it keeps loading the file but does not play. I want it to play while its creating new chunks and updating playlist.m3u8. The quirk in generateM3u8Playlist function is that it adds &#x27;#EXT-X-ENDLIST&#x27; to the playlist file after i have stopped recording.&#xA;The software is still in production so its a bit messy code. Thank you for any answers.

    &#xA;

    The client side that generates blobs is as follows :

    &#xA;

    var mediaConstraints = {&#xA;            video: true,&#xA;            audio:true&#xA;        };&#xA;navigator.getUserMedia(mediaConstraints, onMediaSuccess, onMediaError);&#xA;function onMediaSuccess(stream) {&#xA;            console.log(&#x27;will start capturing and sending &#x27; &#x2B; (DT / 1000) &#x2B; &#x27;s videos when you press start&#x27;);&#xA;            var mediaRecorder = new MediaStreamRecorder(stream);&#xA;&#xA;            mediaRecorder.mimeType = &#x27;video/webm&#x27;;&#xA;&#xA;            mediaRecorder.ondataavailable = function(blob) {&#xA;                var count2 = zeroPad(count, 5);&#xA;                // here count2 just creates a blob number &#xA;                console.log(&#x27;sending chunk &#x27; &#x2B; name &#x2B; &#x27; #&#x27; &#x2B; count2 &#x2B; &#x27;...&#x27;);&#xA;                send(&#x27;/chunk/&#x27; &#x2B; name &#x2B; &#x27;/&#x27; &#x2B; count2 &#x2B; (stopped ? &#x27;/finish&#x27; : &#x27;&#x27;), blob);&#xA;                &#x2B;&#x2B;count;&#xA;            };&#xA;        }&#xA;// Here we have the send function which sends our blob to server:&#xA;        function send(url, blob) {&#xA;            var xhr = new XMLHttpRequest();&#xA;            xhr.open(&#x27;POST&#x27;, url, true);&#xA;&#xA;            xhr.responseType = &#x27;text/plain&#x27;;&#xA;            xhr.setRequestHeader(&#x27;Content-Type&#x27;, &#x27;video/webm&#x27;);&#xA;            //xhr.setRequestHeader("Content-Length", blob.length);&#xA;&#xA;            xhr.onload = function(e) {&#xA;                if (this.status === 200) {&#xA;                    console.log(this.response);&#xA;                }&#xA;            };&#xA;            xhr.send(blob);&#xA;        }&#xA;

    &#xA;

    The code that receives the XHR request is as follows :

    &#xA;

    var parts = u.split(&#x27;/&#x27;);&#xA;        var prefix = parts[2];&#xA;        var num = parts[3];&#xA;        var isFirst = false;&#xA;        var isLast = !!parts[4];&#xA;&#xA;        if ((/^0&#x2B;$/).test(num)) {&#xA;            var path = require(&#x27;path&#x27;);&#xA;            shell.mkdir(path.join(__dirname, &#x27;videos&#x27;, prefix));&#xA;            isFirst = true;&#xA;        }&#xA;&#xA;        var fp = &#x27;videos/&#x27; &#x2B; prefix &#x2B; &#x27;/&#x27; &#x2B; num &#x2B; &#x27;.webm&#x27;;&#xA;        var msg = &#x27;got &#x27; &#x2B; fp;&#xA;        console.log(msg);&#xA;        console.log(&#x27;isFirst:%s, isLast:%s&#x27;, isFirst, isLast);&#xA;&#xA;        var stream = fs.createWriteStream(fp, { encoding: &#x27;binary&#x27; });&#xA;        /*stream.on(&#x27;end&#x27;, function() {&#xA;            respond(res, [&#x27;text/plain&#x27;, msg]);&#xA;        });*/&#xA;&#xA;        //req.setEncoding(&#x27;binary&#x27;);&#xA;&#xA;        req.pipe(stream);&#xA;        req.on(&#x27;end&#x27;, function() {&#xA;            respond(res, [&#x27;text/plain&#x27;, msg]);&#xA;&#xA;            if (!LIVE) { return; }&#xA;&#xA;            var duration = 20;&#xA;            var fd = {&#xA;                fileName: num &#x2B; &#x27;.webm&#x27;,&#xA;                filePath: fp,&#xA;                duration: duration&#xA;            };&#xA;            var fileDataArr;&#xA;            if (isFirst) {&#xA;                fileDataArr = [];&#xA;                fileDataArrs[prefix] = fileDataArr;&#xA;            } else {&#xA;                var fileDataArr = fileDataArrs[prefix];&#xA;            }&#xA;            try {&#xA;                fileDataArr.push(fd);&#xA;            } catch (err) {&#xA;                fileDataArr = [];&#xA;                console.log(err.message);&#xA;            }&#xA;            videoUtils.computeStartTimes(fileDataArr);&#xA;&#xA;            videoUtils.webm2Mpegts(fd, function(err, mpegtsFp) {&#xA;                if (err) { return console.error(err); }&#xA;                console.log(&#x27;created %s&#x27;, mpegtsFp);&#xA;&#xA;                var playlistFp = &#x27;videos/&#x27; &#x2B; prefix &#x2B; &#x27;/playlist.m3u8&#x27;;&#xA;&#xA;                var fileDataArr2 = (isLast ? fileDataArr : lastN(fileDataArr, PREV_ITEMS_IN_LIVE));&#xA;&#xA;                var action = (isFirst ? &#x27;created&#x27; : (isLast ? &#x27;finished&#x27; : &#x27;updated&#x27;));&#xA;&#xA;                videoUtils.generateM3u8Playlist(fileDataArr2, playlistFp, !isLast, function(err) {&#xA;                    console.log(&#x27;playlist %s %s&#x27;, playlistFp, (err ? err.toString() : action));&#xA;                });&#xA;            });&#xA;&#xA;&#xA;            runStreamServer(prefix);&#xA;        }&#xA;

    &#xA;