Recherche avancée

Médias (91)

Autres articles (50)

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

  • Déploiements possibles

    31 janvier 2010, par

    Deux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
    L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
    Version mono serveur
    La version mono serveur consiste à n’utiliser qu’une (...)

Sur d’autres sites (5400)

  • How to make audio sound batter ? (C + FFMpeg audio generation example)

    31 janvier 2014, par Spender

    So I found this grate C FFMpeg official example which I simplified :

    #include
    #include
    #include

    #ifdef HAVE_AV_CONFIG_H
    #undef HAVE_AV_CONFIG_H
    #endif

    #include "libavcodec/avcodec.h"
    #include "libavutil/mathematics.h"

    #define INBUF_SIZE 4096
    #define AUDIO_INBUF_SIZE 20480
    #define AUDIO_REFILL_THRESH 4096

    /*
    * Audio encoding example
    */
    static void audio_encode_example(const char *filename)
    {
       AVCodec *codec;
       AVCodecContext *c= NULL;
       int frame_size, i, j, out_size, outbuf_size;
       FILE *f;
       short *samples;
       float t, tincr;
       uint8_t *outbuf;

       printf("Audio encoding\n");

       /* find the MP2 encoder */
       codec = avcodec_find_encoder(CODEC_ID_MP2);
       if (!codec) {
           fprintf(stderr, "codec not found\n");
           exit(1);
       }

       c= avcodec_alloc_context();

       /* put sample parameters */
       c->bit_rate = 64000;
       c->sample_rate = 44100;
       c->channels = 2;

       /* open it */
       if (avcodec_open(c, codec) < 0) {
           fprintf(stderr, "could not open codec\n");
           exit(1);
       }

       /* the codec gives us the frame size, in samples */
       frame_size = c->frame_size;
       samples = malloc(frame_size * 2 * c->channels);
       outbuf_size = 10000;
       outbuf = malloc(outbuf_size);

       f = fopen(filename, "wb");
       if (!f) {
           fprintf(stderr, "could not open %s\n", filename);
           exit(1);
       }

       /* encode a single tone sound */
       t = 0;
       tincr = 2 * M_PI * 440.0 / c->sample_rate;
       for(i=0;i<200;i++) {
           for(j=0;j* encode the samples */
           out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);
           fwrite(outbuf, 1, out_size, f);
       }
       fclose(f);
       free(outbuf);
       free(samples);

       avcodec_close(c);
       av_free(c);
    }

    int main(int argc, char **argv)
    {

       /* must be called before using avcodec lib */
       avcodec_init();

       /* register all the codecs */
       avcodec_register_all();

       audio_encode_example("test.mp2");

       return 0;
    }

    How should it sound like ? May be I don't get something but it sounds awful =( how to make audio generation sound batter/ more interesting/ melodical in a wary shourt way (no special functions just how to change this code to make it sound batter) ?

  • FFMPEG : Decode video in h264rgb/libx264rgb error

    9 février 2018, par Furan

    I did a small program to encode raw images in h264rgb codec with ffmpeg.
    I use this codec because I needed to encode lossless rgb images (not possible with the classic h264 codec).

    But now, I have a problem. I’m not able to decode the video generated with ffmpeg. I did a second small program for that, but I get a segfault when I reach the avcodec_decode_video2() function.

    I did all the initialisation correctly. I didn’t forget the avcodec_register_all() and av_init_packet() functions.

    Here is the code for initialisation :

     _c = NULL;
     _frame_nb = 0;

     // Register all formats and codecs
     #pragma omp critical
     {
         avcodec_register_all();
     }

     _pkt = new AVPacket;
     av_init_packet(_pkt);  // a defaut de pouvoir ecrire : pkt = av_packet_alloc();

     if(!_pkt)
         exit(1);

       _codec = avcodec_find_encoder_by_name("libx264rgb");

     if (!_codec) {
         fprintf(stderr, "codec not found\n");
         exit(1);
     }

     _c = avcodec_alloc_context3(_codec);
     if (!_c) {
         fprintf(stderr, "Could not allocate video codec context\n");
         exit(1);
     }

     _c->debug = true;
     _c->pix_fmt =  (AVPixelFormat)AV_PIX_FMT_RGB24;
     _c->width = this->_headerCam[this->_currentCam]->iNbCol;
     _c->height = this->_headerCam[this->_currentCam]->iNbLine;

     _picture = av_frame_alloc();
     if (!_picture) {
         fprintf(stderr, "Could not allocate video _picture\n");
         exit(1);
     }

     _tmp_picture = av_frame_alloc();
     if (!_tmp_picture) {
         fprintf(stderr, "Could not allocate video _tmp_picture\n");
         exit(1);
     }


         _tmp_picture->format = (AVPixelFormat)AV_PIX_FMT_RGB24;
         _tmp_picture->width = this->_headerCam[this->_currentCam]->iNbCol;
         _tmp_picture->height = this->_headerCam[this->_currentCam]->iNbLine;
         _tmp_picture->linesize[0] = this->_headerCam[this->_currentCam]->iNbCol;

     /* open it */
     if (avcodec_open2(_c, _codec, NULL) < 0) {
         fprintf(stderr, "could not open codec\n");
         exit(1);
     }

    And the decode function :

           _pkt->data = NULL;    // packet data will be allocated by the encoder
           _pkt->size = 0;

           unsigned char * inbuf;
           inbuf = (uint8_t*)av_malloc(w*h*3);

           //! read img size
           int size_img;
           fread(&size_img, sizeof(int), 1, this->_pFile);
           _pkt->size = fread(inbuf, 1, size_img, this->_pFile);

           _pkt->data = (unsigned char*)inbuf;

           if(_pkt->size)
           {
               len = avcodec_decode_video2(_c, _tmp_picture, &got_picture, _pkt);
               ...
           }

    Any idea ?

  • Issues Streaming FLV Video from RTSP using FFmpeg and Python to flv.js

    14 juin 2024, par yternal

    I am currently working on a project where I need to stream video from an RTSP source, convert it to FLV format using FFmpeg, and then send the FLV stream to clients upon request. The code I have written to achieve this is as follows :

    


    import subprocess
