rework android-rmt display, add a few buttons
[goodguy/history.git] / cinelerra-5.0 / cinelerra / ffmpeg.C
index aa7a9f1f396827759404a688d94bf815c1e23d7d..c0914420ef612a6686557b4c4ed49424cf699c47 100644 (file)
@@ -460,7 +460,7 @@ int FFStream::seek(int64_t no, double rate)
                if( no-n < 30*rate ) {
                        if( n < 0 ) n = 0;
                        pos = n;
-                       plmt = marks[i].pos;
+                       if( ++i < marks.size() ) plmt = marks[i].pos;
                        npkts = MAX_RETRY;
                }
        }
@@ -475,9 +475,8 @@ int FFStream::seek(int64_t no, double rate)
                seeked = 1;  st_eof(0);
 // read up to retry packets, limited to npkts in stream, and not past pkt.pos plmt
                for( int retry=MAX_RETRY; ret>=0 && --retry>=0; ) {
-                       if( read_packet() <= 0 || ( plmt >= 0 && ipkt->pos > plmt ) ) {
-                               ret = -1;  break;
-                       }
+                       if( read_packet() <= 0 ) { ret = -1;  break; }
+                       if( plmt >= 0 && ipkt->pos >= plmt ) break;
                        if( ipkt->stream_index != st->index ) continue;
                        if( --npkts <= 0 ) break;
                        if( (pkt_ts=ipkt->dts) == AV_NOPTS_VALUE &&
@@ -1566,7 +1565,6 @@ int FFMPEG::init_encoder(const char *filename)
                load_options("encode.opts", opts);
        }
        ff_unlock();
-       start_muxer();
        return ret;
 }
 
@@ -1655,7 +1653,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                        ctx->channel_layout =  av_get_default_channel_layout(ctx->channels);
                        ctx->sample_rate = check_sample_rate(codec, asset->sample_rate);
                        if( !ctx->sample_rate ) {
-                               eprintf("FFMPEG::open_audio_encode:"
+                               eprintf("FFMPEG::open_encoder:"
                                        " check_sample_rate failed %s\n", filename);
                                ret = 1;
                                break;
@@ -1717,7 +1715,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                        ctx->pix_fmt = codec->pix_fmts ? codec->pix_fmts[0] : AV_PIX_FMT_YUV420P;
                        AVRational frame_rate = check_frame_rate(codec, vid->frame_rate);
                        if( !frame_rate.num || !frame_rate.den ) {
-                               eprintf("FFMPEG::open_audio_encode:"
+                               eprintf("FFMPEG::open_encoder:"
                                        " check_frame_rate failed %s\n", filename);
                                ret = 1;
                                break;
@@ -1752,6 +1750,8 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
        }
 
        ff_unlock();
+       if( !ret )
+               start_muxer();
        av_dict_free(&sopts);
        return ret;
 }