[FFmpeg-user] Feature request: show the "speed" of audio only conversions
Moritz Barsnick
barsnick at gmx.net
Thu Sep 3 12:56:11 CEST 2015
Hi Roger, users,
On Tue, Jun 30, 2015 at 15:49:34 -0600, Roger Pack wrote:
> On 6/11/15, Moritz Barsnick <barsnick at gmx.net> wrote:
> > On Thu, Jun 11, 2015 at 10:31:54 -0600, Roger Pack wrote:
> > Which is something like a "5.3x" display, such as lame shows it (I
> > think).
> >
> > I think that is just as valid a request for video. I do see the fps,
> > but I need to do quick head-math and know the fps of the source.
> >
> > That said, there may be some ambiguity with regards to which base to
> > take: Input PTS, output PTS; what about jumps in PTS? Can this work
> > when copying? I'm thinking out loud too much. ;)
I have done some thinking, and I am convinced I need this feature.
> It would be a huge win to get an "estimated time to completion" as well :)
This is too tricky in this part of the code. I think the muxers and
demuxers handle durations, and it becomes more complicated if VBR, trim
filters, enable expressions and other complicated stuff are involved.
So while an ETA (or a progress in percent) would be nice, I can't wrap
my head around it.
That said, here's a not-so-quick shot at a speed display (attached). I
made some other approaches with some other calculations, but it never
made enough sense.
I used "%.3g" for the printf format, as I like the number of relevant
digits this way. I haven't looked at the portability of %g across
supported compilers though.
I haven't bothered writing any info into the "progress information"
(&buf_script) at this point. I probably should for consistency.
Disclaimer: I don't know if we should even try to get this upstream.
I'm just playing with the possibilities. ;-) Just for you and me,
Roger.
[That function could really really really make use of a macro for
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ...);
14 occurrences!
;-) ]
Moritz
-------------- next part --------------
--- ffmpeg-build-2015-08-31/ffmpeg.c 2015-08-29 19:20:04.000000000 +0200
+++ ffmpeg-build-2015-08-31-speedrate/ffmpeg.c 2015-09-03 10:57:01.000000000 +0200
@@ -1536,10 +1536,12 @@
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate;
+ double speed;
int64_t pts = INT64_MIN;
static int64_t last_time = -1;
static int qp_histogram[52];
int hours, mins, secs, us;
+ float t;
if (!print_stats && !is_last_report && !progress_avio)
return;
@@ -1554,6 +1556,8 @@
last_time = cur_time;
}
+ t = (cur_time-timer_start) / 1000000.0;
+
oc = output_files[0]->ctx;
@@ -1577,7 +1581,7 @@
ost->file_index, ost->index, q);
}
if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
- float fps, t = (cur_time-timer_start) / 1000000.0;
+ float fps;
frame_number = ost->frame_number;
fps = t > 1 ? frame_number / t : 0;
@@ -1645,6 +1649,7 @@
mins %= 60;
bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
+ speed = t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
if (total_size < 0) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=N/A time=");
@@ -1676,6 +1681,12 @@
av_bprintf(&buf_script, "dup_frames=%d\n", nb_frames_dup);
av_bprintf(&buf_script, "drop_frames=%d\n", nb_frames_drop);
+ if (speed < 0) {
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=N/A");
+ } else {
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=%.3gx", speed);
+ }
+
if (print_stats || is_last_report) {
const char end = is_last_report ? '\n' : '\r';
if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
More information about the ffmpeg-user
mailing list