Recherche avancée

Médias (0)

Mot : - Tags -/logo

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

Autres articles (65)

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

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

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

Sur d’autres sites (9915)

  • Unable to encode H264 video using FFMPEG example

    4 mai 2020, par Basit Anwer

    FFMPEG encode example fails to create a H264 video. MPEG1 works fine though.

    



    Pasting the code here as well

    



    &#xA;     * @file&#xA;     * video encoding with libavcodec API example&#xA;     *&#xA;     * @example encode_video.c&#xA;     */&#xA;    #include &#xA;    #include &#xA;    #include &#xA;    #include <libavcodec></libavcodec>avcodec.h>&#xA;    #include <libavutil></libavutil>opt.h>&#xA;    #include <libavutil></libavutil>imgutils.h>&#xA;    static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,&#xA;                       FILE *outfile)&#xA;    {&#xA;        int ret;&#xA;        /* send the frame to the encoder */&#xA;        if (frame)&#xA;            printf("Send frame %3"PRId64"\n", frame->pts);&#xA;        ret = avcodec_send_frame(enc_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error sending a frame for encoding\n");&#xA;            exit(1);&#xA;        }&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(enc_ctx, pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                return;&#xA;            else if (ret &lt; 0) {&#xA;                fprintf(stderr, "Error during encoding\n");&#xA;                exit(1);&#xA;            }&#xA;            printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);&#xA;            fwrite(pkt->data, 1, pkt->size, outfile);&#xA;            av_packet_unref(pkt);&#xA;        }&#xA;    }&#xA;&#xA;    int main(int argc, char **argv)&#xA;    {&#xA;        const char *filename, *codec_name;&#xA;        const AVCodec *codec;&#xA;        AVCodecContext *c= NULL;&#xA;        int i, ret, x, y;&#xA;        FILE *f;&#xA;        AVFrame *frame;&#xA;        AVPacket *pkt;&#xA;        uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;        if (argc &lt;= 2) {&#xA;            fprintf(stderr, "Usage: %s <output file="file"> <codec>\n", argv[0]);&#xA;            exit(0);&#xA;        }&#xA;        filename = argv[1];&#xA;        codec_name = argv[2];&#xA;        /* find the mpeg1video encoder */&#xA;        codec = avcodec_find_encoder_by_name(codec_name);&#xA;        if (!codec) {&#xA;            fprintf(stderr, "Codec &#x27;%s&#x27; not found\n", codec_name);&#xA;            exit(1);&#xA;        }&#xA;        c = avcodec_alloc_context3(codec);&#xA;        if (!c) {&#xA;            fprintf(stderr, "Could not allocate video codec context\n");&#xA;            exit(1);&#xA;        }&#xA;        pkt = av_packet_alloc();&#xA;        if (!pkt)&#xA;            exit(1);&#xA;        /* put sample parameters */&#xA;        c->bit_rate = 400000;&#xA;        /* resolution must be a multiple of two */&#xA;        c->width = 352;&#xA;        c->height = 288;&#xA;        /* frames per second */&#xA;        c->time_base = (AVRational){1, 25};&#xA;        c->framerate = (AVRational){25, 1};&#xA;        /* emit one intra frame every ten frames&#xA;         * check frame pict_type before passing frame&#xA;         * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I&#xA;         * then gop_size is ignored and the output of encoder&#xA;         * will always be I frame irrespective to gop_size&#xA;         */&#xA;        c->gop_size = 10;&#xA;        c->max_b_frames = 1;&#xA;        c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;        if (codec->id == AV_CODEC_ID_H264)&#xA;            av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;        /* open it */&#xA;        ret = avcodec_open2(c, codec, NULL);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;        f = fopen(filename, "wb");&#xA;        if (!f) {&#xA;            fprintf(stderr, "Could not open %s\n", filename);&#xA;            exit(1);&#xA;        }&#xA;        frame = av_frame_alloc();&#xA;        if (!frame) {&#xA;            fprintf(stderr, "Could not allocate video frame\n");&#xA;            exit(1);&#xA;        }&#xA;        frame->format = c->pix_fmt;&#xA;        frame->width  = c->width;&#xA;        frame->height = c->height;&#xA;        ret = av_frame_get_buffer(frame, 32);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not allocate the video frame data\n");&#xA;            exit(1);&#xA;        }&#xA;        /* encode 1 second of video */&#xA;        for (i = 0; i &lt; 25; i&#x2B;&#x2B;) {&#xA;            fflush(stdout);&#xA;            /* make sure the frame data is writable */&#xA;            ret = av_frame_make_writable(frame);&#xA;            if (ret &lt; 0)&#xA;                exit(1);&#xA;            /* prepare a dummy image */&#xA;            /* Y */&#xA;            for (y = 0; y &lt; c->height; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width; x&#x2B;&#x2B;) {&#xA;                    frame->data[0][y * frame->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;                }&#xA;            }&#xA;            /* Cb and Cr */&#xA;            for (y = 0; y &lt; c->height/2; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width/2; x&#x2B;&#x2B;) {&#xA;                    frame->data[1][y * frame->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;                    frame->data[2][y * frame->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;                }&#xA;            }&#xA;            frame->pts = i;&#xA;            /* encode the image */&#xA;            encode(c, frame, pkt, f);&#xA;        }&#xA;        /* flush the encoder */&#xA;        encode(c, NULL, pkt, f);&#xA;        /* add sequence end code to have a real MPEG file */&#xA;        if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)&#xA;            fwrite(endcode, 1, sizeof(endcode), f);&#xA;        fclose(f);&#xA;        avcodec_free_context(&amp;c);&#xA;        av_frame_free(&amp;frame);&#xA;        av_packet_free(&amp;pkt);&#xA;        return 0;&#xA;    }&#xA;</codec></output>

    &#xA;&#xA;

    The code fails at encode call and every avcodec_receive_packet call returns AVERROR(EAGAIN)

    &#xA;&#xA;

    What am i missing here ?

    &#xA;

  • How to get FFMPEG to encode H264 using libx264 ?

    4 mai 2020, par Basit Anwer

    FFMPEG encode example fails to create a H264 video. MPEG1 works fine though.

    &#xA;&#xA;

    Pasting the code here as well

    &#xA;&#xA;

    &#xA;     * @file&#xA;     * video encoding with libavcodec API example&#xA;     *&#xA;     * @example encode_video.c&#xA;     */&#xA;    #include &#xA;    #include &#xA;    #include &#xA;    #include <libavcodec></libavcodec>avcodec.h>&#xA;    #include <libavutil></libavutil>opt.h>&#xA;    #include <libavutil></libavutil>imgutils.h>&#xA;    static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,&#xA;                       FILE *outfile)&#xA;    {&#xA;        int ret;&#xA;        /* send the frame to the encoder */&#xA;        if (frame)&#xA;            printf("Send frame %3"PRId64"\n", frame->pts);&#xA;        ret = avcodec_send_frame(enc_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error sending a frame for encoding\n");&#xA;            exit(1);&#xA;        }&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(enc_ctx, pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                return;&#xA;            else if (ret &lt; 0) {&#xA;                fprintf(stderr, "Error during encoding\n");&#xA;                exit(1);&#xA;            }&#xA;            printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);&#xA;            fwrite(pkt->data, 1, pkt->size, outfile);&#xA;            av_packet_unref(pkt);&#xA;        }&#xA;    }&#xA;&#xA;    int main(int argc, char **argv)&#xA;    {&#xA;        const char *filename, *codec_name;&#xA;        const AVCodec *codec;&#xA;        AVCodecContext *c= NULL;&#xA;        int i, ret, x, y;&#xA;        FILE *f;&#xA;        AVFrame *frame;&#xA;        AVPacket *pkt;&#xA;        uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;        if (argc &lt;= 2) {&#xA;            fprintf(stderr, "Usage: %s <output file="file"> <codec>\n", argv[0]);&#xA;            exit(0);&#xA;        }&#xA;        filename = argv[1];&#xA;        codec_name = argv[2];&#xA;        /* find the mpeg1video encoder */&#xA;        codec = avcodec_find_encoder_by_name(codec_name);&#xA;        if (!codec) {&#xA;            fprintf(stderr, "Codec &#x27;%s&#x27; not found\n", codec_name);&#xA;            exit(1);&#xA;        }&#xA;        c = avcodec_alloc_context3(codec);&#xA;        if (!c) {&#xA;            fprintf(stderr, "Could not allocate video codec context\n");&#xA;            exit(1);&#xA;        }&#xA;        pkt = av_packet_alloc();&#xA;        if (!pkt)&#xA;            exit(1);&#xA;        /* put sample parameters */&#xA;        c->bit_rate = 400000;&#xA;        /* resolution must be a multiple of two */&#xA;        c->width = 352;&#xA;        c->height = 288;&#xA;        /* frames per second */&#xA;        c->time_base = (AVRational){1, 25};&#xA;        c->framerate = (AVRational){25, 1};&#xA;        /* emit one intra frame every ten frames&#xA;         * check frame pict_type before passing frame&#xA;         * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I&#xA;         * then gop_size is ignored and the output of encoder&#xA;         * will always be I frame irrespective to gop_size&#xA;         */&#xA;        c->gop_size = 10;&#xA;        c->max_b_frames = 1;&#xA;        c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;        if (codec->id == AV_CODEC_ID_H264)&#xA;            av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;        /* open it */&#xA;        ret = avcodec_open2(c, codec, NULL);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;        f = fopen(filename, "wb");&#xA;        if (!f) {&#xA;            fprintf(stderr, "Could not open %s\n", filename);&#xA;            exit(1);&#xA;        }&#xA;        frame = av_frame_alloc();&#xA;        if (!frame) {&#xA;            fprintf(stderr, "Could not allocate video frame\n");&#xA;            exit(1);&#xA;        }&#xA;        frame->format = c->pix_fmt;&#xA;        frame->width  = c->width;&#xA;        frame->height = c->height;&#xA;        ret = av_frame_get_buffer(frame, 32);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not allocate the video frame data\n");&#xA;            exit(1);&#xA;        }&#xA;        /* encode 1 second of video */&#xA;        for (i = 0; i &lt; 25; i&#x2B;&#x2B;) {&#xA;            fflush(stdout);&#xA;            /* make sure the frame data is writable */&#xA;            ret = av_frame_make_writable(frame);&#xA;            if (ret &lt; 0)&#xA;                exit(1);&#xA;            /* prepare a dummy image */&#xA;            /* Y */&#xA;            for (y = 0; y &lt; c->height; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width; x&#x2B;&#x2B;) {&#xA;                    frame->data[0][y * frame->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;                }&#xA;            }&#xA;            /* Cb and Cr */&#xA;            for (y = 0; y &lt; c->height/2; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width/2; x&#x2B;&#x2B;) {&#xA;                    frame->data[1][y * frame->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;                    frame->data[2][y * frame->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;                }&#xA;            }&#xA;            frame->pts = i;&#xA;            /* encode the image */&#xA;            encode(c, frame, pkt, f);&#xA;        }&#xA;        /* flush the encoder */&#xA;        encode(c, NULL, pkt, f);&#xA;        /* add sequence end code to have a real MPEG file */&#xA;        if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)&#xA;            fwrite(endcode, 1, sizeof(endcode), f);&#xA;        fclose(f);&#xA;        avcodec_free_context(&amp;c);&#xA;        av_frame_free(&amp;frame);&#xA;        av_packet_free(&amp;pkt);&#xA;        return 0;&#xA;    }&#xA;</codec></output>

    &#xA;&#xA;

    The code fails at encode call and every avcodec_receive_packet call returns AVERROR(EAGAIN)

    &#xA;&#xA;

    What am i missing here ?

    &#xA;

  • How to get FFMPEG to encode H264 using libx264 ?

    12 décembre 2021, par Basit Anwer

    FFMPEG encode example fails to create a H264 video. MPEG1 works fine though.

    &#xA;&#xA;

    Pasting the code here as well

    &#xA;&#xA;

    &#xA;     * @file&#xA;     * video encoding with libavcodec API example&#xA;     *&#xA;     * @example encode_video.c&#xA;     */&#xA;    #include &#xA;    #include &#xA;    #include &#xA;    #include <libavcodec></libavcodec>avcodec.h>&#xA;    #include <libavutil></libavutil>opt.h>&#xA;    #include <libavutil></libavutil>imgutils.h>&#xA;    static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,&#xA;                       FILE *outfile)&#xA;    {&#xA;        int ret;&#xA;        /* send the frame to the encoder */&#xA;        if (frame)&#xA;            printf("Send frame %3"PRId64"\n", frame->pts);&#xA;        ret = avcodec_send_frame(enc_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error sending a frame for encoding\n");&#xA;            exit(1);&#xA;        }&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(enc_ctx, pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                return;&#xA;            else if (ret &lt; 0) {&#xA;                fprintf(stderr, "Error during encoding\n");&#xA;                exit(1);&#xA;            }&#xA;            printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);&#xA;            fwrite(pkt->data, 1, pkt->size, outfile);&#xA;            av_packet_unref(pkt);&#xA;        }&#xA;    }&#xA;&#xA;    int main(int argc, char **argv)&#xA;    {&#xA;        const char *filename, *codec_name;&#xA;        const AVCodec *codec;&#xA;        AVCodecContext *c= NULL;&#xA;        int i, ret, x, y;&#xA;        FILE *f;&#xA;        AVFrame *frame;&#xA;        AVPacket *pkt;&#xA;        uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;        if (argc &lt;= 2) {&#xA;            fprintf(stderr, "Usage: %s <output file="file"> <codec>\n", argv[0]);&#xA;            exit(0);&#xA;        }&#xA;        filename = argv[1];&#xA;        codec_name = argv[2];&#xA;        /* find the mpeg1video encoder */&#xA;        codec = avcodec_find_encoder_by_name(codec_name);&#xA;        if (!codec) {&#xA;            fprintf(stderr, "Codec &#x27;%s&#x27; not found\n", codec_name);&#xA;            exit(1);&#xA;        }&#xA;        c = avcodec_alloc_context3(codec);&#xA;        if (!c) {&#xA;            fprintf(stderr, "Could not allocate video codec context\n");&#xA;            exit(1);&#xA;        }&#xA;        pkt = av_packet_alloc();&#xA;        if (!pkt)&#xA;            exit(1);&#xA;        /* put sample parameters */&#xA;        c->bit_rate = 400000;&#xA;        /* resolution must be a multiple of two */&#xA;        c->width = 352;&#xA;        c->height = 288;&#xA;        /* frames per second */&#xA;        c->time_base = (AVRational){1, 25};&#xA;        c->framerate = (AVRational){25, 1};&#xA;        /* emit one intra frame every ten frames&#xA;         * check frame pict_type before passing frame&#xA;         * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I&#xA;         * then gop_size is ignored and the output of encoder&#xA;         * will always be I frame irrespective to gop_size&#xA;         */&#xA;        c->gop_size = 10;&#xA;        c->max_b_frames = 1;&#xA;        c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;        if (codec->id == AV_CODEC_ID_H264)&#xA;            av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;        /* open it */&#xA;        ret = avcodec_open2(c, codec, NULL);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;        f = fopen(filename, "wb");&#xA;        if (!f) {&#xA;            fprintf(stderr, "Could not open %s\n", filename);&#xA;            exit(1);&#xA;        }&#xA;        frame = av_frame_alloc();&#xA;        if (!frame) {&#xA;            fprintf(stderr, "Could not allocate video frame\n");&#xA;            exit(1);&#xA;        }&#xA;        frame->format = c->pix_fmt;&#xA;        frame->width  = c->width;&#xA;        frame->height = c->height;&#xA;        ret = av_frame_get_buffer(frame, 32);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not allocate the video frame data\n");&#xA;            exit(1);&#xA;        }&#xA;        /* encode 1 second of video */&#xA;        for (i = 0; i &lt; 25; i&#x2B;&#x2B;) {&#xA;            fflush(stdout);&#xA;            /* make sure the frame data is writable */&#xA;            ret = av_frame_make_writable(frame);&#xA;            if (ret &lt; 0)&#xA;                exit(1);&#xA;            /* prepare a dummy image */&#xA;            /* Y */&#xA;            for (y = 0; y &lt; c->height; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width; x&#x2B;&#x2B;) {&#xA;                    frame->data[0][y * frame->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;                }&#xA;            }&#xA;            /* Cb and Cr */&#xA;            for (y = 0; y &lt; c->height/2; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width/2; x&#x2B;&#x2B;) {&#xA;                    frame->data[1][y * frame->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;                    frame->data[2][y * frame->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;                }&#xA;            }&#xA;            frame->pts = i;&#xA;            /* encode the image */&#xA;            encode(c, frame, pkt, f);&#xA;        }&#xA;        /* flush the encoder */&#xA;        encode(c, NULL, pkt, f);&#xA;        /* add sequence end code to have a real MPEG file */&#xA;        if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)&#xA;            fwrite(endcode, 1, sizeof(endcode), f);&#xA;        fclose(f);&#xA;        avcodec_free_context(&amp;c);&#xA;        av_frame_free(&amp;frame);&#xA;        av_packet_free(&amp;pkt);&#xA;        return 0;&#xA;    }&#xA;</codec></output>

    &#xA;&#xA;

    The code fails at encode call and every avcodec_receive_packet call returns AVERROR(EAGAIN)

    &#xA;&#xA;

    What am i missing here ?

    &#xA;