rework camera/projector drag outline
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / ffmpeg.C
index 65e0c780e793cfaa82b04cd3860cafbe8cb98066..0c351e5a038375cd09e9579b178ac8390811b4fe 100644 (file)
@@ -48,6 +48,9 @@
 #define AUDIO_REFILL_THRESH 0x1000
 #define AUDIO_MIN_FRAME_SZ 128
 
+#define FF_ESTM_TIMES 0x0001
+#define FF_BAD_TIMES  0x0002
+
 Mutex FFMPEG::fflock("FFMPEG::fflock");
 
 static void ff_err(int ret, const char *fmt, ...)
@@ -481,7 +484,7 @@ int FFStream::write_packet(FFPacket &pkt)
 int FFStream::encode_frame(AVFrame *frame)
 {
        int pkts = 0, ret = 0;
-       for( int retry=100; --retry>=0; ) {
+       for( int retry=MAX_RETRY; --retry>=0; ) {
                if( frame || !pkts )
                        ret = avcodec_send_frame(avctx, frame);
                if( !ret && frame ) return pkts;
@@ -1325,6 +1328,7 @@ FFMPEG::FFMPEG(FileBase *file_base)
        opt_duration = -1;
        opt_video_filter = 0;
        opt_audio_filter = 0;
+       fflags = 0;
        char option_path[BCTEXTLEN];
        set_option_path(option_path, "%s", "ffmpeg.opts");
        read_options(option_path, opts);
@@ -1944,8 +1948,10 @@ int FFMPEG::init_decoder(const char *filename)
        ff_lock("FFMPEG::init_decoder");
        av_register_all();
        char file_opts[BCTEXTLEN];
-       char *bp = strrchr(strcpy(file_opts, filename), '/');
-       char *sp = strrchr(!bp ? file_opts : bp, '.');
+       strcpy(file_opts, filename);
+       char *bp = strrchr(file_opts, '/');
+       if( !bp ) bp = file_opts;
+       char *sp = strrchr(bp, '.');
        if( !sp ) sp = bp + strlen(bp);
        FILE *fp = 0;
        AVInputFormat *ifmt = 0;
@@ -1999,10 +2005,10 @@ int FFMPEG::open_decoder()
                        estimated = 1;
                }
        }
-       static int notified = 0;
-       if( !notified && estimated ) {
-               notified = 1;
-               printf("FFMPEG::open_decoder: some stream times estimated\n");
+       if( estimated && !(fflags & FF_ESTM_TIMES) ) {
+               fflags |= FF_ESTM_TIMES;
+               printf("FFMPEG::open_decoder: some stream times estimated: %s\n",
+                       fmt_ctx->url);
        }
 
        ff_lock("FFMPEG::open_decoder");
@@ -2058,8 +2064,11 @@ int FFMPEG::open_decoder()
                default: break;
                }
        }
-       if( bad_time )
-               printf("FFMPEG::open_decoder: some stream have bad times\n");
+       if( bad_time && !(fflags & FF_BAD_TIMES) ) {
+               fflags |= FF_BAD_TIMES;
+               printf("FFMPEG::open_decoder: some stream have bad times: %s\n",
+                       fmt_ctx->url);
+       }
        ff_unlock();
        return ret < 0 ? -1 : 0;
 }