[FFmpeg-soc] [soc]: r4717 - in concat: ffmpeg.c.diff libavformat/playlist.c libavformat/playlist.h upstreamrev
gkovacs
subversion at mplayerhq.hu
Thu Jul 16 01:20:27 CEST 2009
Author: gkovacs
Date: Thu Jul 16 01:20:26 2009
New Revision: 4717
Log:
added simpler interface to specify files in ffmpeg, as suggested by Michael Niedermayer
Modified:
concat/ffmpeg.c.diff
concat/libavformat/playlist.c
concat/libavformat/playlist.h
concat/upstreamrev
Modified: concat/ffmpeg.c.diff
==============================================================================
--- concat/ffmpeg.c.diff Wed Jul 15 18:10:17 2009 (r4716)
+++ concat/ffmpeg.c.diff Thu Jul 16 01:20:26 2009 (r4717)
@@ -1,5 +1,5 @@
diff --git a/ffmpeg.c b/ffmpeg.c
-index 22bfed8..5f8b256 100644
+index 22bfed8..16b5773 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -70,6 +70,8 @@
@@ -93,11 +93,10 @@ index 22bfed8..5f8b256 100644
AVFormatContext *ic;
AVFormatParameters params, *ap = ¶ms;
int err, i, ret, rfps, rfps_base;
-@@ -2859,6 +2884,42 @@ static void opt_input_file(const char *filename)
+@@ -2859,6 +2884,55 @@ 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
+ int filenamelen = strlen(filename);
+ if (!playlist_ctx) {
@@ -131,12 +130,26 @@ index 22bfed8..5f8b256 100644
+ }
+ return;
+ }
-+
++ // alternative interface for concat - specify -i item1,item2
++ playlist_ctx = ff_playlist_from_encodedstring(filename, ',');
++ if (playlist_ctx) {
++ av_log(ic, AV_LOG_DEBUG, "Generating playlist from encoded string\n");
++ concatenate_video_files = 1;
++ ic = avformat_alloc_context();
++ av_strlcpy(ic->filename, filename, sizeof(ic->filename));
++ ic->nb_streams = 2;
++ ic->iformat = ff_concat_alloc_demuxer();
++ ff_playlist_set_context(ic, playlist_ctx);
++ ff_playlist_populate_context(ic);
++ nb_input_files = 1;
++ input_files[0] = ic;
++ goto configcodecs;
++ }
+
/* get default parameters from command line */
ic = avformat_alloc_context();
-@@ -2925,6 +2986,8 @@ static void opt_input_file(const char *filename)
+@@ -2925,6 +2999,8 @@ static void opt_input_file(const char *filename)
start_time = 0;
}
@@ -145,7 +158,7 @@ index 22bfed8..5f8b256 100644
/* update the current parameters so that they match the one of the input stream */
for(i=0;i<ic->nb_streams;i++) {
AVCodecContext *enc = ic->streams[i]->codec;
-@@ -3000,6 +3063,8 @@ static void opt_input_file(const char *filename)
+@@ -3000,6 +3076,8 @@ static void opt_input_file(const char *filename)
dump_format(ic, nb_input_files, filename, 0);
nb_input_files++;
@@ -154,7 +167,7 @@ index 22bfed8..5f8b256 100644
file_iformat = NULL;
file_oformat = NULL;
-@@ -3874,6 +3939,7 @@ static const OptionDef options[] = {
+@@ -3874,6 +3952,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" },
Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c Wed Jul 15 18:10:17 2009 (r4716)
+++ concat/libavformat/playlist.c Thu Jul 16 01:20:26 2009 (r4717)
@@ -112,6 +112,67 @@ AVStream *ff_playlist_get_stream(Playlis
return NULL;
}
+void ff_playlist_split_encodedstring(char *s, char sep, char ***flist_ptr, int *len_ptr)
+{
+ char c, *ts, **flist;
+ int i, len, buflen, *sepidx;
+ buflen = sepidx = len = 0;
+ sepidx = av_fast_realloc(sepidx, &buflen, ++len);
+ sepidx[0] = 0;
+ ts = s;
+ while ((c = *ts++) != 0) {
+ if (c == sep) {
+ sepidx[len] = ts-s;
+ sepidx = av_fast_realloc(sepidx, &buflen, ++len);
+ }
+ }
+ sepidx[len] = ts-s;
+ ts = s;
+ *len_ptr = len;
+ *flist_ptr = flist = av_malloc(sizeof(*flist) * (len+1));
+ flist[len] = 0;
+ for (i = 0; i < len; ++i) {
+ flist[i] = av_malloc(sepidx[i+1]-sepidx[i]);
+ av_strlcpy(flist[i], ts+sepidx[i], sepidx[i+1]-sepidx[i]);
+ }
+ av_free(sepidx);
+}
+
+PlaylistContext *ff_playlist_from_encodedstring(char *s, char sep)
+{
+ PlaylistContext *ctx;
+ char **flist;
+ int i, len;
+ char workingdir[1024];
+ getcwd(workingdir, 1024);
+ workingdir[1023] = 0;
+ ff_playlist_split_encodedstring(s, sep, &flist, &len);
+ if (len <= 1) {
+ for (i = 0; i < len; ++i)
+ av_free(flist[i]);
+ av_free(flist);
+ return NULL;
+ }
+ ctx = ff_playlist_alloc_context();
+ ff_playlist_relative_paths(flist, workingdir);
+ ff_playlist_add_stringlist(ctx, flist, len);
+ return ctx;
+}
+
+void ff_playlist_add_stringlist(PlaylistContext *ctx, char **flist, int len)
+{
+ int i;
+ ctx->pelist_size = len;
+ ctx->pelist = av_malloc(ctx->pelist_size * sizeof(*(ctx->pelist)));
+ memset(ctx->pelist, 0, ctx->pelist_size * sizeof(*(ctx->pelist)));
+ for (i = 0; i < ctx->pelist_size; ++i) {
+ ctx->pelist[i] = av_malloc(sizeof(*(ctx->pelist[i])));
+ memset(ctx->pelist[i], 0, sizeof(*(ctx->pelist[i])));
+ ctx->pelist[i]->filename = flist[i];
+ }
+ ctx->pe_curidx = 0;
+}
+
// converts list of mixed absolute and relative paths into all absolute paths
void ff_playlist_relative_paths(char **flist, const char *workingdir)
{
Modified: concat/libavformat/playlist.h
==============================================================================
--- concat/libavformat/playlist.h Wed Jul 15 18:10:17 2009 (r4716)
+++ concat/libavformat/playlist.h Thu Jul 16 01:20:26 2009 (r4717)
@@ -98,4 +98,10 @@ void ff_playlist_set_context(AVFormatCon
*/
AVStream *ff_playlist_get_stream(PlaylistContext *ctx, int pe_idx, int stream_index);
+void ff_playlist_split_encodedstring(char *s, char sep, char ***flist_ptr, int *len_ptr);
+
+PlaylistContext *ff_playlist_from_encodedstring(char *s, char sep);
+
+void ff_playlist_add_stringlist(PlaylistContext *ctx, char **flist, int len);
+
#endif /* AVFORMAT_PLAYLIST_H */
Modified: concat/upstreamrev
==============================================================================
--- concat/upstreamrev Wed Jul 15 18:10:17 2009 (r4716)
+++ concat/upstreamrev Thu Jul 16 01:20:26 2009 (r4717)
@@ -1,12 +1,12 @@
ffmpeg:
-svn: 19419
-git: faa53067a35c09644d3915edbbc85bc0f6675e30
+svn: 19424
+git: 806496708b491d2f825309f6e3b4f6c6f7c7d085
committer: diego
-commitdate: Sun, 12 Jul 2009 22:31:05 +0000
-commitlog: Make (de)muxers for format variants select the main format (de)muxer. It makes little sense to enable the variant without the main format.
+commitdate: Mon, 13 Jul 2009 17:16:36 +0000
+commitlog: Only #define lseek to _lseeki64 on MinGW, not MinGW CE. This fixes compilation on WinCE, which does not support _lseeki64. patch by Ismail Dönmez, ismail namtrac org
libswscale:
-svn: 19419
+svn: 19424
git: f3ae90a5d9f9e01b326c031803b977be3d5369c0
committer: ramiro
commitdate: Thu, 9 Jul 2009 02:27:39 +0000
More information about the FFmpeg-soc
mailing list