
Recherche avancée
Médias (91)
-
Les Miserables
9 décembre 2019, par
Mis à jour : Décembre 2019
Langue : français
Type : Textuel
-
VideoHandle
8 novembre 2019, par
Mis à jour : Novembre 2019
Langue : français
Type : Video
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
-
Un test - mauritanie
3 avril 2014, par
Mis à jour : Avril 2014
Langue : français
Type : Textuel
-
Pourquoi Obama lit il mes mails ?
4 février 2014, par
Mis à jour : Février 2014
Langue : français
-
IMG 0222
6 octobre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Image
Autres articles (62)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 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, parMediaSPIP 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 2013Jolie 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 CodrutI'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
 Files: TArray<pansichar>;
 Output: PAnsiChar;

 I, S: integer;

 i_fmt_ctx: PAVFormatContext;
 i_video_stream: PAVStream;
 o_fmt_ctx: PAVFormatContext;
 o_video_stream: PAVStream;

 P: PPAVStream;
begin
 SetLength(Files, 2);
 Files[0] := PAnsiChar('.\Clips\file9.mp4');
 Files[1] := PAnsiChar('.\Clips\file10.mp4');
 Output := '.\Output\out.mp4';

 avcodec_register_all(); 
 av_register_all();

 (* should set to NULL so that avformat_open_input() allocate a new one *)
 i_fmt_ctx := nil;

 if avformat_open_input(@i_fmt_ctx, Files[0], nil, nil) <> 0 then
 raise Exception.Create('Could not open file');

 if avformat_find_stream_info(i_fmt_ctx, nil) < 0 then
 raise Exception.Create('Could not find stream info');
 
 (* Find 1st video stream *)
 i_video_stream := nil;
 P := i_fmt_ctx.streams;
 for i := 0 to i_fmt_ctx.nb_streams-1 do begin
 if P^.codec.codec_type = AVMEDIA_TYPE_VIDEO then
 begin
 i_video_stream := P^;
 Break;
 end;
 Inc(P);
 end;
 if i_video_stream = nil then
 raise Exception.Create('Could not find video stream');

 avformat_alloc_output_context2(@o_fmt_ctx, nil, nil, Output);

 (*
 since all input files are supposed to be identical (framerate, dimension, color format, ...)
 we can safely set output codec values from first input file
 *)
 o_video_stream := avformat_new_stream(o_fmt_ctx, nil);
 
 var c: PAVCodecContext;
 c := o_video_stream.codec;
 c.bit_rate := 400000;
 c.codec_id := i_video_stream.codec.codec_id;
 c.codec_type := i_video_stream.codec.codec_type;
 c.time_base.num := i_video_stream.time_base.num;
 c.time_base.den := i_video_stream.time_base.den;
 //fprintf(stderr, "time_base.num = %d time_base.den = %d\n", c->time_base.num, c->time_base.den);
 c.width := i_video_stream.codec.width;
 c.height := i_video_stream.codec.height;
 c.pix_fmt := i_video_stream.codec.pix_fmt;
 //printf("%d %d %d", c->width, c->height, c->pix_fmt);
 c.flags := i_video_stream.codec.flags;
 c.flags := c.flags or CODEC_FLAG_GLOBAL_HEADER;
 c.me_range := i_video_stream.codec.me_range;
 c.max_qdiff := i_video_stream.codec.max_qdiff;

 c.qmin := i_video_stream.codec.qmin;
 c.qmax := i_video_stream.codec.qmax;

 c.qcompress := i_video_stream.codec.qcompress;

 c.extradata := i_video_stream.codec.extradata;
 c.extradata_size := i_video_stream.codec.extradata_size;

 avio_open(@o_fmt_ctx.pb, Output, AVIO_FLAG_WRITE);

 (* yes! this is redundant *)
 avformat_close_input(@i_fmt_ctx);

 avformat_write_header(o_fmt_ctx, nil);

 var last_pts: integer; last_pts := 0;
 var last_dts: integer; last_dts := 0;
 for i := 1 to High(Files) do begin
 i_fmt_ctx := nil;

 if avformat_open_input(@i_fmt_ctx, Files[i], nil, nil) <> 0 then
 raise Exception.Create('Could not open input file');

 if avformat_find_stream_info(i_fmt_ctx, nil) < 0 then
 raise Exception.Create('Could not find stream info');

 av_dump_format(i_fmt_ctx, 0, Files[i], 0);
 
 (* we only use first video stream of each input file *)
 i_video_stream := nil;

 P := i_fmt_ctx.streams;
 for S := 0 to i_fmt_ctx.nb_streams-1 do
 begin
 if (P^.codec.codec_type = AVMEDIA_TYPE_VIDEO) then
 begin
 i_video_stream := P^;
 break;
 end;
 
 Inc(P);
 end;

 if i_video_stream = nil then
 raise Exception.Create('Could not find video stream');
 
 var pts, dts: int64;
 pts := 0; dts := 0;
 while true do begin
 var i_pkt: TAVPacket;
 av_init_packet( @i_pkt );
 i_pkt.size := 0;
 i_pkt.data := nil;

 if av_read_frame(i_fmt_ctx, @i_pkt) < 0 then
 break;
 (*
 pts and dts should increase monotonically
 pts should be >= dts
 *)
 i_pkt.flags := i_pkt.flags or AV_PKT_FLAG_KEY;
 pts := i_pkt.pts;
 Inc(i_pkt.pts, last_pts);
 dts := i_pkt.dts;
 Inc(i_pkt.dts, last_dts);
 i_pkt.stream_index := 0;

 // Write
 av_interleaved_write_frame(o_fmt_ctx, @i_pkt);
 end;

 Inc(last_dts, dts);
 Inc(last_pts, pts); 
 
 avformat_close_input(@i_fmt_ctx)
 end;

 av_write_trailer(o_fmt_ctx);

 avcodec_close(o_fmt_ctx.streams^.codec);
 av_freep(&o_fmt_ctx.streams^.codec);
 av_freep(&o_fmt_ctx.streams);

 avio_close(o_fmt_ctx.pb);
 av_free(o_fmt_ctx);
