Recherche avancée

Médias (91)

Autres articles (62)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

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

Sur d’autres sites (11058)

  • How can you combine multiple video files with FFMPEG and merging the audio track as well

    19 décembre 2023, par Codrut

    I'm trying to combine multiple MP4 files in Delphi with the FFMPEG video library. I have the headers unit with all the functions. All videos are MPEG-4, and so is the destination output file.

    


    I found this question on Stack Overflow asking the same question. To combine video files while keeping the audio and video tracks.
I have translated the answers to Delphi, and while the code is executed successfully, the output file is invalid and cannot be played.

    


    Here is my implementation :

    


    var&#xA;  Files: TArray<pansichar>;&#xA;  Output: PAnsiChar;&#xA;&#xA;  I, S: integer;&#xA;&#xA;  i_fmt_ctx: PAVFormatContext;&#xA;  i_video_stream: PAVStream;&#xA;  o_fmt_ctx: PAVFormatContext;&#xA;  o_video_stream: PAVStream;&#xA;&#xA;  P: PPAVStream;&#xA;begin&#xA;  SetLength(Files, 2);&#xA;  Files[0] := PAnsiChar(&#x27;.\Clips\file9.mp4&#x27;);&#xA;  Files[1] := PAnsiChar(&#x27;.\Clips\file10.mp4&#x27;);&#xA;  Output := &#x27;.\Output\out.mp4&#x27;;&#xA;&#xA;  avcodec_register_all();   &#xA;  av_register_all();&#xA;&#xA;  (* should set to NULL so that avformat_open_input() allocate a new one *)&#xA;  i_fmt_ctx := nil;&#xA;&#xA;  if avformat_open_input(@i_fmt_ctx, Files[0], nil, nil) &lt;> 0 then&#xA;    raise Exception.Create(&#x27;Could not open file&#x27;);&#xA;&#xA;  if avformat_find_stream_info(i_fmt_ctx, nil) &lt; 0 then&#xA;    raise Exception.Create(&#x27;Could not find stream info&#x27;);&#xA;                &#xA;  (* Find 1st video stream *)&#xA;  i_video_stream := nil;&#xA;  P := i_fmt_ctx.streams;&#xA;  for i := 0 to i_fmt_ctx.nb_streams-1 do begin&#xA;    if P^.codec.codec_type = AVMEDIA_TYPE_VIDEO then&#xA;      begin&#xA;        i_video_stream := P^;&#xA;        Break;&#xA;      end;&#xA;    Inc(P);&#xA;  end;&#xA;  if i_video_stream = nil then&#xA;    raise Exception.Create(&#x27;Could not find video stream&#x27;);&#xA;&#xA;  avformat_alloc_output_context2(@o_fmt_ctx, nil, nil, Output);&#xA;&#xA;  (*&#xA;  since all input files are supposed to be identical (framerate, dimension, color format, ...)&#xA;  we can safely set output codec values from first input file&#xA;  *)&#xA;  o_video_stream := avformat_new_stream(o_fmt_ctx, nil);&#xA;  &#xA;  var c: PAVCodecContext;&#xA;  c := o_video_stream.codec;&#xA;  c.bit_rate := 400000;&#xA;  c.codec_id := i_video_stream.codec.codec_id;&#xA;  c.codec_type := i_video_stream.codec.codec_type;&#xA;  c.time_base.num := i_video_stream.time_base.num;&#xA;  c.time_base.den := i_video_stream.time_base.den;&#xA;  //fprintf(stderr, "time_base.num = %d time_base.den = %d\n", c->time_base.num, c->time_base.den);&#xA;  c.width := i_video_stream.codec.width;&#xA;  c.height := i_video_stream.codec.height;&#xA;  c.pix_fmt := i_video_stream.codec.pix_fmt;&#xA;  //printf("%d %d %d", c->width, c->height, c->pix_fmt);&#xA;  c.flags := i_video_stream.codec.flags;&#xA;  c.flags := c.flags or CODEC_FLAG_GLOBAL_HEADER;&#xA;  c.me_range := i_video_stream.codec.me_range;&#xA;  c.max_qdiff := i_video_stream.codec.max_qdiff;&#xA;&#xA;  c.qmin := i_video_stream.codec.qmin;&#xA;  c.qmax := i_video_stream.codec.qmax;&#xA;&#xA;  c.qcompress := i_video_stream.codec.qcompress;&#xA;&#xA;  c.extradata := i_video_stream.codec.extradata;&#xA;  c.extradata_size := i_video_stream.codec.extradata_size;&#xA;&#xA;  avio_open(@o_fmt_ctx.pb, Output, AVIO_FLAG_WRITE);&#xA;&#xA;  (* yes! this is redundant *)&#xA;  avformat_close_input(@i_fmt_ctx);&#xA;&#xA;  avformat_write_header(o_fmt_ctx, nil);&#xA;&#xA;  var last_pts: integer; last_pts := 0;&#xA;  var last_dts: integer; last_dts := 0;&#xA;  for i := 1 to High(Files) do begin&#xA;    i_fmt_ctx := nil;&#xA;&#xA;    if avformat_open_input(@i_fmt_ctx, Files[i], nil, nil) &lt;> 0 then&#xA;      raise Exception.Create(&#x27;Could not open input file&#x27;);&#xA;&#xA;    if avformat_find_stream_info(i_fmt_ctx, nil) &lt; 0 then&#xA;      raise Exception.Create(&#x27;Could not find stream info&#x27;);&#xA;&#xA;    av_dump_format(i_fmt_ctx, 0, Files[i], 0);&#xA;    &#xA;    (* we only use first video stream of each input file *)&#xA;    i_video_stream := nil;&#xA;&#xA;    P := i_fmt_ctx.streams;&#xA;    for S := 0 to i_fmt_ctx.nb_streams-1 do&#xA;      begin&#xA;        if (P^.codec.codec_type = AVMEDIA_TYPE_VIDEO) then&#xA;          begin&#xA;            i_video_stream := P^;&#xA;            break;&#xA;          end;&#xA;        &#xA;        Inc(P);&#xA;      end;&#xA;&#xA;    if i_video_stream = nil then&#xA;      raise Exception.Create(&#x27;Could not find video stream&#x27;);&#xA;    &#xA;    var pts, dts: int64;&#xA;    pts := 0; dts := 0;&#xA;    while true do begin&#xA;      var i_pkt: TAVPacket;&#xA;      av_init_packet( @i_pkt );&#xA;      i_pkt.size := 0;&#xA;      i_pkt.data := nil;&#xA;&#xA;      if av_read_frame(i_fmt_ctx, @i_pkt) &lt; 0 then&#xA;        break;&#xA;      (*&#xA;        pts and dts should increase monotonically&#xA;        pts should be >= dts&#xA;      *)&#xA;      i_pkt.flags := i_pkt.flags or AV_PKT_FLAG_KEY;&#xA;      pts := i_pkt.pts;&#xA;      Inc(i_pkt.pts, last_pts);&#xA;      dts := i_pkt.dts;&#xA;      Inc(i_pkt.dts, last_dts);&#xA;      i_pkt.stream_index := 0;&#xA;&#xA;      // Write&#xA;      av_interleaved_write_frame(o_fmt_ctx, @i_pkt);&#xA;    end;&#xA;&#xA;    Inc(last_dts, dts);&#xA;    Inc(last_pts, pts);  &#xA;  &#xA;    avformat_close_input(@i_fmt_ctx)&#xA;  end;&#xA;&#xA;  av_write_trailer(o_fmt_ctx);&#xA;&#xA;  avcodec_close(o_fmt_ctx.streams^.codec);&#xA;  av_freep(&amp;o_fmt_ctx.streams^.codec);&#xA;  av_freep(&amp;o_fmt_ctx.streams);&#xA;&#xA;  avio_close(o_fmt_ctx.pb);&#xA;  av_free(o_fmt_ctx);&#xA;</pansichar>

    &#xA;

    Which is a translation of Михаил Чеботарев's answer.

    &#xA;

    Even if the code worked, I see no handling of the AVMEDIA_TYPE_AUDIO stream, which means this answer is 1/2 of the problem, since It only combines the video stream.

    &#xA;

    Another approach I tried was using the UBitmaps2Video FFMPEG implementation, which is successfully able to merge the video files, but only the video stream, no audio.

    &#xA;

    I tried manually converting the audio stream with the Bass Audio Library. It was able to read the audio and write It in a single WAV file, which then I converted to MP3. Finally muxing the combined video file and the MP3 file with MuxStreams2. Unfortunately, the audio and video do not align properly. I was unable to pinpoint the issue.

    &#xA;

    Currently, the only functional option is using the precompiled FFMPEG Executables and using ShellExecute with the according parameters to combine the videos.&#xA;This more exactly :

    &#xA;

    ffmpeg -f concat -safe 0 -i video-list.txt -c copy output.mp4&#xA;

    &#xA;

    But I would still rather use the FFMPEG headers in Delphi to combine the videos that way, as that gives the option for Progress indicatiors, more control of the playback and the ability to pause the thread at any point.

    &#xA;

    So, why does my implementation to merge video files not work. And what is a good method to include the audio stream as well ?

    &#xA;

  • Crash on ffmpeg avcodec_encode_video in a Console app [closed]

    11 janvier 2024, par Robel Sharma

    I want make an encoder which encode a raw image into h263 format.But after loading and initializing ffmpeg library I got crash on avcodec_encode_video for a demo image.

    &#xA;&#xA;

    int _tmain(int argc, _TCHAR* argv[]) {&#xA;    avcodec_register_all();&#xA;    AVCodec *codec;&#xA;    AVCodecContext *c= NULL;&#xA;    int i, ret, x, y, got_output;&#xA;    FILE *f;&#xA;    AVFrame *frame;&#xA;    AVPacket pkt;&#xA;&#xA;    int out_size, size, outbuf_size;&#xA;&#xA;    AVFrame *picture;&#xA;    uint8_t *outbuf, *picture_buf;&#xA;&#xA;    AVRational rp;   &#xA;&#xA;    rp.den = 1;&#xA;    rp.num = 25;&#xA;    uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;&#xA;    codec = avcodec_find_encoder(CODEC_ID_H263);&#xA;&#xA;    c = avcodec_alloc_context3(codec);&#xA;    picture= avcodec_alloc_frame();&#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->time_base = rp;&#xA;    c->gop_size = 10; /* emit one intra frame every ten frames */&#xA;    c->max_b_frames=1;&#xA;    c->pix_fmt = PIX_FMT_YUV420P;&#xA;    avcodec_open(c, codec);&#xA;&#xA;&#xA;    outbuf_size = 100000;&#xA;    outbuf = (uint8_t*)malloc(outbuf_size);&#xA;    size = c->width * c->height;&#xA;    picture_buf = (uint8_t*)malloc((size * 3) / 2); /* size for YUV 420 */&#xA;&#xA;    picture->data[0] = picture_buf;&#xA;    picture->data[1] = picture->data[0] &#x2B; size;&#xA;    picture->data[2] = picture->data[1] &#x2B; size / 4;&#xA;    picture->linesize[0] = c->width;&#xA;    picture->linesize[1] = c->width / 2;&#xA;    picture->linesize[2] = c->width / 2;&#xA;&#xA;    /* encode 1 second of video */&#xA;    for(i=0;i&lt;25;i&#x2B;&#x2B;) {&#xA;        fflush(stdout);&#xA;        /* prepare a dummy image */&#xA;        /* Y */&#xA;        for(y=0;yheight;y&#x2B;&#x2B;) {&#xA;            for(x=0;xwidth;x&#x2B;&#x2B;) {&#xA;                picture->data[0][y * picture->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;            }&#xA;        }&#xA;        /* Cb and Cr */&#xA;        for(y=0;yheight/2;y&#x2B;&#x2B;) {&#xA;            for(x=0;xwidth/2;x&#x2B;&#x2B;) {&#xA;                picture->data[1][y * picture->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;                picture->data[2][y * picture->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;            }&#xA;        }&#xA;        /* encode the image */&#xA;&#xA;        **Crash is here** --->                 ///////////////////////////////////////////////////&#xA;        out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);&#xA;&#xA;        printf("encoding frame %3d (size=%5d)\n", i, out_size);&#xA;        fwrite(outbuf, 1, out_size, f);&#xA;    }&#xA;    /* get the delayed frames */&#xA;    for(; out_size; i&#x2B;&#x2B;) {&#xA;        fflush(stdout);&#xA;        out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);&#xA;        printf("write frame %3d (size=%5d)\n", i, out_size);&#xA;        fwrite(outbuf, 1, out_size, f);&#xA;    }&#xA;    /* add sequence end code to have a real mpeg file */&#xA;    outbuf[0] = 0x00;&#xA;    outbuf[1] = 0x00;&#xA;    outbuf[2] = 0x01;&#xA;    outbuf[3] = 0xb7;&#xA;    fwrite(outbuf, 1, 4, f);&#xA;    fclose(f);&#xA;    free(picture_buf);&#xA;    free(outbuf);&#xA;&#xA;    avcodec_close(c);&#xA;    av_free(c);&#xA;    av_free(picture);&#xA;    printf("\n");&#xA;    return 0;&#xA;}&#xA;

    &#xA;

  • ffmpeg doesn't generate a ISO/IEC 14496-17 (MPEG-4 text) track when ingesting WebVTT subtitles to produce MPEGTS

    10 avril 2024, par Daniel Andres Pelaez Lopez

    We are trying to create a mpegts with an ISO/IEC 14496-17 (MPEG-4 text) subtitles track, using WebVTT, but seems like ffmpeg creates a ISO 13818-1 PES private data instead.

    &#xA;

    The following is the ffmpeg command :

    &#xA;

    ffmpeg -i subtitle.vtt -c:s mov_text -f mpegts output3GPP.ts

    &#xA;

    This is using the following subtitle.vtt file :

    &#xA;

    WEBVTT&#xA;&#xA;00:00.000 --> 00:01.000&#xA;Subtitle 1&#xA;&#xA;00:01.000 --> 00:02.000&#xA;Subtitle 2&#xA;&#xA;00:02.000 --> 00:03.000&#xA;Subtitle 3&#xA;&#xA;00:03.000 --> 00:04.000&#xA;Subtitle 4&#xA;

    &#xA;

    And the following is the output of the ffprobe for that file :

    &#xA;

    Input #0, mpegts, from &#x27;output3GPP.ts&#x27;:&#xA;  Duration: 00:00:19.00, start: 1.400000, bitrate: 1 kb/s&#xA;  Program 1&#xA;    Metadata:&#xA;      service_name    : Service01&#xA;      service_provider: FFmpeg&#xA;  Stream #0:0[0x100]: Data: bin_data ([6][0][0][0] / 0x0006)&#xA;Unsupported codec with id 98314 for input stream 0&#xA;

    &#xA;

    However, if we generate an mp4, it works, the following is the command :

    &#xA;

    ffmpeg -i subtitle.vtt -c:s mov_text -f mp4 output3GPP.ts

    &#xA;

    And the following is the output of the ffprobe for that file :

    &#xA;

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;output3GPP.ts&#x27;:&#xA;  Metadata:&#xA;    major_brand     : isom&#xA;    minor_version   : 512&#xA;    compatible_brands: isomiso2mp41&#xA;    encoder         : Lavf57.83.100&#xA;  Duration: 00:00:20.00, start: 0.000000, bitrate: 0 kb/s&#xA;  Stream #0:0[0x1](und): Subtitle: mov_text (tx3g / 0x67337874), 0&#xA;kb/s (default)&#xA;    Metadata:&#xA;      handler_name    : SubtitleHandler&#xA;

    &#xA;

    Any reason why both commands behave differently ? is mpegts not supporting ISO/IEC 14496-17 (MPEG-4 text) ?

    &#xA;