Recherche avancée

Médias (0)

Mot : - Tags -/xml-rpc

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

Autres articles (90)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

Sur d’autres sites (10910)

  • swr_convert float planar to S16

    8 janvier 2020, par Kevin Kouketsu

    How convert using libav API AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16

    I’m trying to figure out how to resample and encode PCM (captured from Microphone) 44.1KHz to AAC 48.0KHz

    That’s my resampler initializer :

    void initialize_resampler(SwrContext*& resamplerCtx, AVCodecContext* encoder, AVFrame*& rawResampledAudioFrame, AVStream* audioFormatStream)
    {
       int nb_samples = (encoder->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) ? encoder->sample_rate : encoder->frame_size;

       int encoderFrameSize = encoder->channels * av_get_bytes_per_sample(encoder->sample_fmt) * encoder->frame_size;
       rawResampledAudioFrame = allocate_audioframe(encoder->sample_fmt, encoder->channel_layout, encoder->sample_rate, nb_samples);

       // Copy the stream parameters to the muxer
       check(avcodec_parameters_from_context(audioFormatStream->codecpar, encoder));

       // Create resampler context
       resamplerCtx = swr_alloc();
       if (resamplerCtx == nullptr)
           throw std::runtime_error("Could not allocate resampler context");

       // Set options
       check(av_opt_set_int(resamplerCtx, "in_channel_count", 2, 0));
       check(av_opt_set_int(resamplerCtx, "in_sample_rate", 44100, 0));
       check(av_opt_set_sample_fmt(resamplerCtx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0));
       check(av_opt_set_int(resamplerCtx, "out_channel_count", encoder->channels, 0));
       check(av_opt_set_int(resamplerCtx, "out_sample_rate", encoder->sample_rate, 0));
       check(av_opt_set_sample_fmt(resamplerCtx, "out_sample_fmt", encoder->sample_fmt, 0));

       // initialize the resampling context
       check(swr_init(resamplerCtx));
    }

    And for resample I’ve this code :

       AVPacket pkt{};
       while (true)
       {
           AVPacket input_packet;
           av_init_packet(&input_packet);

           check(av_read_frame(inputContext, &input_packet));

           check(avcodec_send_packet(decoderContext, &input_packet));
           check(avcodec_receive_frame(decoderContext, decodedFrame));


           // WHAT DO HERE swr_convert(resamplerContext, )
           av_packet_unref(&input_packet);

           av_init_packet(&pkt);
           auto in_stream = inputContext->streams[pkt.stream_index];
           auto out_stream = outputContext->streams[pkt.stream_index];

           pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
           pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
           pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
           pkt.pos = -1;

           check(avcodec_send_frame(encoderContext, decodedFrame));
           check(avcodec_receive_packet(encoderContext, &pkt));

           check(av_interleaved_write_frame(outputContext, &pkt));
           av_packet_unref(&pkt);
       }

    REading the docs I can’t figure out what exactly I need to pass to function. I have this code to encode PCM to MP2 (output is AV_SAMPLE_FMT_S16)

    const uint8_t* inPtr[] { const_cast<const>(&amp;pcmData[0]), nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr };
    uint8_t* outPtr[] { &amp;resampledAudioData[0], nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr };

    int resampledSamplesCount{ swr_convert(
       resamplerCtx,
       outPtr,
       maxResampledSamplesCount,
       inPtr,
       inputSampleCount) };

    // Negativo indica erro.
    check(resampledSamplesCount);
    </const>

    pcmData is raw data from input AVPacket (PCM)

    What I get here is : MP2 isn’t planar so it uses the same outPtr[0] different from plannar which needs two valid pointers to same writable data. But what I need to pass to inPtr, for example ?

    When I try to use the same code, ffmpeg try to write on outPtr[1] which is nullptr.

  • How to hide/disable ffmpeg erros when using OpenCV (python) ?

    20 décembre 2019, par Mehran

    I’m using OpenCV python to capture a video.
    This is my code

    import cv2

    cap = cv2.VideoCapture("vid.mp4")
    while True:
       flag, frame =  cap.read()

       if not flag:
           cv2.imshow('video', frame)

       if cv2.waitKey(10) == 27:
           break

    When a frame is not ready it produces an error like this

    enter image description here

    or

    Truncating packet of size 2916 to 1536
    [h264 @ 0x7ffa4180be00] AVC: nal size 2912
    [h264 @ 0x7ffa4180be00] AVC: nal size 2912
    [h264 @ 0x7ffa4180be00] no frame!

    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffa41803000] stream 0, offset 0x14565: partial file

    I wanted to find a way to hide this error ! I guess that this error is being produced by ffmpeg. Is there any way to hide or disable it ?

    This error is produced when I call cap.read(). And I also tried to wrap it with try ... except ... but it doesn’t work because it doesn’t throw any exceptions.

  • MJPEG Stream works in Firefox but not in Chrome

    11 décembre 2019, par Maoration

    We have a system that contains cameras and we want to stream them to multiple clients.
    Behind the scenes on the server we get connections from cameras, we keep everything related to that camera in a CameraContainer, which also includes a mpegtsToMjpegStream that extends Duplex (both Readable and Writable Stream).

    after a camera connects, we open an ffmpeg process to work on the incoming mpegts stream, and output an MJPEG stream :

         '-map', '0:v', '-c:v', 'mjpeg','-f', 'mjpeg', `-`,

    ** we are doing this because we are also mapping to other outputs, like writing files.


    On the ’serving’ side, we are currently testing a simple API to GET an mjpeg stream with a camera id :

     async getCameraStream(@Param('cameraId') cameraId: string, @Res() res): Promise<any> {
    const cameraContainer = this.cameraBridgeService.getCameraContainer(cameraId);
    if (!cameraContainer) {
     throw new Error(`Camera with id: ${cameraId} was not found`);
    }

    if (!cameraContainer.mpegtsToMjpegStream) {
     throw new Error('ERROR: mpegtsToMjpegStream stream does not exist on this camera container');
    }

    const writable = new Writable({
     write: (chunk, encoding, callback) => {
       res.write(`Content-Type: image/jpeg\r\nContent-Length: ${chunk.length}\r\n\r\n`);
       res.write(chunk);
       res.write('\r\n--ffmpeg_streamer\r\n');
       callback();
     },
    });

    res.set('Content-Type', 'multipart/x-mixed-replace;boundary=ffmpeg_streamer');
    res.write('--ffmpeg_streamer\r\n');

    cameraContainer.mpegtsToMjpegStream.pipe(writable, { end: false });

    res.once('close', () => {
     if (cameraContainer.mpegtsToMjpegStream &amp;&amp; writable) {
       cameraContainer.mpegtsToMjpegStream.unpipe(writable);
     }
     res.destroy();
    });
    </any>

    The problem is this code works very nicely when accessing the stream with Firefox- after 1-2 seconds we get a stable, high quality, low latency stream.
    With Chrome however, the same code does not behave- the video output is corrupted, disappears into a black screen all the time, and we have to keep refreshing the page constantly just to view a few seconds of the stream until it disappears again.

    Any suggestions as to why this happens and how can I fix it ?