</pansichar>


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

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.

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.


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.

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


ffmpeg -f concat -safe 0 -i video-list.txt -c copy output.mp4



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.


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


-
Crash on ffmpeg avcodec_encode_video in a Console app [closed]
11 janvier 2024, par Robel SharmaI 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.



int _tmain(int argc, _TCHAR* argv[]) {
 avcodec_register_all();
 AVCodec *codec;
 AVCodecContext *c= NULL;
 int i, ret, x, y, got_output;
 FILE *f;
 AVFrame *frame;
 AVPacket pkt;

 int out_size, size, outbuf_size;

 AVFrame *picture;
 uint8_t *outbuf, *picture_buf;

 AVRational rp; 

 rp.den = 1;
 rp.num = 25;
 uint8_t endcode[] = { 0, 0, 1, 0xb7 };

 codec = avcodec_find_encoder(CODEC_ID_H263);

 c = avcodec_alloc_context3(codec);
 picture= avcodec_alloc_frame();
 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->time_base = rp;
 c->gop_size = 10; /* emit one intra frame every ten frames */
 c->max_b_frames=1;
 c->pix_fmt = PIX_FMT_YUV420P;
 avcodec_open(c, codec);


 outbuf_size = 100000;
 outbuf = (uint8_t*)malloc(outbuf_size);
 size = c->width * c->height;
 picture_buf = (uint8_t*)malloc((size * 3) / 2); /* size for YUV 420 */

 picture->data[0] = picture_buf;
 picture->data[1] = picture->data[0] + size;
 picture->data[2] = picture->data[1] + size / 4;
 picture->linesize[0] = c->width;
 picture->linesize[1] = c->width / 2;
 picture->linesize[2] = c->width / 2;

 /* encode 1 second of video */
 for(i=0;i<25;i++) {
 fflush(stdout);
 /* prepare a dummy image */
 /* Y */
 for(y=0;yheight;y++) {
 for(x=0;xwidth;x++) {
 picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3;
 }
 }
 /* Cb and Cr */
 for(y=0;yheight/2;y++) {
 for(x=0;xwidth/2;x++) {
 picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;
 picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;
 }
 }
 /* encode the image */

 **Crash is here** ---> ///////////////////////////////////////////////////
 out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);

 printf("encoding frame %3d (size=%5d)\n", i, out_size);
 fwrite(outbuf, 1, out_size, f);
 }
 /* get the delayed frames */
 for(; out_size; i++) {
 fflush(stdout);
 out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
 printf("write frame %3d (size=%5d)\n", i, out_size);
 fwrite(outbuf, 1, out_size, f);
 }
 /* add sequence end code to have a real mpeg file */
 outbuf[0] = 0x00;
 outbuf[1] = 0x00;
 outbuf[2] = 0x01;
 outbuf[3] = 0xb7;
 fwrite(outbuf, 1, 4, f);
 fclose(f);
 free(picture_buf);
 free(outbuf);

 avcodec_close(c);
 av_free(c);
 av_free(picture);
 printf("\n");
 return 0;
}



-
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 LopezWe 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.


The following is the ffmpeg command :


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


This is using the following subtitle.vtt file :


WEBVTT

00:00.000 --> 00:01.000
Subtitle 1

00:01.000 --> 00:02.000
Subtitle 2

00:02.000 --> 00:03.000
Subtitle 3

00:03.000 --> 00:04.000
Subtitle 4



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


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



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


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


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


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



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