[FFmpeg-soc] [soc]: r4722 - concat/ffmpeg.c.diff

gkovacs subversion at mplayerhq.hu
Thu Jul 16 02:44:06 CEST 2009


Author: gkovacs
Date: Thu Jul 16 02:44:06 2009
New Revision: 4722

Log:
simplified playliste generation when using -conc in ffmpeg

Modified:
   concat/ffmpeg.c.diff

Modified: concat/ffmpeg.c.diff
==============================================================================
--- concat/ffmpeg.c.diff	Thu Jul 16 02:33:14 2009	(r4721)
+++ concat/ffmpeg.c.diff	Thu Jul 16 02:44:06 2009	(r4722)
@@ -1,5 +1,5 @@
 diff --git a/ffmpeg.c b/ffmpeg.c
-index 22bfed8..16b5773 100644
+index 22bfed8..f5b9656 100644
 --- a/ffmpeg.c
 +++ b/ffmpeg.c
 @@ -70,6 +70,8 @@
@@ -93,24 +93,16 @@ index 22bfed8..16b5773 100644
      AVFormatContext *ic;
      AVFormatParameters params, *ap = &params;
      int err, i, ret, rfps, rfps_base;
-@@ -2859,6 +2884,55 @@ static void opt_input_file(const char *filename)
+@@ -2859,6 +2884,43 @@ 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) {
 +            ic = avformat_alloc_context();
 +            av_log(ic, AV_LOG_DEBUG, "Generating playlist ctx\n");
 +            playlist_ctx = ff_playlist_alloc_context();
-+            playlist_ctx->pelist_size = 1;
-+            playlist_ctx->pelist = av_malloc(playlist_ctx->pelist_size * sizeof(*(playlist_ctx->pelist)));
-+            memset(playlist_ctx->pelist, 0, playlist_ctx->pelist_size * sizeof(*(playlist_ctx->pelist)));
-+            playlist_ctx->pelist[playlist_ctx->pelist_size-1] = av_malloc(sizeof(*(playlist_ctx->pelist[playlist_ctx->pelist_size-1])));
-+            memset(playlist_ctx->pelist[playlist_ctx->pelist_size-1], 0, sizeof(*(playlist_ctx->pelist[playlist_ctx->pelist_size-1])));
-+            playlist_ctx->pelist[playlist_ctx->pelist_size-1]->filename =  av_malloc(sizeof(char) * (filenamelen+1));
-+            av_strlcpy(playlist_ctx->pelist[playlist_ctx->pelist_size-1]->filename, filename, filenamelen+1);
-+            av_strlcpy(ic->filename, filename, sizeof(ic->filename));
++            ff_playlist_add_path(playlist_ctx, filename);
 +            ic->nb_streams = 2;
 +            ic->iformat = ff_concat_alloc_demuxer();
 +            ff_playlist_set_context(ic, playlist_ctx);
@@ -121,19 +113,15 @@ index 22bfed8..16b5773 100644
 +        }
 +        else {
 +            av_log(ic, AV_LOG_DEBUG, "Adding file %s to playlist\n", filename);
-+            ++playlist_ctx->pelist_size;
-+            playlist_ctx->pelist = av_realloc(playlist_ctx->pelist, playlist_ctx->pelist_size * sizeof(*(playlist_ctx->pelist)));
-+            playlist_ctx->pelist[playlist_ctx->pelist_size-1] = av_malloc(sizeof(*(playlist_ctx->pelist[playlist_ctx->pelist_size-1])));
-+            memset(playlist_ctx->pelist[playlist_ctx->pelist_size-1], 0, sizeof(*(playlist_ctx->pelist[playlist_ctx->pelist_size-1])));
-+            playlist_ctx->pelist[playlist_ctx->pelist_size-1]->filename =  av_realloc(playlist_ctx->pelist[playlist_ctx->pelist_size-1]->filename, sizeof(char) * (filenamelen+1));
-+            av_strlcpy(playlist_ctx->pelist[playlist_ctx->pelist_size-1]->filename, filename, filenamelen+1);
++            ff_playlist_add_path(playlist_ctx, filename);
++            return;
 +        }
-+        return;
 +    }
-+    // alternative interface for concat - specify -i item1,item2
++
++    // alternative interface for concat - specify -i item1,item2,item3
 +    playlist_ctx = ff_playlist_from_encodedstring(filename, ',');
 +    if (playlist_ctx) {
-+        av_log(ic, AV_LOG_DEBUG, "Generating playlist from encoded string\n");
++        av_log(ic, AV_LOG_DEBUG, "Generating playlist from %s\n", filename);
 +        concatenate_video_files = 1;
 +        ic = avformat_alloc_context();
 +        av_strlcpy(ic->filename, filename, sizeof(ic->filename));
@@ -149,7 +137,7 @@ index 22bfed8..16b5773 100644
      /* get default parameters from command line */
      ic = avformat_alloc_context();
  
-@@ -2925,6 +2999,8 @@ static void opt_input_file(const char *filename)
+@@ -2925,6 +2987,8 @@ static void opt_input_file(const char *filename)
          start_time = 0;
      }
  
@@ -158,7 +146,7 @@ index 22bfed8..16b5773 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 +3076,8 @@ static void opt_input_file(const char *filename)
+@@ -3000,6 +3064,8 @@ static void opt_input_file(const char *filename)
          dump_format(ic, nb_input_files, filename, 0);
  
      nb_input_files++;
@@ -167,7 +155,7 @@ index 22bfed8..16b5773 100644
      file_iformat = NULL;
      file_oformat = NULL;
  
-@@ -3874,6 +3952,7 @@ static const OptionDef options[] = {
+@@ -3874,6 +3940,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*)&copy_initial_nonkeyframes}, "copy initial non-keyframes" },


More information about the FFmpeg-soc mailing list