Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Autres articles (80)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

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

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

Sur d’autres sites (9691)

  • RTSP stream to ffmpeg problems

    14 octobre 2022, par maeek

    I'm writing a web application for managing and viewing streams from ONVIF ip-cameras.
    
It's written in nodejs. The idea is to run a child process in node and pipe output to node, then send the buffer to client and render it on canvas. I have a working solution for sending data to client and rendering it on canvas using websockets but it only works on one of my cameras.

    


    I own 2 IP cameras and both of them have rtsp server.
    
One of them(let's name it camX) kind of works with this ffmpeg command (sometimes it just stops, maybe due to packet losses) :

    


    ffmpeg -rtsp_transport tcp -re -i  -f mjpeg pipe:1


    


    But the other one(camY) returns Nonmatching transport in server reply and exits.

    


    I discovered that the camY transport is unicast but ffmpeg doesn't support this particular lower_transport as I read on ffmpeg forum.

    


    So I started looking for a solution. My first idea was to use openRTSP which works fine with both streams.
I looked at the documentation and came up with this command :
    
openRTSP -4 -c  | ffmpeg -re -i pipe:0 -f mjpeg pipe:1
    
-4 parameter returns stream to pipe in mp4 format
    
And here's another problem I ran into, ffmpeg returns :

    


    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x559a4b6ba900] moov atom not found  
pipe:0: Invalid data found when processing input


    


    Is there any way to make this work ?
I tried various solutions I found, but none of them worked.

    


    EDIT

    


    As @Gyan suggested I used -i parameter instead of -4 but it didn't solve my problem.

    


    My command :

    


    openRTSP -V -i -c -K  | ffmpeg -loglevel debug -re -i pipe:0 -f mjpeg pipe:1
  
Created receiver for "video/H264" subsession (client ports 49072-49073)
Setup "video/H264" subsession (client ports 49072-49073)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
AVIFileSink::setWord(): SeekFile64 failed (err 29)
Outputting to the file: "stdout"
[avi @ 0x5612944268c0] Format avi probed with size=2048 and score=100
[avi @ 0x56129442f7a0] use odml:1
Started playing session
Receiving streamed data (signal with "kill -HUP 15028" or "kill -USR1 15028" to terminate)...
^C
[AVIOContext @ 0x56129442f640] Statistics: 16904 bytes read, 0 seeks
pipe:0: Invalid data found when processing input


    


    As you can see openRTSP command return err 29 but in meantime it outputs some data to pipe.
    
When I terminate the command ffmpeg shows that it read some data but couldn't process it.

    


    Here's the function that produces that error :

    


    void AVIFileSink::setWord(unsigned filePosn, unsigned size) {
  do {
    if (SeekFile64(fOutFid, filePosn, SEEK_SET) < 0) break;
    addWord(size);
    if (SeekFile64(fOutFid, 0, SEEK_END) < 0) break; // go back to where we were

    return;
  } while (0);

  // One of the SeekFile64()s failed, probable because we're not a seekable file
  envir() << "AVIFileSink::setWord(): SeekFile64 failed (err "
          << envir().getErrno() << ")\n";
}


    


    In my opinion it looks like it won't be able to seek file because it's a stream not a static file.
    
