Recherche avancée

Médias (91)

Autres articles (97)

  • 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

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

Sur d’autres sites (7972)

  • 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 :

    


    function generateM3u8Playlist(fileDataArr, playlistFp, isLive, cb) {
    var durations = fileDataArr.map(function(fd) {
        return fd.duration;
    });
    var maxT = maxOfArr(durations);

    var meta = [
        '#EXTM3U',
        '#EXT-X-VERSION:3',
        '#EXT-X-MEDIA-SEQUENCE:0',
        '#EXT-X-ALLOW-CACHE:YES',
        '#EXT-X-TARGETDURATION:' + Math.ceil(maxT),
    ];

    fileDataArr.forEach(function(fd) {
        meta.push('#EXTINF:' + fd.duration.toFixed(2) + ',');
        meta.push(fd.fileName2);
    });

    if (!isLive) {
        meta.push('#EXT-X-ENDLIST');
    }

    meta.push('');
    meta = meta.join('\n');

    fs.writeFile(playlistFp, meta, cb);
}


    


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

    


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

    


    var runStreamServer = (function(streamFolder) {
    var executed = false;
    return function(streamFolder) {
        if (!executed) {
            executed = true;
            var HLSServer = require('hls-server')
            var http = require('http')

            var server = http.createServer()
            var hls = new HLSServer(server, {
                path: '/stream', // Base URI to output HLS streams
                dir: 'C:\\Users\\Work\\Desktop\\live-stream\\webcam2hls\\videos\\' + streamFolder // Directory that input files are stored
            })
            console.log("We are going to stream from folder:" + streamFolder);
            server.listen(8000);
            console.log('Server Listening on Port 8000');
        }
    };
})();


    


    The problem is that if i stop creating new chunks and then use the hls server link :
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 '#EXT-X-ENDLIST' to the playlist file after i have stopped recording.
The software is still in production so its a bit messy code. Thank you for any answers.

    


    The client side that generates blobs is as follows :

    


    var mediaConstraints = {
            video: true,
            audio:true
        };
navigator.getUserMedia(mediaConstraints, onMediaSuccess, onMediaError);
function onMediaSuccess(stream) {
            console.log('will start capturing and sending ' + (DT / 1000) + 's videos when you press start');
            var mediaRecorder = new MediaStreamRecorder(stream);

            mediaRecorder.mimeType = 'video/webm';

            mediaRecorder.ondataavailable = function(blob) {
                var count2 = zeroPad(count, 5);
                // here count2 just creates a blob number 
                console.log('sending chunk ' + name + ' #' + count2 + '...');
                send('/chunk/' + name + '/' + count2 + (stopped ? '/finish' : ''), blob);
                ++count;
            };
        }
