diff --git a/core/encode.h b/core/encode.h index fdeb273f34..acdb75c5a3 100644 --- a/core/encode.h +++ b/core/encode.h @@ -14,7 +14,7 @@ void encode_lavc_finish(struct encode_lavc_context *ctx); void encode_lavc_free(struct encode_lavc_context *ctx); void encode_lavc_discontinuity(struct encode_lavc_context *ctx); bool encode_lavc_showhelp(struct MPOpts *opts); -int encode_lavc_getstatus(struct encode_lavc_context *ctx, char *buf, int bufsize, float relative_position, float playback_time); +int encode_lavc_getstatus(struct encode_lavc_context *ctx, char *buf, int bufsize, float relative_position); void encode_lavc_expect_stream(struct encode_lavc_context *ctx, enum AVMediaType mt); void encode_lavc_set_video_fps(struct encode_lavc_context *ctx, float fps); bool encode_lavc_didfail(struct encode_lavc_context *ctx); // check if encoding failed diff --git a/core/encode_lavc.c b/core/encode_lavc.c index e7c52be221..b09ecaa1ac 100644 --- a/core/encode_lavc.c +++ b/core/encode_lavc.c @@ -739,6 +739,9 @@ int encode_lavc_write_frame(struct encode_lavc_context *ctx, AVPacket *packet) break; case AVMEDIA_TYPE_AUDIO: ctx->abytes += packet->size; + ctx->audioseconds += packet->duration + * (double)ctx->avc->streams[packet->stream_index]->time_base.num + / (double)ctx->avc->streams[packet->stream_index]->time_base.den; break; default: break; @@ -1003,7 +1006,7 @@ double encode_lavc_getoffset(struct encode_lavc_context *ctx, AVStream *stream) int encode_lavc_getstatus(struct encode_lavc_context *ctx, char *buf, int bufsize, - float relative_position, float playback_time) + float relative_position) { double now = mp_time_sec(); float minutes, megabytes, fps, x; @@ -1015,14 +1018,17 @@ int encode_lavc_getstatus(struct encode_lavc_context *ctx, minutes = (now - ctx->t0) / 60.0 * (1 - f) / f; megabytes = ctx->avc->pb ? (avio_size(ctx->avc->pb) / 1048576.0 / f) : 0; - fps = ctx->frames / ((now - ctx->t0)); - x = playback_time / ((now - ctx->t0)); + fps = ctx->frames / (now - ctx->t0); + x = ctx->audioseconds / (now - ctx->t0); if (ctx->frames) - snprintf(buf, bufsize, "{%.1f%% %.1fmin %.1ffps %.1fMB}", - relative_position * 100.0, minutes, fps, megabytes); + snprintf(buf, bufsize, "{%.1fmin %.1ffps %.1fMB}", + minutes, fps, megabytes); + else if (ctx->audioseconds) + snprintf(buf, bufsize, "{%.1fmin %.2fx %.1fMB}", + minutes, x, megabytes); else - snprintf(buf, bufsize, "{%.1f%% %.1fmin %.2fx %.1fMB}", - relative_position * 100.0, minutes, x, megabytes); + snprintf(buf, bufsize, "{%.1fmin %.1fMB}", + minutes, megabytes); buf[bufsize - 1] = 0; return 0; } diff --git a/core/encode_lavc.h b/core/encode_lavc.h index 7e53ae6a1d..f47825e1d7 100644 --- a/core/encode_lavc.h +++ b/core/encode_lavc.h @@ -63,6 +63,7 @@ struct encode_lavc_context { struct stream *twopass_bytebuffer_v; double t0; unsigned int frames; + double audioseconds; bool expect_video; bool expect_audio; diff --git a/core/mplayer.c b/core/mplayer.c index 86260a0598..1a99c03644 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -1229,19 +1229,11 @@ static void print_status(struct MPContext *mpctx) } #ifdef CONFIG_ENCODING - double startpos = rel_time_to_abs(mpctx, opts->play_start, 0); - double endpos = rel_time_to_abs(mpctx, opts->play_end, -1); - float position = (get_current_time(mpctx) - startpos) / - (get_time_length(mpctx) - startpos); - if (endpos != -1) - position = max(position, (get_current_time(mpctx) - startpos) - / (endpos - startpos)); - if (opts->play_frames > 0) - position = max(position, - 1.0 - mpctx->max_frames / (double) opts->play_frames); + double position = get_current_pos_ratio(mpctx); + // TODO rescale this to take --start, --end, --length, --frames into account char lavcbuf[80]; if (encode_lavc_getstatus(mpctx->encode_lavc_ctx, lavcbuf, sizeof(lavcbuf), - position, get_current_time(mpctx) - startpos) >= 0) + position) >= 0) { // encoding stats saddf(&line, " %s", lavcbuf);