Any suggestion for a workaround ?

    


  • Overwriting destination file in PowerShell

    2 mai 2019, par user10204157

    I am running the following script

    ffmpeg -i $Args[0] -vcodec copy -acodec copy -movflags +faststart $Args[1]

    Which essentially is overwriting the original file, how can I force this to override so my powershell script doesn’t error out ?

    File ’./cache/videos/1556749678654.mp4’ already exists. Overwrite ? [y/N] Not overwriting - exiting

    Edit
    I am executing this script as follows within node.js

    var spawn = require("child_process").spawn,
           child;

         response.data.pipe(file);

         child = spawn("powershell.exe", [
           "./script.ps1",
           `./cache/videos/${tempFileName + "."}${videoType}`,
           ` ./cache/converted_videos/${tempFileName + "."}${videoType}`
         ]);
  • mux / remux / box in memory h264 frames to mp4 via C / C++ (no ffmpeg cmdline)

    28 février 2019, par Vans S

    I have looked at various tutorials and I am still struggling to correctly frame raw h264 into an mp4 container. The problem is the stream does not have an end (live) and is in memory, a lot of the examples available of muxers assume the streams are located on disk as files.

    I have tried and looked at
    http://www.ffmpeg.org/doxygen/trunk/doc_2examples_2remuxing_8c-example.html
    https://ffmpeg.org/doxygen/trunk/muxing_8c-source.html
    and countless other examples.

    This is what I have now :

    AVFormatContext *outFmtCtx = NULL;
    AVFormatContext *inFmtCtx = NULL;
    std::vector g_p;

    static int read_packet(void *opaque, uint8_t *pBuf, int nBuf) {
       printf("read_packet %d\n", g_p.size());
       memcpy(pBuf, &g_p[0], g_p.size());
       return g_p.size();
    }

    static int write_packet(void *opaque, uint8_t *buf, int buf_size) {
       printf("write_packet %d %lld\n", buf_size, timestamp_micro());
       return buf_size;
    }

    static int64_t seek_packet(void *opaque, int64_t offset, int whence) {
       printf("seek_packet\n");
       exit(0);
       return 0;
    }

    void create_mp4() {
       av_log_set_level(AV_LOG_DEBUG);

       //alloc memory buffer
       uint8_t *avioc_buffer = NULL;
       int avioc_buffer_size = 8 * 1024 * 1024;
       avioc_buffer = (uint8_t *)av_malloc(avioc_buffer_size);
       if (!avioc_buffer) {
           printf("failed make avio buffer\n");
           exit(1);
       }
       AVIOContext* pIOCtx = avio_alloc_context(avioc_buffer, avioc_buffer_size, 1,
           NULL/*outptr*/, &read_packet, &write_packet, &seek_packet);
       if (!pIOCtx) {
           printf("failed make avio context\n");
           exit(1);
       }

       inFmtCtx = avformat_alloc_context();
       inFmtCtx->pb = pIOCtx;
       inFmtCtx->iformat = av_find_input_format("h264");
       avformat_open_input(&inFmtCtx, "", inFmtCtx->iformat, NULL);

       AVOutputFormat* outFmt = av_guess_format("mp4", NULL, NULL);
       avformat_alloc_output_context2(&outFmtCtx, outFmt, NULL, NULL);

       //set the AIO buffer to the memory one
       outFmtCtx->pb = pIOCtx;
       //outFmtCtx->flags = AVFMT_FLAG_CUSTOM_IO;//pIOCtx;

       AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_H264);
       AVStream * outStrm = avformat_new_stream(outFmtCtx, codec);

       avcodec_get_context_defaults3(outStrm->codec, codec);
       outStrm->id = 0;
       outStrm->codec->coder_type = AVMEDIA_TYPE_VIDEO;
       outStrm->codec->codec_id = AV_CODEC_ID_H264;
       outStrm->codec->bit_rate = 8000000;
       outStrm->codec->width = 1280;
       outStrm->codec->height = 720;
       outStrm->codec->time_base.den = 60;
       outStrm->codec->time_base.num = 1;
       outStrm->codec->gop_size = 0xffffffff;
       outStrm->codec->pix_fmt = AV_PIX_FMT_NV12;
       outStrm->duration = 0;

       //Allow it to play immediately
       AVDictionary* options = nullptr;
       av_dict_set( &options, "movflags", "empty_moov+default_base_moof+frag_keyframe", 0 );

       avformat_write_header(outFmtCtx, &options);
       printf("mp4 muxer created\n");
    }

    //set the first raw h264 frame from capture
    g_p = raw_h264_frame;
    AVPacket pkt;
    //call av_read_frame (infinite loop here on read_packet)
    int wret = av_read_frame(inFmtCtx, &pkt);

    I get an infinite loop on read_packet after calling av_read_frame, I tried to construct the packets myself by also doing

    AVPacket pkt;
    av_init_packet(&pkt);
    if (nFrame == 0) {
       pkt.flags        |= AV_PKT_FLAG_KEY;
    }
    pkt.stream_index  = 0;
    pkt.data          = &raw_h264_frame[0];
    pkt.size          = raw_h264_frame.size();
    //pkt.dts = AV_NOPTS_VALUE;
    //pkt.pts = AV_NOPTS_VALUE;
    pkt.dts = nFrame;
    pkt.pts = nFrame;

    int ret = av_interleaved_write_frame(outFmtCtx, &pkt);
    if (ret < 0) {
       printf("error av_write_frame\n");
       exit(1);
    }

    But this does not work either. Some help would be greatly appreciated or guidance where to look (perhaps drop libFFMPEG and look elsewhere, etc).

    VLC errors look like :

    mp4 warning: out of bound child    �
    mp4 warning: out of bound child    �
    mp4 warning: no chunk defined
    mp4 warning: STTS table of 0 entries
    mp4 warning: cannot select track[Id 0x1]

    or

    mp4 warning: no chunk defined
    mp4 warning: STTS table of 0 entries
    mp4: Fragment sequence discontinuity detected 1 != 0
    avcodec warning: thread type 1: disabling hardware acceleration
    main warning: picture is too late to be displayed (missing 14 ms)
    main warning: picture is too late to be displayed (missing 14 ms)
    main warning: picture is too late to be displayed (missing 14 ms)