[soc]: r4610 - in concat: ffmpeg.c.diff libavformat/allformats.c.diff libavformat/concat.c libavformat/concat.h libavformat/m3u.c
Author: gkovacs Date: Sun Jul 5 08:05:04 2009 New Revision: 4610 Log: added ffmpeg conc option to concatenate input files Modified: concat/ffmpeg.c.diff concat/libavformat/allformats.c.diff concat/libavformat/concat.c concat/libavformat/concat.h concat/libavformat/m3u.c Modified: concat/ffmpeg.c.diff ============================================================================== --- concat/ffmpeg.c.diff Sun Jul 5 08:04:45 2009 (r4609) +++ concat/ffmpeg.c.diff Sun Jul 5 08:05:04 2009 (r4610) @@ -1,8 +1,28 @@ diff --git a/ffmpeg.c b/ffmpeg.c -index 22bfed8..ec47a05 100644 +index 22bfed8..d7294c3 100644 --- a/ffmpeg.c +++ b/ffmpeg.c -@@ -1237,7 +1237,8 @@ static void print_report(AVFormatContext **output_files, +@@ -70,6 +70,8 @@ + + #undef exit + ++#include "libavformat/concat.h" ++ + const char program_name[] = "FFmpeg"; + const int program_birth_year = 2000; + +@@ -223,6 +225,10 @@ static unsigned int sws_flags = SWS_BICUBIC; + + static int64_t timer_start; + ++static int concatenate_video_files; ++ ++PlaylistContext *playlist_ctx; ++ + static uint8_t *audio_buf; + static uint8_t *audio_out; + static uint8_t *audio_out2; +@@ -1237,7 +1243,8 @@ static void print_report(AVFormatContext **output_files, /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(AVInputStream *ist, int ist_index, AVOutputStream **ost_table, int nb_ostreams, @@ -12,7 +32,7 @@ index 22bfed8..ec47a05 100644 { AVFormatContext *os; AVOutputStream *ost; -@@ -1250,6 +1251,23 @@ static int output_packet(AVInputStream *ist, int ist_index, +@@ -1250,6 +1257,23 @@ static int output_packet(AVInputStream *ist, int ist_index, AVSubtitle subtitle, *subtitle_to_free; int got_subtitle; AVPacket avpkt; @@ -36,7 +56,7 @@ index 22bfed8..ec47a05 100644 if(ist->next_pts == AV_NOPTS_VALUE) ist->next_pts= ist->pts; -@@ -1292,8 +1310,10 @@ static int output_packet(AVInputStream *ist, int ist_index, +@@ -1292,8 +1316,10 @@ static int output_packet(AVInputStream *ist, int ist_index, endianness as CPU */ ret = avcodec_decode_audio3(ist->st->codec, samples, &data_size, &avpkt); @@ -48,7 +68,7 @@ index 22bfed8..ec47a05 100644 avpkt.data += ret; avpkt.size -= ret; /* Some bug in mpeg audio decoder gives */ -@@ -1314,9 +1334,12 @@ static int output_packet(AVInputStream *ist, int ist_index, +@@ -1314,9 +1340,12 @@ static int output_packet(AVInputStream *ist, int ist_index, ret = avcodec_decode_video2(ist->st->codec, &picture, &got_picture, &avpkt); ist->st->quality= picture.quality; @@ -62,7 +82,7 @@ index 22bfed8..ec47a05 100644 /* no picture yet */ goto discard_packet; } -@@ -1331,8 +1354,10 @@ static int output_packet(AVInputStream *ist, int ist_index, +@@ -1331,8 +1360,10 @@ static int output_packet(AVInputStream *ist, int ist_index, case CODEC_TYPE_SUBTITLE: ret = avcodec_decode_subtitle2(ist->st->codec, &subtitle, &got_subtitle, &avpkt); @@ -74,7 +94,15 @@ index 22bfed8..ec47a05 100644 if (!got_subtitle) { goto discard_packet; } -@@ -2278,8 +2303,9 @@ static int av_encode(AVFormatContext **output_files, +@@ -1644,6 +1675,7 @@ static int av_encode(AVFormatContext **output_files, + uint8_t no_packet[MAX_FILES]={0}; + int no_packet_count=0; + ++ + file_table= av_mallocz(nb_input_files * sizeof(AVInputFile)); + if (!file_table) + goto fail; +@@ -2278,8 +2310,9 @@ static int av_encode(AVFormatContext **output_files, } //fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size); @@ -86,7 +114,7 @@ index 22bfed8..ec47a05 100644 if (verbose >= 0) fprintf(stderr, "Error while decoding stream #%d.%d\n", ist->file_index, ist->index); -@@ -2300,7 +2326,7 @@ static int av_encode(AVFormatContext **output_files, +@@ -2300,7 +2333,7 @@ static int av_encode(AVFormatContext **output_files, for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { @@ -95,3 +123,36 @@ index 22bfed8..ec47a05 100644 } } +@@ -2848,6 +2881,7 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder) + + static void opt_input_file(const char *filename) + { ++ + AVFormatContext *ic; + AVFormatParameters params, *ap = ¶ms; + int err, i, ret, rfps, rfps_base; +@@ -2859,6 +2893,16 @@ static void opt_input_file(const char *filename) + using_stdin |= !strncmp(filename, "pipe:", 5) || + !strcmp(filename, "/dev/stdin"); + ++ if (concatenate_video_files) { // need to specify -conc before -i ++ if (!playlist_ctx) { ++ printf("need to generate playlist ctx\n"); ++ playlist_ctx = ff_playlist_make_context(filename); ++ nb_input_files = 1; ++ input_files[nb_input_files] = ic; ++ } ++ return; ++ } ++ + /* get default parameters from command line */ + ic = avformat_alloc_context(); + +@@ -3874,6 +3918,7 @@ static const OptionDef options[] = { + { "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" }, + { "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" }, + { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)©_initial_nonkeyframes}, "copy initial non-keyframes" }, ++ { "conc", OPT_BOOL, {(void*)&concatenate_video_files}, "concatenate video files", "concatenate" }, + + /* video options */ + { "b", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, Modified: concat/libavformat/allformats.c.diff ============================================================================== --- concat/libavformat/allformats.c.diff Sun Jul 5 08:04:45 2009 (r4609) +++ concat/libavformat/allformats.c.diff Sun Jul 5 08:05:04 2009 (r4610) @@ -1,13 +1,12 @@ diff --git a/libavformat/allformats.c b/libavformat/allformats.c -index ad47631..5773fe6 100644 +index ad47631..08a460b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c -@@ -66,6 +66,8 @@ void av_register_all(void) +@@ -66,6 +66,7 @@ void av_register_all(void) REGISTER_DEMUXER (BFI, bfi); REGISTER_DEMUXER (C93, c93); REGISTER_DEMUXER (CAVSVIDEO, cavsvideo); + REGISTER_DEMUXER (M3U, m3u); -+ REGISTER_DEMUXER (CONCAT, concat); REGISTER_MUXER (CRC, crc); REGISTER_MUXDEMUX (DAUD, daud); REGISTER_MUXDEMUX (DIRAC, dirac); Modified: concat/libavformat/concat.c ============================================================================== --- concat/libavformat/concat.c Sun Jul 5 08:04:45 2009 (r4609) +++ concat/libavformat/concat.c Sun Jul 5 08:05:04 2009 (r4610) @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "concatgen.h" +#include "concat.h" /* The ffmpeg codecs we support, and the IDs they have in the file */ static const AVCodecTag codec_concat_tags[] = { @@ -33,14 +33,37 @@ static int concat_probe(AVProbeData *p) } static int concat_read_header(AVFormatContext *s, - AVFormatParameters *ap) + AVFormatParameters *ap) { // PlaylistD should be constructed externally return 0; } +AVInputFormat *concat_make_demuxer() +{ + AVInputFormat *cdm = av_malloc(sizeof(*cdm)); + cdm->name = "concat"; + cdm->long_name = NULL_IF_CONFIG_SMALL("CONCAT format"); + cdm->priv_data_size = sizeof(PlaylistContext); + cdm->read_probe = concat_probe; + cdm->read_header = concat_read_header; + cdm->read_packet = concatgen_read_packet; + cdm->read_close = concatgen_read_close; + cdm->read_seek = concatgen_read_seek; + cdm->read_timestamp = concatgen_read_timestamp; + cdm->flags = NULL; + cdm->extensions = NULL; + cdm->value = NULL; + cdm->read_play = concatgen_read_play; + cdm->read_pause = concatgen_read_pause; + cdm->codec_tag = codec_concat_tags; + cdm->read_seek2 = concatgen_read_seek; + cdm->metadata_conv = NULL; + cdm->next = NULL; + return cdm; +} -#if CONFIG_CONCAT_DEMUXER +#if 0 AVInputFormat concat_demuxer = { "concat", NULL_IF_CONFIG_SMALL("CONCAT format"), Modified: concat/libavformat/concat.h ============================================================================== --- concat/libavformat/concat.h Sun Jul 5 08:04:45 2009 (r4609) +++ concat/libavformat/concat.h Sun Jul 5 08:05:04 2009 (r4610) @@ -1,2 +1,34 @@ +/* + * Standard playlist/concatenation demuxer + * Copyright (c) 2009 Geza Kovacs + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "concatgen.h" + +#ifndef _CONCAT_H +#define _CONCAT_H + +//int concat_probe(AVProbeData *p); + +//int concat_read_header(AVFormatContext *s, AVFormatParameters *ap); + +AVInputFormat *concat_make_demuxer(); +#endif /* _CONCAT_H */ Modified: concat/libavformat/m3u.c ============================================================================== --- concat/libavformat/m3u.c Sun Jul 5 08:04:45 2009 (r4609) +++ concat/libavformat/m3u.c Sun Jul 5 08:05:04 2009 (r4610) @@ -87,8 +87,8 @@ static int m3u_read_header(AVFormatConte &(ctx->flist), &(ctx->pelist_size), ctx->workingdir); - ctx->pelist = av_malloc(ctx->pelist_size * sizeof(PlayElem*)); - memset(ctx->pelist, 0, ctx->pelist_size * sizeof(PlayElem*)); + ctx->pelist = av_malloc(ctx->pelist_size * sizeof(*(ctx->pelist))); + memset(ctx->pelist, 0, ctx->pelist_size * sizeof(*(ctx->pelist))); s->priv_data = ctx; for (i = 0; i < ctx->pe_curidxs_size; ++i) { ff_playlist_populate_context(ctx, s, i); @@ -100,7 +100,7 @@ static int m3u_read_header(AVFormatConte AVInputFormat m3u_demuxer = { "m3u", NULL_IF_CONFIG_SMALL("M3U format"), - 0, + sizeof(PlaylistContext), m3u_probe, m3u_read_header, concatgen_read_packet, @@ -113,7 +113,7 @@ AVInputFormat m3u_demuxer = { concatgen_read_play, concatgen_read_pause, (const AVCodecTag* const []){codec_m3u_tags, 0}, - NULL, //m3u_read_seek2 + concatgen_read_seek, //m3u_read_seek2 NULL, //metadata_conv NULL, //next };
On Sun, Jul 05, 2009 at 08:05:04AM +0200, gkovacs wrote:
Log: added ffmpeg conc option to concatenate input files
--- concat/libavformat/concat.c Sun Jul 5 08:04:45 2009 (r4609) +++ concat/libavformat/concat.c Sun Jul 5 08:05:04 2009 (r4610) @@ -33,14 +33,37 @@ static int concat_probe(AVProbeData *p)
+AVInputFormat *concat_make_demuxer()
void
+ cdm->name = "concat"; + cdm->long_name = NULL_IF_CONFIG_SMALL("CONCAT format"); + cdm->priv_data_size = sizeof(PlaylistContext); + cdm->read_probe = concat_probe; + cdm->read_header = concat_read_header; + cdm->read_packet = concatgen_read_packet; + cdm->read_close = concatgen_read_close; + cdm->read_seek = concatgen_read_seek; + cdm->read_timestamp = concatgen_read_timestamp; + cdm->flags = NULL; + cdm->extensions = NULL; + cdm->value = NULL; + cdm->read_play = concatgen_read_play; + cdm->read_pause = concatgen_read_pause; + cdm->codec_tag = codec_concat_tags; + cdm->read_seek2 = concatgen_read_seek; + cdm->metadata_conv = NULL; + cdm->next = NULL;
All of this should be vertically aligned.
--- concat/libavformat/concat.h Sun Jul 5 08:04:45 2009 (r4609) +++ concat/libavformat/concat.h Sun Jul 5 08:05:04 2009 (r4610) @@ -1,2 +1,34 @@ + +#include "concatgen.h" + +#ifndef _CONCAT_H +#define _CONCAT_H
nonstandard and illegal identifier Diego
participants (2)
-
Diego Biurrun -
gkovacs