Recherche avancée

Médias (91)

Autres articles (37)

  • 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

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (3394)

  • Best approach to real time http streaming to HTML5 video client

    12 octobre 2016, par deandob

    I’m really stuck trying to understand the best way to stream real time output of ffmpeg to a HTML5 client using node.js, as there are a number of variables at play and I don’t have a lot of experience in this space, having spent many hours trying different combinations.

    My use case is :

    1) IP video camera RTSP H.264 stream is picked up by FFMPEG and remuxed into a mp4 container using the following FFMPEG settings in node, output to STDOUT. This is only run on the initial client connection, so that partial content requests don’t try to spawn FFMPEG again.

    liveFFMPEG = child_process.spawn("ffmpeg", [
                   "-i", "rtsp://admin:12345@192.168.1.234:554" , "-vcodec", "copy", "-f",
                   "mp4", "-reset_timestamps", "1", "-movflags", "frag_keyframe+empty_moov",
                   "-"   // output to stdout
                   ],  {detached: false});

    2) I use the node http server to capture the STDOUT and stream that back to the client upon a client request. When the client first connects I spawn the above FFMPEG command line then pipe the STDOUT stream to the HTTP response.

    liveFFMPEG.stdout.pipe(resp);

    I have also used the stream event to write the FFMPEG data to the HTTP response but makes no difference

    xliveFFMPEG.stdout.on("data",function(data) {
           resp.write(data);
    }

    I use the following HTTP header (which is also used and working when streaming pre-recorded files)

    var total = 999999999         // fake a large file
    var partialstart = 0
    var partialend = total - 1

    if (range !== undefined) {
       var parts = range.replace(/bytes=/, "").split("-");
       var partialstart = parts[0];
       var partialend = parts[1];
    }

    var start = parseInt(partialstart, 10);
    var end = partialend ? parseInt(partialend, 10) : total;   // fake a large file if no range reques

    var chunksize = (end-start)+1;

    resp.writeHead(206, {
                     'Transfer-Encoding': 'chunked'
                    , 'Content-Type': 'video/mp4'
                    , 'Content-Length': chunksize // large size to fake a file
                    , 'Accept-Ranges': 'bytes ' + start + "-" + end + "/" + total
    });

    3) The client has to use HTML5 video tags.

    I have no problems with streaming playback (using fs.createReadStream with 206 HTTP partial content) to the HTML5 client a video file previously recorded with the above FFMPEG command line (but saved to a file instead of STDOUT), so I know the FFMPEG stream is correct, and I can even correctly see the video live streaming in VLC when connecting to the HTTP node server.

    However trying to stream live from FFMPEG via node HTTP seems to be a lot harder as the client will display one frame then stop. I suspect the problem is that I am not setting up the HTTP connection to be compatible with the HTML5 video client. I have tried a variety of things like using HTTP 206 (partial content) and 200 responses, putting the data into a buffer then streaming with no luck, so I need to go back to first principles to ensure I’m setting this up the right way.

    Here is my understanding of how this should work, please correct me if I’m wrong :

    1) FFMPEG should be setup to fragment the output and use an empty moov (FFMPEG frag_keyframe and empty_moov mov flags). This means the client does not use the moov atom which is typically at the end of the file which isn’t relevant when streaming (no end of file), but means no seeking possible which is fine for my use case.

    2) Even though I use MP4 fragments and empty MOOV, I still have to use HTTP partial content, as the HTML5 player will wait until the entire stream is downloaded before playing, which with a live stream never ends so is unworkable.

    3) I don’t understand why piping the STDOUT stream to the HTTP response doesn’t work when streaming live yet if I save to a file I can stream this file easily to HTML5 clients using similar code. Maybe it’s a timing issue as it takes a second for the FFMPEG spawn to start, connect to the IP camera and send chunks to node, and the node data events are irregular as well. However the bytestream should be exactly the same as saving to a file, and HTTP should be able to cater for delays.

    4) When checking the network log from the HTTP client when streaming a MP4 file created by FFMPEG from the camera, I see there are 3 client requests : A general GET request for the video, which the HTTP server returns about 40Kb, then a partial content request with a byte range for the last 10K of the file, then a final request for the bits in the middle not loaded. Maybe the HTML5 client once it receives the first response is asking for the last part of the file to load the MP4 MOOV atom ? If this is the case it won’t work for streaming as there is no MOOV file and no end of the file.

    5) When checking the network log when trying to stream live, I get an aborted initial request with only about 200 bytes received, then a re-request again aborted with 200 bytes and a third request which is only 2K long. I don’t understand why the HTML5 client would abort the request as the bytestream is exactly the same as I can successfully use when streaming from a recorded file. It also seems node isn’t sending the rest of the FFMPEG stream to the client, yet I can see the FFMPEG data in the .on event routine so it is getting to the FFMPEG node HTTP server.

    6) Although I think piping the STDOUT stream to the HTTP response buffer should work, do I have to build an intermediate buffer and stream that will allow the HTTP partial content client requests to properly work like it does when it (successfully) reads a file ? I think this is the main reason for my problems however I’m not exactly sure in Node how to best set that up. And I don’t know how to handle a client request for the data at the end of the file as there is no end of file.

    7) Am I on the wrong track with trying to handle 206 partial content requests, and should this work with normal 200 HTTP responses ? HTTP 200 responses works fine for VLC so I suspect the HTML5 video client will only work with partial content requests ?

    As I’m still learning this stuff its difficult to work through the various layers of this problem (FFMPEG, node, streaming, HTTP, HTML5 video) so any pointers will be greatly appreciated. I have spent hours researching on this site and the net, and I have not come across anyone who has been able to do real time streaming in node but I can’t be the first, and I think this should be able to work (somehow !).

  • Extended client ownership of MediaCodec encoder output buffers for RTMP streaming

    13 février 2014, par dbro

    Background :

    I've connected Android's MediaCodec to FFmpeg for muxing a variety of formats not supported by MediaMuxer, including rtmp:// output via a .flv container. Such streaming muxers require longer, unpredictable ownership of MediaCodec's output buffers, as they may perform networking I/O on any packet processing step. For my video stream, I'm using MediaCodec configured for Surface input. To decouple muxing from encoding, I queue MediaCodec's ByteBuffer output buffers to my muxer via a Handler.

    All works splendidly if I mux the .flv output to file, rather than rtmp endpoint.

    Problem :

    When muxing to rtmp://... endpoint I notice my streaming application begins to block on calls to eglSwapBuffers(mEGLDisplay, mEncodingEGLSurface) at dequeueOutputBuffer() once I'm retaining even a few MediaCodec output buffers in my muxing queue as MediaCodec seems to be locked to only 4 output buffers.

    Any tricks to avoid copying all encoder output returned by MediaCodec#dequeueOutputBuffers and immediately calling releaseOutputBuffer(...) ?

    The full source of my project is available on Github. Specifically, see :

    • AndroidEncoder.java : Abstract Encoder class with shared behavior between Audio and Video encoders : mainly drainEncoder(). Writes data to a Muxer instance.
    • FFmpegMuxer.java : Implements Muxer
    • CameraEncoder.java. Sends camera frames to an AndroidEncoder subclass configured for Video encoding.

    Systrace

    Systrace output

    Here's some systrace output streaming 720p @ 2Mbps video to Zencoder.

    Solved

    Copying then releasing the MediaCodec encoder output ByteBuffers as soon as they're available solves the issue without significantly affecting performance. I recycle the ByteBuffer copies in an ArrayDeque<bytebuffer></bytebuffer> for each muxer track, which limits the number of allocations.

  • multithreaded client/server listener using ffmpeg to record video

    29 janvier 2014, par user1895639

    I've got a python project where I need to trigger start/stop of two Axis IP cameras using ffmpeg. I've gotten bits and pieces of this to work but can't put the whole thing together. A "listener" program runs on one machine that can accept messages from other machines to start and stop recordings.

    The listener responds to two commands only :

    START v :/video_dir/myvideo.mov
    STOP

    The START command is followed by the full path of a video file that it will record.
    When receiving a STOP command, the video recording should stop.

    I am using ffmpeg to attach to cameras, and manually doing this works :

    ffmpeg.exe -i rtsp ://cameraip/blah/blah -vcodec copy -acodec copy -y c :\temp\output.mov

    I can attach to the stream and upon hitting 'q' I can stop the recording.

    What I'd like to be able to do is relatively simple, I just can't wrap my head around it :

    Listener listens
    When it receives a START signal, it spawns two processes to start recording from each camera
    When it receives a STOP signal, it sends the 'q' keystroke to each process to tell ffmpeg to stop recording.

    I've got the listener part, but I'm just not sure how to get the multithreaded part down :

    while True:
       client,address = s.accept()
       data = client.recv( size )
       if data:
           if data.startswith(&#39;START&#39;):
               # start threads here
           elif data.startswith(&#39;STOP&#39;):
               # how to send a stop to the newly-created processes?

    In the thread code I'm doing this (which may be very incorrect) :

    subprocess.call(&#39;ffmpeg.exe -i "rtsp://cameraipstuff -vcodec copy -acodec copy -t 3600 -y &#39;+filename)  

    I can get this process to spawn off and I see it recording, but how can I send it a "q" message ? I can use a Queue to pass a stop message and then do something like

    win32com.client.Dispatch(&#39;WScript.Shell&#39;).SendKeys(&#39;q&#39;)

    but that seems awkward. Perhaps a pipe and sending q to stdin ? Regardless, I'm pretty sure using threads is the right approach (as opposed to calling subprocess.call('ffmpeg.exe ...') twice in a row), but I just don't know how to tie things together.