Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

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

Autres articles (69)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

Sur d’autres sites (11196)

  • How to add subtitles to the encoded video using ffmpeg ?

    14 novembre 2019, par geo-freak

    I am trying to add my srt file to the video using the options which were answered here before. My input file has captions in it by default. I tried in different ways to get the captions enabled in my encoded video. Below are the commands I used.

    ffmpeg  -i input.ts -i captions.srt -b:a 32000 -ar 48000  -force_key_frames 'expr:gte(t,n_forced*3)' -acodec libfaac -hls_flags single_file -hls_list_size 0 -hls_time 3 -vcodec libx264 -s 320x240 -b:v 512000 -maxrate 512000 -c:s mov_text outfile.ts

    But I couldn’t see the captions after I see the mediainfo of the encoded file. You can see the log file of my command.

    [mpegts @ 0x56412e67b0c0] max_analyze_duration 5000000 reached at 5024000 microseconds st:1
    input.ts FPS 29.970030 1
    Input #0, mpegts, from 'input.ts':
     Duration: 00:03:00.07, start: 1.400000, bitrate: 2172 kb/s
     Program 1
       Metadata:
         service_name    : Service01
         service_provider: FFmpeg
       Stream #0:0[0x100]: Video: mpeg2video (Main), 1 reference frame ([2][0][0][0] / 0x0002), yuv420p(tv), 704x480 [SAR 10:11 DAR 4:3], Closed Captions, max. 15000 kb/s,
    29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
       Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 192 kb/s
    Input #1, srt, from 'captions.srt':
     Duration: N/A, bitrate: N/A
       Stream #1:0: Subtitle: subrip
    [graph 0 input from stream 0:0 @ 0x56412e678540] w:704 h:480 pixfmt:yuv420p tb:1/90000 fr:30000/1001 sar:10/11 sws_param:flags=2
    [scaler for output stream 0:0 @ 0x56412e9caac0] w:320 h:240 flags:'bicubic' interl:0
    [scaler for output stream 0:0 @ 0x56412e9caac0] w:704 h:480 fmt:yuv420p sar:10/11 -> w:320 h:240 fmt:yuv420p sar:1/1 flags:0x4
    [graph 1 input from stream 0:1 @ 0x56412e9f74e0] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
    [audio format for output stream 0:1 @ 0x56412e9f7b40] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format
    for output stream 0:1'                                                                                                                                              
    [auto-inserted resampler 0 @ 0x56412e9f9f20] ch:2 chl:stereo fmt:fltp r:48000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
    [libx264 @ 0x56412e9bb8c0] VBV maxrate specified, but no bufsize, ignored
    [libx264 @ 0x56412e9bb8c0] using SAR=1/1
    [libx264 @ 0x56412e9bb8c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    [libx264 @ 0x56412e9bb8c0] profile High, level 2.0
    [mpegts @ 0x56412e9ba5a0] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
    Output #0, mpegts, to 'my_encoded_all-3.ts':
     Metadata:
       encoder         : Lavf57.25.100
       Stream #0:0: Video: h264 (libx264), -1 reference frame, yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 512 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
       Metadata:
         encoder         : Lavc57.24.102 libx264
       Side data:
         unknown side data type 10 (24 bytes)
       Stream #0:1(eng): Audio: aac (libfaac), 48000 Hz, stereo, s16, 32 kb/s
       Metadata:
         encoder         : Lavc57.24.102 libfaac
       Stream #0:2(eng): Subtitle: subrip (srt), 320x240
           Metadata:
             encoder         : Lavc57.24.102 srt
       Stream mapping:
         Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
         Stream #0:1 -> #0:1 (ac3 (native) -> aac (libfaac))
         Stream #1:0 -> #0:2 (subrip (srt) -> subrip (srt))
    Press [q] to stop, [?] for help
    [scaler for output stream 0:0 @ 0x56412e9caac0] w:704 h:480 fmt:yuv420p sar:40/33 -> w:320 h:240 fmt:yuv420p sar:4/3 flags:0x4
    No more output streams to write to, finishing.e=00:02:58.85 bitrate= 658.4kbits/s speed=13.2x
    frame= 5377 fps=385 q=-1.0 Lsize=   16672kB time=00:59:16.18 bitrate=  38.4kbits/s speed= 255x
    video:11401kB audio:1410kB subtitle:446kB other streams:0kB global headers:0kB muxing overhead: 25.753614%
    Input file #0 (input.ts):
     Input stream #0:0 (video): 5380 packets read (40279443 bytes); 5377 frames decoded;
     Input stream #0:1 (audio): 5625 packets read (4320000 bytes); 5625 frames decoded (8640000 samples);
     Total: 11005 packets (44599443 bytes) demuxed
    Input file #1 (captions.srt):
     Input stream #1:0 (subtitle): 10972 packets read (447147 bytes); 10972 frames decoded;
     Total: 10972 packets (447147 bytes) demuxed
    Output file #0 (output.ts):
     Output stream #0:0 (video): 5377 frames encoded; 5377 packets muxed (11675098 bytes);
     Output stream #0:1 (audio): 8438 frames encoded (8640000 samples); 8439 packets muxed (1444109 bytes);
     Output stream #0:2 (subtitle): 10972 frames encoded; 10972 packets muxed (456619 bytes);
     Total: 24788 packets (13575826 bytes) muxed
    [libx264 @ 0x56412e9bb8c0] frame I:81    Avg QP:15.08  size: 16370
    [libx264 @ 0x56412e9bb8c0] frame P:2312  Avg QP:17.77  size:  3393
    [libx264 @ 0x56412e9bb8c0] frame B:2984  Avg QP:22.38  size:   839
    [libx264 @ 0x56412e9bb8c0] consecutive B-frames: 20.6% 13.2%  9.4% 56.8%
    [libx264 @ 0x56412e9bb8c0] mb I  I16..4: 11.6% 37.0% 51.4%
    [libx264 @ 0x56412e9bb8c0] mb P  I16..4:  1.2%  3.2%  2.4%  P16..4: 33.7% 18.0% 15.7%  0.0%  0.0%    skip:25.6%
    [libx264 @ 0x56412e9bb8c0] mb B  I16..4:  0.2%  0.3%  0.2%  B16..8: 30.7%  9.2%  3.2%  direct: 5.1%  skip:51.1%  L0:33.6% L1:44.5% BI:21.9%
    [libx264 @ 0x56412e9bb8c0] final ratefactor: 16.76
    [libx264 @ 0x56412e9bb8c0] 8x8 transform intra:43.0% inter:49.8%
    [libx264 @ 0x56412e9bb8c0] coded y,uvDC,uvAC intra: 77.9% 85.1% 68.8% inter: 22.9% 21.7% 6.0%
    [libx264 @ 0x56412e9bb8c0] i16 v,h,dc,p: 30% 38%  5% 26%
    [libx264 @ 0x56412e9bb8c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 23% 18%  4%  5%  7%  6%  7%  8%
    [libx264 @ 0x56412e9bb8c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 23% 11%  5%  6%  8%  6%  7%  6%
    [libx264 @ 0x56412e9bb8c0] i8c dc,h,v,p: 46% 24% 21%  8%
    [libx264 @ 0x56412e9bb8c0] Weighted P-Frames: Y:4.2% UV:2.6%
    [libx264 @ 0x56412e9bb8c0] ref P L0: 73.3% 10.9% 11.1%  4.5%  0.1%
    [libx264 @ 0x56412e9bb8c0] ref B L0: 92.1%  6.3%  1.6%
    [libx264 @ 0x56412e9bb8c0] ref B L1: 97.4%  2.6%

    I found no issues in encoding but I couldn’t see the captions enabled in my output encoded video. I played it in my VLC player. No tracks for subtitles.

    Can’t we add the subtitles to a video while encoding ?

    Any help in achieving this would be appreciated.

  • avcodec_find_encoder_by_name() returns NULL

    27 décembre 2019, par GiuTor

    I’m trying to compile the following example I found on ffmpeg documentation :

    /*
    * Copyright (c) 2001 Fabrice Bellard
    *
    * Permission is hereby granted, free of charge, to any person obtaining a copy
    * of this software and associated documentation files (the "Software"), to deal
    * in the Software without restriction, including without limitation the rights
    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    * copies of the Software, and to permit persons to whom the Software is
    * furnished to do so, subject to the following conditions:
    *
    * The above copyright notice and this permission notice shall be included in
    * all copies or substantial portions of the Software.
    *
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    * THE SOFTWARE.
    */

    // compile with gcc -o encode_video encode_video.c -lavutil -lavcodec -lz -lm

    /**
    * @file
    * video encoding with libavcodec API example
    *
    * @example encode_video.c
    */

    #include
    #include
    #include

    #include <libavcodec></libavcodec>avcodec.h>

    #include <libavutil></libavutil>opt.h>
    #include <libavutil></libavutil>imgutils.h>

    static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,
                      FILE *outfile)
    {
       int ret;

       /* send the frame to the encoder */
       if (frame)
           printf("Send frame %3"PRId64"\n", frame->pts);

       ret = avcodec_send_frame(enc_ctx, frame);
       if (ret &lt; 0) {
           fprintf(stderr, "Error sending a frame for encoding\n");
           exit(1);
       }

       while (ret >= 0) {
           ret = avcodec_receive_packet(enc_ctx, pkt);
           if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
               return;
           else if (ret &lt; 0) {
               fprintf(stderr, "Error during encoding\n");
               exit(1);
           }

           printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);
           fwrite(pkt->data, 1, pkt->size, outfile);
           av_packet_unref(pkt);
       }
    }

    int main(int argc, char **argv)
    {
       const char *filename, *codec_name;
       const AVCodec *codec;
       AVCodecContext *c= NULL;
       int i, ret, x, y;
       FILE *f;
       AVFrame *frame;
       AVPacket *pkt;
       uint8_t endcode[] = { 0, 0, 1, 0xb7 };

       if (argc &lt;= 2) {
           fprintf(stderr, "Usage: %s <output file="file"> <codec>\n", argv[0]);
           exit(0);
       }
       filename = argv[1];
       codec_name = argv[2];

       /* find the mpeg1video encoder */
       codec = avcodec_find_encoder_by_name(codec_name);
       if (!codec) {
           fprintf(stderr, "Codec '%s' not found\n", codec_name);
           exit(1);
       }

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

       pkt = av_packet_alloc();
       if (!pkt)
           exit(1);

       /* put sample parameters */
       c->bit_rate = 400000;
       /* resolution must be a multiple of two */
       c->width = 352;
       c->height = 288;
       /* frames per second */
       c->time_base = (AVRational){1, 25};
       c->framerate = (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
        */
       c->gop_size = 10;
       c->max_b_frames = 1;
       c->pix_fmt = AV_PIX_FMT_YUV420P;

       if (codec->id == AV_CODEC_ID_H264)
           av_opt_set(c->priv_data, "preset", "slow", 0);

       /* open it */
       ret = avcodec_open2(c, codec, NULL);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));
           exit(1);
       }

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

       frame = av_frame_alloc();
       if (!frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(1);
       }
       frame->format = c->pix_fmt;
       frame->width  = c->width;
       frame->height = c->height;

       ret = av_frame_get_buffer(frame, 32);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate the video frame data\n");
           exit(1);
       }

       /* encode 1 second of video */
       for (i = 0; i &lt; 25; i++) {
           fflush(stdout);

           /* make sure the frame data is writable */
           ret = av_frame_make_writable(frame);
           if (ret &lt; 0)
               exit(1);

           /* prepare a dummy image */
           /* Y */
           for (y = 0; y &lt; c->height; y++) {
               for (x = 0; x &lt; c->width; x++) {
                   frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
               }
           }

           /* Cb and Cr */
           for (y = 0; y &lt; c->height/2; y++) {
               for (x = 0; x &lt; c->width/2; x++) {
                   frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
                   frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
               }
           }

           frame->pts = i;

           /* encode the image */
           encode(c, frame, pkt, f);
       }

       /* flush the encoder */
       encode(c, NULL, pkt, f);

       /* add sequence end code to have a real MPEG file */
       if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)
           fwrite(endcode, 1, sizeof(endcode), f);
       fclose(f);

       avcodec_free_context(&amp;c);
       av_frame_free(&amp;frame);
       av_packet_free(&amp;pkt);

       return 0;
    }
    </codec></output>

    ffmpeg -codecs return a bunch of codecs among which libx264 and libx265. When I run the above code I get NULL from avcodec_find_encoder_by_name() :

    gt@gt-Aspire-E1-570 : /libav$ ./encode_video pippo libx264
    Codec ’libx264’ not found
    gt@gt-Aspire-E1-570 : /libav$ ./encode_video pippo x264
    Codec ’x264’ not found
    gt@gt-Aspire-E1-570 : /libav$ ./encode_video pippo H264
    Codec ’H264’ not found
    gt@gt-Aspire-E1-570 : /libav$

    Can someone help please ?

    Thanks

  • Encode buffer captured by OpenGL in C

    4 janvier 2020, par M. Ying

    I am trying to use OpenGL to capture the back buffer of my computer’s screen, and then H.264 encode the buffer using FFMPEG’s libavcodec library. The issue I’m having is that I would like to encode the video in AV_PIX_FMT_420P, but the back buffer capture function provided by OpenGL, glReadPixels(), only supports formats like GL_RGB. As you can see below, I try to use FFMPEG’s swscale() function to convert from RGB to YUV, but the following code crashes at the swscale() line. Any ideas on how I can encode the OpenGL backbuffer ?

    // CAPTURE BACK BUFFER USING OPENGL
       int width = 1280, height = 720;
       BYTE* pixels = (BYTE *) malloc(sizeof(BYTE));
       glReadPixels(0, 720, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

    //CREATE FFMPEG VARIABLES
       avcodec_register_all();

       AVCodec *codec;
       AVCodecContext *context;
       struct SwsContext *sws;
       AVPacket packet;
       AVFrame *frame;

       codec = avcodec_find_encoder(AV_CODEC_ID_H264);
       context = avcodec_alloc_context3(encoder->codec);
       context->dct_algo = FF_DCT_FASTINT;
       context->bit_rate = 400000;
       context->width = width;
       context->height = height;
       context->time_base.num = 1;
       context->time_base.den = 30;
       context->gop_size = 1;
       context->max_b_frames = 1;
       context->pix_fmt = AV_PIX_FMT_YUV420P;

       avcodec_open2(context, codec, NULL);

    // CONVERT TO YUV AND ENCODE
       int frame_size = avpicture_get_size(AV_PIX_FMT_YUV420P, out_width, out_height);
       encoder->frame_buffer = malloc(frame_size);
       avpicture_fill((AVPicture *) encoder->frame, (uint8_t *) encoder->frame_buffer, AV_PIX_FMT_YUV420P, out_width, out_height);
       sws = sws_getContext(in_width, in_height, AV_PIX_FMT_RGB32, out_width, out_height, AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);

       uint8_t *in_data[1] = {(uint8_t *) pixels};
       int in_linesize[1] = {width * 4};


    // PROGRAM CRASHES HERE


       sws_scale(encoder->sws, in_data, in_linesize, 0, encoder->in_height, encoder->frame->data, encoder->frame->linesize);

       av_free_packet(&amp;packet);
       av_init_packet(&amp;packet);
       int success;

       avcodec_encode_video2(context, &amp;packet, frame, &amp;success);