Recherche avancée

Médias (91)

Autres articles (101)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • L’agrémenter visuellement

    10 avril 2011

    MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
    Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (8110)

  • how to improve image quality when I write c++ using ffmpeg( avcodec)

    6 septembre 2021, par qycx

    I am writing a c++ program, using ffmpeg to encode video.
but the image quality is very bad.
can you help me to improve the video quality ?

    


    following is my code :

    


        pUnit->encV_var.pkt = av_packet_alloc();
    if (!pUnit->encV_var.pkt) {
        goto errLabel;
    }

    /* put sample parameters */
    pUnit->encV_var.c->bit_rate = bitrate;//400000;
    pUnit->encV_var.c->rc_max_rate=bitrate;
    pUnit->encV_var.c->rc_min_rate=bitrate;
    AVCodecContext *c=pUnit->encV_var.c;
    int br = bitrate;
    c->bit_rate_tolerance = br;
c->rc_buffer_size=br;
c->rc_initial_buffer_occupancy = c->rc_buffer_size*3/4;
//c->rc_buffer_aggressivity= (float)1.0;
//c->rc_initial_cplx= 0.5; 



    /* resolution must be a multiple of two */
    pUnit->encV_var.c->width = in_w;//352;
    pUnit->encV_var.c->height = in_h;//288;
    /* frames per second */
    AVRational t1={1,25};
    t1.den=fps;
    pUnit->encV_var.c->time_base = t1;//(AVRational){1, 25};
    AVRational t2={25,1};
    t2.num=fps;
    pUnit->encV_var.c->framerate = t2;//(AVRational){25, 1};

    /* emit one intra frame every ten frames
     * check frame pict_type before passing frame
     * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
     * then gop_size is ignored and the output of encoder
     * will always be I frame irrespective to gop_size
     */
    pUnit->encV_var.c->gop_size = 256;//10;
    pUnit->encV_var.c->max_b_frames = 0;//1;
    pUnit->encV_var.c->pix_fmt = AV_PIX_FMT_YUV420P;

    //
    pUnit->encV_var.c->flags|=AV_CODEC_FLAG_GLOBAL_HEADER;

    //
    if (codec_id == AV_CODEC_ID_H264) {
        int ret;
        ret = av_opt_set(pUnit->encV_var.c->priv_data, "preset", "fast", 0);
        //ret = av_opt_set(pUnit->encV_var.c->priv_data, "preset", "slow", 0);
        //ret = av_opt_set(pUnit->encV_var.c->priv_data, "preset", "medium", 0);

        //
        ret = av_opt_set(pUnit->encV_var.c->priv_data, "tune","zerolatency",0);

        //
        ret = av_opt_set(pUnit->encV_var.c->priv_data, "profile","main",0);

    }

    /* open it */
    ret = avcodec_open2(pUnit->encV_var.c, pUnit->encV_var.codec, NULL);
   


    


    please help me to improve image quality

    


    mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

    


  • FFMPEG/C++ How to simply write out/passthrough h264 stream ?

    11 août 2021, par Schuerta

    Im trying to learn the basics of ffmpeg writing (reading already works), so im just trying to take in an input .ts file and write out/passthrough the exact same h264 stream to a new output file. I dont get any compilation errors, but for some reason i cant figure out why my output file's framerate is very wrong. Also when i read in my output file, i get printouts saying "Packet corrupt (stream = 0, dts = #)"

    


    I followed the instructions in the ffmpeg library comments so im not sure what im missing. I call initOutStream(), then initH264encoder(), then during the reading/decoding readH264Packet() is called repeatedly. (Removed code for readability sake, left relevant sections below) ;

    


    Edit : If i put my output file through the actuall ffmpeg cmd app, the framerate issue seems to get fixed. Wonder where im messing up

    


    void test::initOutStream() {

//create muxing context
outstreamContext = avformat_alloc_context();

//oformat
AVOutputFormat *guessFormat; //Populate oformat
guessFormat = av_guess_format(NULL, inputVideoUrl.c_str(), NULL);
outstreamContext->oformat = guessFormat; 
outstreamContext->oformat->video_codec = AV_CODEC_ID_H264; 
//outstreamContext->bit_rate = 400000; //No affect; 

//pb
AVIOContext *outAVIOContext = nullptr;
//int result = avio_open(&outAVIOContext, outputVideoUrl.c_str(), AVIO_FLAG_WRITE);
int result = avio_open2(&outAVIOContext, outputVideoUrl.c_str(), AVIO_FLAG_WRITE, NULL, NULL); //Documentain said to use this method
outstreamContext->pb = outAVIOContext;
}


    


    .

    


    void test::initH264encoder() { //Frame -> packet&#xA;int result;&#xA;&#xA;h264OutCodec = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;&#xA;h264OutStream = avformat_new_stream(outstreamContext, h264OutCodec);&#xA;h264OutStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;h264OutStream->codecpar->codec_id = AV_CODEC_ID_H264;&#xA;h264OutStream->codecpar->width = 640;&#xA;h264OutStream->codecpar->height = 480;&#xA;h264OutStream->id = H264_STREAM_ID;&#xA;h264OutStream->codecpar->color_range = AVCOL_RANGE_MPEG;&#xA;//h264OutStream->codecpar->bit_rate = 400000;&#xA;&#xA;h264OutContext = avcodec_alloc_context3(h264OutCodec);&#xA;&#xA;h264OutContext->width = 640;&#xA;h264OutContext->height = 480;&#xA;h264OutContext->time_base = (AVRational){1,static_cast<int>(29.97)};&#xA;h264OutContext->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;&#xA;result = avcodec_open2(h264OutContext, h264OutCodec, nullptr);&#xA;&#xA;//Alloc packet &#x2B; finish&#xA;outPacket = av_packet_alloc();&#xA;&#xA;//Write header&#xA;result = avformat_write_header(outstreamContext, NULL);&#xA;}&#xA;</int>

    &#xA;

    Assume that reading was set up correctly

    &#xA;

    void test::readH264Packet(__unused uint64_t tick) {&#xA;//...av_read_frame(streamContext, inPacket);&#xA;//...avcodec_send_packet(h264Context, inPacket);&#xA;//...avcodec_receive_frame(h264Context, yuvFrame)&#xA;//My passthrough:&#xA;if(shouldOutputH264Stream){&#xA;        result = avcodec_send_frame(h264OutContext, yuvFrame); //1. Encode frame to packet&#xA;        result = avcodec_receive_packet(h264OutContext, outPacket2); //2. get encoded packet&#xA;        result = av_interleaved_write_frame(outstreamContext, outPacket2); //3. write packet&#xA;        //Write trailer and free happens later&#xA;    }&#xA;}&#xA;

    &#xA;

  • ffmpeg regenerate m3u8 from multi ts file

    17 juin 2021, par Mulham Aryan

    I have generated hls videos using FFmpeg with output m3u8.&#xA;m3u8 file content

    &#xA;

    #EXTM3U&#xA;#EXT-X-VERSION:3&#xA;#EXT-X-TARGETDURATION:2&#xA;#EXT-X-MEDIA-SEQUENCE:1&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie1.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie2.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie3.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie4.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie5.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie6.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie7.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie8.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie9.ts&#xA;#EXTINF:2.400000,&#xA;ffmpegmovie10.ts&#xA;

    &#xA;

    so let suppose that I'm going to take only files from 1 to 5&#xA;the m3u8 file should be like this

    &#xA;

    #EXTM3U&#xA;    #EXT-X-VERSION:3&#xA;    #EXT-X-TARGETDURATION:2&#xA;    #EXT-X-MEDIA-SEQUENCE:1&#xA;    #EXTINF:2.400000,&#xA;    ffmpegmovie1.ts&#xA;    #EXTINF:2.400000,&#xA;    ffmpegmovie2.ts&#xA;    #EXTINF:2.400000,&#xA;    ffmpegmovie3.ts&#xA;    #EXTINF:2.400000,&#xA;    ffmpegmovie4.ts&#xA;    #EXTINF:2.400000,&#xA;    ffmpegmovie5.ts&#xA;

    &#xA;

    so the question is : is there any command from FFmpeg lets me input multiple ts files and get an output in m3u8 ?&#xA;example

    &#xA;

    ffmpeg -i ffmpegmovie1.ts, ffmpegmovie2.ts, ffmpegmovie3.ts, .... >> output.m3u8&#xA;

    &#xA;