// Here we have the send function which sends our blob to server:
        function send(url, blob) {
            var xhr = new XMLHttpRequest();
            xhr.open('POST', url, true);

            xhr.responseType = 'text/plain';
            xhr.setRequestHeader('Content-Type', 'video/webm');
            //xhr.setRequestHeader("Content-Length", blob.length);

            xhr.onload = function(e) {
                if (this.status === 200) {
                    console.log(this.response);
                }
            };
            xhr.send(blob);
        }


    


    The code that receives the XHR request is as follows :

    


    var parts = u.split('/');
        var prefix = parts[2];
        var num = parts[3];
        var isFirst = false;
        var isLast = !!parts[4];

        if ((/^0+$/).test(num)) {
            var path = require('path');
            shell.mkdir(path.join(__dirname, 'videos', prefix));
            isFirst = true;
        }

        var fp = 'videos/' + prefix + '/' + num + '.webm';
        var msg = 'got ' + fp;
        console.log(msg);
        console.log('isFirst:%s, isLast:%s', isFirst, isLast);

        var stream = fs.createWriteStream(fp, { encoding: 'binary' });
        /*stream.on('end', function() {
            respond(res, ['text/plain', msg]);
        });*/

        //req.setEncoding('binary');

        req.pipe(stream);
        req.on('end', function() {
            respond(res, ['text/plain', msg]);

            if (!LIVE) { return; }

            var duration = 20;
            var fd = {
                fileName: num + '.webm',
                filePath: fp,
                duration: duration
            };
            var fileDataArr;
            if (isFirst) {
                fileDataArr = [];
                fileDataArrs[prefix] = fileDataArr;
            } else {
                var fileDataArr = fileDataArrs[prefix];
            }
            try {
                fileDataArr.push(fd);
            } catch (err) {
                fileDataArr = [];
                console.log(err.message);
            }
            videoUtils.computeStartTimes(fileDataArr);

            videoUtils.webm2Mpegts(fd, function(err, mpegtsFp) {
                if (err) { return console.error(err); }
                console.log('created %s', mpegtsFp);

                var playlistFp = 'videos/' + prefix + '/playlist.m3u8';

                var fileDataArr2 = (isLast ? fileDataArr : lastN(fileDataArr, PREV_ITEMS_IN_LIVE));

                var action = (isFirst ? 'created' : (isLast ? 'finished' : 'updated'));

                videoUtils.generateM3u8Playlist(fileDataArr2, playlistFp, !isLast, function(err) {
                    console.log('playlist %s %s', playlistFp, (err ? err.toString() : action));
                });
            });


            runStreamServer(prefix);
        }


    


  • Knitr Plot Animation - disappearing output files ?

    20 avril 2015, par tcs

    I downloaded the latest ffmpeg (exe version), unzipped the files, renamed the directory to ffmpeg, copied the directory into c :\Program Files. I appended my PATH variable to include c :\Program Files\ffmpeg\bin. Finally, I restarted Rstudio.

    While attempting to run the following code chunk :

    ```{r perf_plot, fig.width=7, fig.height=6, fig.show='animate'}
    library(corrplot)
    corrplot(m, method = "circle")
    m<-sequence_2_matrix(perf_list[[1]])
    corrplot(m)
    for (i in 2:length(perf_list)) {
     m<-(m*(i-1)+sequence_2_matrix(perf_list[[i]]))/i
     corrplot(m,method = "circle")

    }

    I see within the output in in my RMarkdown window that the ffmpeg call seems to be successfully run, but while watching the directory where my code is located the png that is attempted to be created can often disappear, or not appear at all. Strangeness.

    processing file: MarkovRoutinesSim.rmd
     |........                                                         |  13%
     ordinary text without R code

     |...........                                                      |  17%
    label: unnamed-chunk-2
     |..............                                                   |  22%
     ordinary text without R code

     |.................                                                |  26%
    label: unnamed-chunk-3
     |....................                                             |  30%
     ordinary text without R code

     |.......................                                          |  35%
    label: unnamed-chunk-4
     |.........................                                        |  39%
     ordinary text without R code

     |............................                                     |  43%
    label: unnamed-chunk-5
     |...............................                                  |  48%
     ordinary text without R code

     |..................................                               |  52%
    label: unnamed-chunk-6
     |.....................................                            |  57%
     ordinary text without R code

     |........................................                         |  61%
    label: unnamed-chunk-7
     |..........................................                       |  65%
     ordinary text without R code

     |.............................................                    |  70%
    label: perf_plot (with options)
    List of 3
    $ fig.width : num 7
    $ fig.height: num 6
    $ fig.show  : chr "animate"

    executing: ffmpeg -y -r 1 -i MarkovRoutinesSim_files/figure-html/perf_plot-%d.png MarkovRoutinesSim_files/figure-html/perf_plot-.webm
    ffmpeg version N-71515-ga40cee0 Copyright (c) 2000-2015 the FFmpeg developers
     built with gcc 4.9.2 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
     libavutil      54. 22.101 / 54. 22.101
     libavcodec     56. 34.100 / 56. 34.100
     libavformat    56. 30.100 / 56. 30.100
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 14.100 /  5. 14.100
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    Input #0, image2, from 'MarkovRoutinesSim_files/figure-html/perf_plot-%d.png':
     Duration: 00:00:00.44, start: 0.000000, bitrate: N/A
       Stream #0:0: Video: png, pal8, 1344x1152 [SAR 7559:7559 DAR 7:6], 25 fps, 25 tbr, 25 tbn, 25 tbc
    [libvpx @ 000000000310e720] v1.4.0
    Output #0, webm, to 'MarkovRoutinesSim_files/figure-html/perf_plot-.webm':
     Metadata:
       encoder         : Lavf56.30.100
       Stream #0:0: Video: vp8 (libvpx), yuv420p, 1344x1152 [SAR 1:1 DAR 7:6], q=-1--1, 200 kb/s, 1 fps, 1k tbn, 1 tbc
       Metadata:
         encoder         : Lavc56.34.100 libvpx
    Stream mapping:
     Stream #0:0 -> #0:0 (png (native) -> vp8 (libvpx))
    Press [q] to stop, [?] for help
     |................................................                 |  74%
     ordinary text without R code

     |...................................................              |  78%
    label: unnamed-chunk-8
     |......................................................           |  83%
     ordinary text without R code

     |.........................................................        |  87%
    label: unnamed-chunk-9
    frame=   11 fps=0.0 q=0.0 Lsize=     108kB time=00:00:11.00 bitrate=  80.8kbits/s    
    video:108kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.524176%
     |...........................................................      |  91%
     ordinary text without R code

     |..............................................................   |  96%
    label: unnamed-chunk-10
     |.................................................................| 100%
     ordinary text without R code


    "C:/Program Files/RStudio/bin/pandoc/pandoc" MarkovRoutinesSim.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output MarkovRoutinesSim.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\Tim\Documents\R\win-library\3.2\rmarkdown\rmd\h\default.html" --variable "theme:bootstrap" --include-in-header "C:\Users\Tim\AppData\Local\Temp\Rtmpkrtekd\rmarkdown-str7d43d7d5475.html" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --no-highlight --variable "highlightjs=C:\Users\Tim\Documents\R\win-library\3.2\rmarkdown\rmd\h\highlight"
    output file: MarkovRoutinesSim.knit.md


    Output created: MarkovRoutinesSim.html

    Any ideas on what might be happening ? I’ve tried adding in other graphs, and I see this random behavior of the file folder appearing disappearing, sometimes the file is created, other times not.

  • 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 .
    
first, i create a MediaStream.

    


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


    


    then, i create a MediaRecorder.

    


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


    


    when data is available, i call a function called handleDataAvailable.
    
here is the function.

    


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


    


    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.
    
here it is.

    


    const transcode = async (inputVideo: Blob | undefined) => {
        const ffmpeg = ffmpegRef.current;
        const fetchFileOutput = await fetchFile(inputVideo)
        ffmpeg?.writeFile('input.webm', fetchFileOutput)

        const data = await ffmpeg?.readFile('input.webm');
        if (videoRef.current) {
            videoRef.current.src =
                URL.createObjectURL(new Blob([(data as any)?.buffer], {type: 'video/webm'}));
        }

        // execute by node-media-server config 1
        await ffmpeg?.exec(['-re', '-i', 'input.webm', '-c', 'copy', '-f', 'flv', "rtmp://localhost:1935/live/ttt"])

        // execute by node-media-server config 2
        // await ffmpeg?.exec(['-re', '-i', 'input.webm', '-c:v', 'libx264', '-preset', 'veryfast', '-tune', 'zerolatency', '-c:a', 'aac', '-ar', '44100', '-f', 'flv', 'rtmp://localhost:1935/live/ttt']);

        // execute by stack-over-flow config 1
        // await ffmpeg?.exec(['-re', '-i', 'input.webm', '-c:v', 'h264', '-c:a', 'aac', '-f', 'flv', "rtmp://localhost:1935/live/ttt"]);

        // execute by stack-over-flow config 2
        // await ffmpeg?.exec(['-i', 'input.webm', '-c:v', 'libx264', '-flags:v', '+global_header', '-c:a', 'aac', '-ac', '2', '-f', 'flv', "rtmp://localhost:1935/live/ttt"]);

        // execute by stack-over-flow config 3
        // await ffmpeg?.exec(['-i', 'input.webm', '-acodec', 'aac', '-ac', '2', '-strict', 'experimental', '-ab', '160k', '-vcodec', 'libx264', '-preset', 'slow', '-profile:v', 'baseline', '-level', '30', '-maxrate', '10000000', '-bufsize', '10000000', '-b', '1000k', '-f', 'flv', 'rtmp://localhost:1935/live/ttt']);

    }


    


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

    


    ffmpeg >>>  ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers index.tsx:81:20
ffmpeg >>>    built with emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.40 (5c27e79dd0a9c4e27ef2326841698cdd4f6b5784) index.tsx:81:20
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++ --objcc=emcc --dep-cc=emcc --extra-cflags='-I/opt/include -O3 -msimd128' --extra-cxxflags='-I/opt/include -O3 -msimd128' --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
ffmpeg >>>    libavutil      57. 28.100 / 57. 28.100 index.tsx:81:20
ffmpeg >>>    libavcodec     59. 37.100 / 59. 37.100 index.tsx:81:20
ffmpeg >>>    libavformat    59. 27.100 / 59. 27.100 index.tsx:81:20
ffmpeg >>>    libavdevice    59.  7.100 / 59.  7.100 index.tsx:81:20
ffmpeg >>>    libavfilter     8. 44.100 /  8. 44.100 index.tsx:81:20
ffmpeg >>>    libswscale      6.  7.100 /  6.  7.100 index.tsx:81:20
ffmpeg >>>    libswresample   4.  7.100 /  4.  7.100 index.tsx:81:20
ffmpeg >>>    libpostproc    56.  6.100 / 56.  6.100 index.tsx:81:20
ffmpeg >>>  Input #0, matroska,webm, from 'input.webm': index.tsx:81:20
ffmpeg >>>    Metadata: index.tsx:81:20
ffmpeg >>>      encoder         : QTmuxingAppLibWebM-0.0.1 index.tsx:81:20
ffmpeg >>>    Duration: N/A, start: 0.000000, bitrate: N/A index.tsx:81:20
ffmpeg >>>    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 15.50 tbr, 1k tbn (default)


    


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

    


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

    


    enter image description here

    


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

    


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

    


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


    


    at last here are my ques

    


    

      

    • how can i achive this option ?
    • 


    • is it possible to share webcam to rtmp server ?
    •