Recherche avancée

Médias (1)

Mot : - Tags -/punk

Autres articles (107)

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

Sur d’autres sites (14138)

  • Decode IP camera RTSP stream to pictures with ffmpeg library

    10 mars 2024, par lars

    I use c++ with curl library on linux to connect to my IP camera and retrieve data from RTPS video stream. I have succeeded to decode RTSP and RTP data but I haven't managed to put together the data into a frame that ffmpeg can read. I have read everything there is to read with no success. Is there anyone who can explain how to do this.

    


    Thanks

    


    Here is what I have come up with.

    


    curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);


    


    Parsing callback sdp description :

    


    packetization_mode = 1 e.i Non-Interleaved mode

    


    sprop-parameter-sets :

    


    Nal unit (SPS) = 274d0028e7403c0113f2e029414141...8ae0000f4145fffc0a 
Nal unit (PPS) = 28ee3c80 (Both are decoded values)


    


    Parsing SPS givs pic size 1920x1088 (the 8 ?)

    


    curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, URL_RTSPREQ_RECEIVE);


    


    Callback function :
Search for SPS, PPS and fragmentations

    


    size_t interleavedCallback(uint8_t *data, size_t size, size_t nmemb, USER_DATA *userp) {
    size_t data_size = size * nmemb;
    uint8_t *rtp_hdr = data + RTSP_HDR_SIZE;
    uint8_t *payload = data + RTSP_HDR_SIZE + RTP_HDR_SIZE;
    size_t payload_size = data_size - (RTSP_HDR_SIZE + RTP_HDR_SIZE);
    int seqNum = 0;

    uint8_t u = payload[0] << 3;
    int type = u >> 3;              // nal_unit_type
    int nri = payload[0] >> 5;
    seqNum = (rtp_hdr[2] << 8) + rtp_hdr[3];

   int ret = memcmp(payload, userp->sdp_data.SPS, userp->sdp_data.sizeSPS);
   if (0 == ret && !userp->newFrame) {
       userp->newFrame = true;
       payload[0] = type + 0x60;  // nal_unit_type

       size_t memsize = payload_size + sizeof(uint32_t);
       userp->frame.pFrame = (uint8_t*)calloc(memsize, sizeof(uint8_t));
       userp->frame.pFrame[3] = 1;
       memcpy(userp->frame.pFrame + sizeof(uint32_t), payload, payload_size);
       userp->frame.size = memsize;
    }
    else if (userp->newFrame && 28 == type && payload[1] == 0x45) {
        stop;
        userp->newFrame = false;
        size_t memsize = userp->frame.size + payload_size;
        userp->frame.pFrame = (uint8_t*)realloc(userp->frame.pFrame, memsize);
        payload[0] += 0x40;
        memcpy(userp->frame.pFrame + userp->frame.size, payload, payload_size);
        userp->frame.size = memsize;
    
        streamParser(userp->frame.pFrame, userp->frame.size);
    }
    else if (userp->newFrame) {
        if (8 == type) {
            payload[0] = type + 0x60;  // nal_unit_type
            size_t memsize = userp->frame.size + payload_size;
            userp->frame.pFrame[0] = 0;
            userp->frame.pFrame[1] = 0;
            userp->frame.pFrame[2] = 0;
            userp->frame.pFrame[3] = 1;
            userp->frame.pFrame = (uint8_t*)realloc(userp->frame.pFrame, memsize);
            memcpy(userp->frame.pFrame + userp->frame.size, 
                payload, payload_size);
            userp->frame.size = memsize;
        }
        else if (28 == type) {
            size_t memsize = userp->frame.size + payload_size;
            userp->frame.pFrame = (uint8_t*)realloc(userp->frame.pFrame, memsize);
            payload[0] += 0x40;
            memcpy(userp->frame.pFrame + userp->frame.size, payload, payload_size);
            userp->frame.size = memsize;
        }
    }

    return data_size;
}


void streamParser(uint8_t *frame, size_t size) {
    AV avinfo;

    avinfo.packet = av_packet_alloc();
    avinfo.codec = avcodec_find_decoder(AV_CODEC_ID_H264);
    avinfo.context = avcodec_alloc_context3(avinfo.codec);
    if (avcodec_open2(avinfo.context, avinfo.codec, NULL) >= 0) {
        avinfo.frame = av_frame_alloc();
        avinfo.packet->data = frame;
        avinfo.packet->size = size;
    
        int ret = avcodec_send_packet(avinfo.context,avinfo.packet);
        if (ret < 0) {
            return -1;
        }
        ......

        av_frame_free(&avinfo.frame);
    }
    avcodec_close(avinfo.context);
    av_free(avinfo.context);
}


    


    Error from avcodec_send_packet : no frame !

    


  • libswresample : swr_convert() returns empty buffer

    11 septembre 2019, par Герман Лиманський

    I try to convert audio in format AV_SAMPLE_FMT_S32. I use swr_convert(), but out buffer still empty.

    // frame is decoded frame, rframe - is empty frame(out buffer)

       if (!main_context->resampler) {
                       main_context->resampler =
                       swr_alloc_set_opts(main_context->resampler,
                       AV_CH_LAYOUT_STEREO,                    // output
                       AV_SAMPLE_FMT_S32,                      // output
                       44100,                                  // output
                       audio_codec_context->channel_layout,    // input
                       audio_codec_context->sample_fmt,        // input
                       audio_codec_context->sample_rate,       // input
                       0,
                       nullptr);
                   swr_init(main_context->resampler);

               }

               //int in_samples = frame->nb_samples;
               int out_samples = av_rescale_rnd(swr_get_delay(
                   main_context->resampler, 44100) + 44100,
                   44100,
                   44100,
                   AV_ROUND_UP);

               size_t buffSize = av_samples_alloc(rframe->data, NULL,audio_codec_context->channels, out_samples, AV_SAMPLE_FMT_S32, 0);
               int len = swr_convert(main_context->resampler, rframe->data, frame->nb_samples, (const uint8_t * *)frame->data, frame->nb_samples);
    //here.. rframe->data should have some data, but its empty
               while (len > 0)
               {
                   size_t size_ = rframe->nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S32);
                   main_context->audio_buf.write(rframe->data[0], size_, 1);

                   len = swr_convert(main_context->resampler, rframe->data, frame->nb_samples, NULL, NULL);
               }
  • Using ffmpeg to record screen returns corrupted file

    8 août 2020, par odddollar

    I'm using ffmpeg and python to record my desktop screen. I've got it working so that when I input a shortcut, it starts recording. Then I use .terminate() on the subprocess to stop recording. When outputting to an mp4, this corrupts the file and makes it unreadable. I can output the file as an flv or avi and it doesn't get corrupted, but then the video doesn't contain time/duration data, something I need.

    


    Is there a way I can gracefully stop the recording when outputting an mp4 ?
Or is there a way I can include the time/duration data in the flv/avi ?

    


    import keyboard
import os
from subprocess import Popen

class Main:
    def __init__(self):
        self.on = False

    def main(self):
        if not self.on:
            if os.path.isfile("output.mp4"):
                os.remove("output.mp4")

            self.process = Popen('ffmpeg -f gdigrab -framerate 30 -video_size 1920x1080 -i desktop -b:v 5M output.mp4')
            self.on = True
        else:
            self.process.terminate()

            self.on = False

run = Main()
keyboard.add_hotkey("ctrl+shift+g", lambda:run.main())

keyboard.wait()