from flask import Flask, Response, stream_with_context

app = Flask(__name__)

flv_header = b''

def update_stream(ffmpeg_path="ffmpeg", rtsp_url='rtsp://192.168.1.168/0', rtsp_id="rtsp01"):
    global flv_header

    command = [
        ffmpeg_path,
        '-i', rtsp_url,
        '-c:v', 'libx264',
        '-c:a', 'aac',
        '-b:v', '1M',
        '-g', '30',
        '-preset', 'ultrafast',
        '-bsf:v', 'dump_extra',
        '-f', 'flv',
        '-'
    ]
    process = subprocess.Popen(
        command,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
    )
    flv_header = process.stdout.read(1024)
    while True:
        data = process.stdout.read(1024)
        if not data:
            break
        producer.notify(rtsp_id, data)

@app.route('/flv//')
def flv_stream(user_id, rtsp_id):
    try:
        consumer_queue = producer.register(user_id, rtsp_id)

        @stream_with_context
        def generate():
            yield flv_header
            while True:
                yield consumer_queue.get()

        response = Response(generate(), mimetype='video/x-flv')
        response.headers.add('Access-Control-Allow-Origin', '*')  # Allow all origins
        response.headers.add('Access-Control-Allow-Methods', '*')  # Allow all HTTP methods
        response.headers.add('Access-Control-Allow-Headers', 'Content-Type')  # Allow specific headers
        return response
    except Exception as e:
        print(f'{e}')


    


    In order to handle initial playback issues in FFplay and VLC, I save the first 1024 bytes of the FLV stream and send this header before streaming the actual data. This workaround allows playback in FFplay and VLC, but it does not work with flv.js.

    


    When attempting to play the stream using flv.js, the stream keeps loading indefinitely, and the console outputs warnings like :

    


    flv.min.js:9 [FLVDemuxer] > Invalid PrevTagSize 3491417133
[FLVDemuxer] > Unsupported tag type 204, skipped


    


    I have tried several modifications to the FFmpeg command, including adding parameters such as -bsf:v dump_extra, but none of these changes have resolved the issue. My expectation is that the FLV stream would play smoothly in flv.js just as it does in FFplay and VLC.