Recherche avancée

Médias (0)

Mot : - Tags -/performance

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

Autres articles (42)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (5470)

  • Unhandled stream error in pipe : write EPIPE in Node.js

    13 juillet 2020, par Michael Romanenko

    The idea is to serve screenshots of RTSP video stream with Express.js server. There is a continuously running spawned openRTSP process in flowing mode (it's stdout is consumed by another ffmpeg process) :

    



    function spawnProcesses (camera) {
  var openRTSP = spawn('openRTSP', ['-c', '-v', '-t', camera.rtsp_url]),
      encoder = spawn('ffmpeg', ['-i', 'pipe:', '-an', '-vcodec', 'libvpx', '-r', 10, '-f', 'webm', 'pipe:1']);

  openRTSP.stdout.pipe(encoder.stdin);

  openRTSP.on('close', function (code) {
    if (code !== 0) {
      console.log('Encoder process exited with code ' + code);
    }
  });

  encoder.on('close', function (code) {
    if (code !== 0) {
      console.log('Encoder process exited with code ' + code);
    }
  });

  return { rtsp: openRTSP, encoder: encoder };
}

...

camera.proc = spawnProcesses(camera);


    



    There is an Express server with single route :

    



    app.get('/cameras/:id.jpg', function(req, res){
  var camera = _.find(cameras, {id: parseInt(req.params.id, 10)});
  if (camera) {
    res.set({'Content-Type': 'image/jpeg'});
    var ffmpeg = spawn('ffmpeg', ['-i', 'pipe:', '-an', '-vframes', '1', '-s', '800x600', '-f', 'image2', 'pipe:1']);
    camera.proc.rtsp.stdout.pipe(ffmpeg.stdin);
    ffmpeg.stdout.pipe(res);
  } else {
    res.status(404).send('Not found');
  }
});

app.listen(3333);


    



    When i request http://localhost:3333/cameras/1.jpg i get desired image, but from time to time app breaks with error :

    



    stream.js:94
  throw er; // Unhandled stream error in pipe.
        ^
Error: write EPIPE
    at errnoException (net.js:901:11)
    at Object.afterWrite (net.js:718:19)


    



    Strange thing is that sometimes it successfully streams image to res stream and closes child process without any error, but, sometimes, streams image and falls down.

    



    I tried to create on('error', ...) event handlers on every possible stream, tried to change pipe(...) calls to on('data',...) constructions, but could not succeed.

    



    My environment : node v0.10.22, OSX Mavericks 10.9.

    



    UPDATE :

    



    I wrapped spawn('ffmpeg',... block with try-catch :

    



    app.get('/cameras/:id.jpg', function(req, res){
....
    try {
      var ffmpeg = spawn('ffmpeg', ['-i', 'pipe:', '-an', '-vframes', '1', '-s', '800x600', '-f', 'image2', 'pipe:1']);
      camera.proc.rtsp.stdout.pipe(ffmpeg.stdin);
      ffmpeg.stdout.pipe(res);
    } catch (e) {
      console.log("Gotcha!", e);
    }
....
});


    



    ... and this error disappeared, but log is silent, it doesn't catch any errors. What's wrong ?

    


  • How to not allow upload of HD content ?More than 1920 x 1080 || 1080 x 1920 resolution files are not allowed since hardware reasons

    23 juillet 2020, par azaono

    Struggling with making limitation to uploade HD file/content. Intent is to have possibility to rotate content. Limits are required due to hardware reasons.

    


            val ffmpeg = FFmpeg("ffmpeg")
        val ffprobe = FFprobe("ffprobe")
        val probeResult = ffprobe.probe("$targetLocation")
        val stream: FFmpegStream = probeResult.getStreams()[0]
        val aspectRatio = stream.width.toDouble() / stream.height
        
        if (stream.width > 1920) {
            Files.delete(targetLocation)
            throw IncorrectResolutionFileException()
        } else if (stream.height > 1080) {
            Files.delete(targetLocation)
            throw IncorrectResolutionFileException()
        }

        if (type == "image") {
            part.transferTo(thumbnailLocation)
        }

        val builder: FFmpegBuilder = FFmpegBuilder()
            .setInput("$targetLocation")
            .addOutput("$thumbnailLocation")
            .setFrames(1)
            .setVideoFilter("select='gte(n\\,10)',scale=200:-1")
            .done()
        val executor = FFmpegExecutor(ffmpeg)
        executor.createJob(builder).run()

        return aspectRatio
    } catch (ex: Exception) {
        throw FileStorageException("Could not store file $cleanPath. Please try again!", ex)
    }
}


    


  • avcodec_send_packet causing memory leak

    23 juin 2020, par AleksaJanjatovic

    I'm trying to fetch a frame from an Rtsp stream, but it seems that I'm forgetting to free some element, causing my RAM to rapidly fill. Here are the code snippets :

    


    Here is the initialization before frame fetching

    


    bool CRtspStream::Init(void* _userData) {
    InitParam* param = (CBaseStream::InitParam*)_userData;
    m_InputPath = param->m_InputPath;
    m_OutputPath = param->m_OutputPath;
    m_Logger.SetLogLevel(param->m_LoggerLevel);

    av_register_all();
    avformat_network_init();

    int ffmpegFatalLogLevel = 8;
    av_log_set_level(ffmpegFatalLogLevel);

    AVCodec* codec = avcodec_find_decoder(param->m_CodecID);
    if(!codec)
        throw DetectionUtility::StreamException("Unable to open codec.");

    m_FormatContext = avformat_alloc_context();
    m_CodecContext = avcodec_alloc_context3(codec);

    if(avformat_open_input(&m_FormatContext, param->m_InputPath.c_str(), nullptr, nullptr) < 0)
        throw DetectionUtility::StreamException("Unable to open stream: " + param->m_InputPath);

    if(avformat_find_stream_info(m_FormatContext, nullptr) < 0)
        throw DetectionUtility::StreamException("Unable to get stream info into format context.");

    for(unsigned int i = 0;i < m_FormatContext->nb_streams; i++){
        if(m_FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
            m_VideoStreamIndex = i;
    }

    if (avcodec_open2(m_CodecContext, codec, nullptr) < 0)
        throw DetectionUtility::StreamException("Unable to open codec.");

    return m_InitSuccesful = true;
}


    


    And here is the actual frame fetching, i made sure that retVal frame is being freed afterward. Main evidence that this is what causes memory leaks is that valgrind is also pointing to the avcodec_send_packet() line : valgrind_results

    


    AVFrame* CRtspStream::RequestNewFrame() {
    AVPacket packet;
    AVFrame* retVal = av_frame_alloc();
    bool frameAvailable = false;

//    avformat_flush(m_FormatContext);
//    avcodec_flush_buffers(m_CodecContext);
    av_read_play(m_FormatContext);
    int readFrameRes;
    while(!frameAvailable) {
        if((readFrameRes = av_read_frame(m_FormatContext, &packet)) >= 0) {
            if(packet.stream_index == m_VideoStreamIndex) {
                int res = 1;
                if((res = avcodec_send_packet(m_CodecContext, &packet)) < 0) {
                    av_packet_unref(&packet);
                    continue;
                }
                av_packet_unref(&packet);
                res = 1;
                while(res > 0) {
                    res = avcodec_receive_frame(m_CodecContext, retVal);
                    if(res == AVERROR(EAGAIN)) {
                        break;
                    } else if (res < 0) {
                        throw DetectionUtility::StreamException("Unable to receive a frame from the codec.");
                    } else {
                        frameAvailable = true;
                    }
                }
            }
        }
        av_packet_unref(&packet);
    }

    if(readFrameRes < 0) {
        av_frame_free(&retVal);
        av_packet_unref(&packet);
        throw DetectionUtility::StreamException("Unable to fetcha a new frame.");
    } else {
        try {
            if(CheckOutputSupported())
                DetectionUtility::AVFrameHelper::SaveFrame(retVal, "Rtsp" + m_OutputPath, m_CurrentFrameNumber);
            ++m_CurrentFrameNumber;
        } catch (const Utility::BaseException& e) {
            m_Logger.Error(e.GetMessage());
        }
    }
    return retVal;
}