Author Topic: Keep encoding window on screen once enc. done?  (Read 272 times)

hiro

  • Jr. Member
  • **
  • Posts: 52
Keep encoding window on screen once enc. done?
« on: July 26, 2019, 07:49:15 PM »
Hi,

Is there a way to keep the encoding (small) window on screen, once encoding finishes — instead of being replaced with "Done (etc.)"?

I often need to know how long it takes or took, to process a video.

Of course, I tried to open "admlog.txt", but its contents is confusing, + I don't even know if it contains the encoding duration simple info.,

timing "by hand" being rather tedious...


[ Was this asked & answered before? If so, I couldn't find it. ]


Thanx


.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3186
Re: Keep encoding window on screen once enc. done?
« Reply #1 on: July 26, 2019, 08:47:38 PM »
Is there a way to keep the encoding (small) window on screen, once encoding finishes — instead of being replaced with "Done (etc.)"?

This were doable code-wise, but it is not implemented and probably not really needed because...

Quote
Of course, I tried to open "admlog.txt", but its contents is confusing, + I don't even know if it contains the encoding duration simple info.

...this is currently the way to do it. There is nothing confusing in it, just subtract the time printed at the line starting with " [initUI]" after " [saveLoop]" from the time printed at " [close]". The most precise timing one could imagine  :)

Code: [Select]
[FF] Saving
 [saveLoop] 20:26:42-447  avg fps=30000
 [initUI] 20:26:42-447  Muxer, creating UI, video duration is 00:02:30,436

...

 [saveLoop] 20:27:04-305  [FF] Found 0 missing PTS / 4508 total frames
 [close] 20:27:04-305  [Mkv] Closing

20:27:04.305 - 20:26:42.447 = 21.858 seconds

hiro

  • Jr. Member
  • **
  • Posts: 52
Re: Keep encoding window on screen once enc. done?
« Reply #2 on: July 27, 2019, 08:19:43 PM »
Thanx very much for the helpful hint.


OK, my 64-bit Avidemux 2.7.1 (on Win. 10) "admlog" contains no "[close]" *

* Weirdo or normal, I don't know...

So, instead, I'm using "[saveLoop] XX:XX:XX-XXX [FF] Found"

      But at least, it does  :) contain an '"[initUI]" after "[saveLoop]"'.


& "Other story": now, trying to AUTO extract the two timestamps and subtract (using an "AutoIt" macro) from one another is giving me hell, as I'm unable to program anything — but "working"... half way, so far.


.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3186
Re: Keep encoding window on screen once enc. done?
« Reply #3 on: July 28, 2019, 11:06:46 AM »
OK, my 64-bit Avidemux 2.7.1 (on Win. 10)

Astounded question: why THAT old?

Quote
& "Other story": now, trying to AUTO extract the two timestamps and subtract (using an "AutoIt" macro) from one another is giving me hell, as I'm unable to program anything — but "working"... half way, so far.

This could become a nifty exercise  :)

Code: [Select]
#include <cstdio>
#include <string>

int main(int argc, char *argv[]);
int validateString(std::string *s);
int check(int hours, int minutes, int seconds, int milliseconds);

int main(int argc, char *argv[])
{
    if(argc != 3)
    {
        printf("Error: need two timestamps as arguments.\n");
        return 1;
    }

    std::string timeStart = argv[1];
    std::string timeEnd = argv[2];

    if(validateString(&timeStart))
    {
        printf("Error: malformed start time string.\n");
        return 1;
    }
    if(validateString(&timeEnd))
    {
        printf("Error: malformed end time string.\n");
        return 1;
    }

    int hh1,mm1,ss1,ms1;
    if(4 != std::sscanf(timeStart.c_str(),"%02d:%02d:%02d-%03d",&hh1,&mm1,&ss1,&ms1))
    {
        printf("Error: malformed start time, should be in xx:xx:xx-xxx format.\n");
        return 1;
    }
    if(check(hh1,mm1,ss1,ms1))
    {
        printf("Error: invalid start time.\n");
        return 1;
    }

    int hh2,mm2,ss2,ms2;
    if(4 != std::sscanf(timeEnd.c_str(),"%02d:%02d:%02d-%03d",&hh2,&mm2,&ss2,&ms2))
    {
        printf("Error: malformed end time, should be in xx:xx:xx-xxx format.\n");
        return 1;
    }
    if(check(hh2,mm2,ss2,ms2))
    {
        printf("Error: invalid end time.\n");
        return 1;
    }

    int startMs = ms1;
    startMs += ss1 * 1000;
    startMs += mm1 * 1000 * 60;
    startMs += hh1 * 1000 * 60 * 60;

    int durationMs = ms2;
    durationMs += ss2 * 1000;
    durationMs += mm2 * 1000 * 60;
    durationMs += hh2 * 1000 * 60 * 60;

    if(startMs > durationMs)
    {
        printf("Start time > end time, swapping.\n");
        int swap = startMs;
        startMs = durationMs;
        durationMs = swap;
    }

    durationMs -= startMs;

    int sec = durationMs / 1000;
    int outms = durationMs - sec * 1000;
    int outhh = sec / (60 * 60);
    sec -= outhh * 60 * 60;
    int outmm = sec / 60;
    int outss = sec % 60;

    printf("Duration: %02d:%02d:%02d-%03d\n",outhh,outmm,outss,outms);
    return 0;
}

int validateString(std::string *s)
{
    std::size_t off = s->find(":");
    if(off == std::string::npos || !off || off > 2)
       return 1;
    if(s->size() - off != 10)
       return 1;
    off++;
    if(s->find(":",off) != off + 2)
       return 1;
    off += 3;
    if(s->find("-",off) != off + 2)
       return 1;
    return 0;
}

int check(int hours, int minutes, int seconds, int milli)
{
    if(hours < 0 || hours > 23)
        return 1;
    if(minutes < 0 || minutes > 59)
        return 1;
    if(seconds < 0 || seconds > 59)
        return 1;
    if(milli < 0 || milli > 999)
        return 1;
    return 0;
}
« Last Edit: July 28, 2019, 11:08:39 AM by eumagga0x2a »

hiro

  • Jr. Member
  • **
  • Posts: 52
Re: Keep encoding window on screen once enc. done?
« Reply #4 on: July 28, 2019, 03:32:20 PM »
THANX!! for the code;

"only" PROBLEM: just HOW could I exploit it? Note · I have no compiler & wouldn't know how to proceed anyway...

Frustrating, when seeing an out of reach — readymade? — peace'o'cake!


Astounded question: why THAT old?

"It's~about~TIME,~huh?"

Due to problems I had with 2.7.3 (forgot which exact version) — and to lack of... time, to test well enough again *. But PLANNED! :)

That said, 2.7.1 works just fine, for me anyway (versions = endless debate, I know).

* Also, since I've been "promoting" ADM (must be a decade, by now!) to friends — "forever newbies"... —, and quite "touchy" in case of the LEAST problem, I'm used to test as much as possible, before recommending a new version...


This could become a nifty exercise  :)

Ooch! Rather, kinda pain in the ... "exercice", in my case. But I did, and ended up with a little window, that does the trick:

"Duration-calc_Windows.7z"   https://www.datafilehost.com/d/dcedbc2e

EXCEPT :), darn!, that it works with 2.7.1 only = unable to find the same strings (therefore the required timestamps) in 2.7.2 "admlog.txt": error msg...

AND, but not least: ONLY on a "00:00:00(-000) to 23:59:59(-999)" 24-hour range. From e.g. "yesterday to today": no way, sir!..



eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3186
Re: Keep encoding window on screen once enc. done?
« Reply #5 on: July 28, 2019, 03:52:58 PM »
Astounded question: why THAT old?

"It's~about~TIME,~huh?"

Due to problems I had with 2.7.3 (forgot which exact version) — and to lack of... time, to test well enough again *. But PLANNED! :)

2.7.3 is also very old, there has been a ton of fixes since then. Please grab the latest nightly.

Quote
This could become a nifty exercise  :)
AND, but not least: ONLY on a "00:00:00(-000) to 23:59:59(-999)" 24-hour range. From e.g. "yesterday to today": no way, sir!..

You just found a bug in my exercise code, thanks  :)

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3186
Re: Keep encoding window on screen once enc. done?
« Reply #6 on: July 28, 2019, 04:14:04 PM »
Fixed version, still restricted to the timestamp format used by Avidemux:

Code: [Select]
#include <cstdio>
#include <string>

int main(int argc, char *argv[]);
int validateString(std::string *s);
int check(int hours, int minutes, int seconds, int milliseconds);

int main(int argc, char *argv[])
{
    if(argc != 3)
    {
        printf("Error: need two timestamps as arguments.\n");
        return 1;
    }

    std::string timeStart = argv[1];
    std::string timeEnd = argv[2];

    if(validateString(&timeStart))
    {
        printf("Error: malformed start time string.\n");
        return 1;
    }
    if(validateString(&timeEnd))
    {
        printf("Error: malformed end time string.\n");
        return 1;
    }

    int hh1,mm1,ss1,ms1;
    if(4 != std::sscanf(timeStart.c_str(),"%02d:%02d:%02d-%03d",&hh1,&mm1,&ss1,&ms1))
    {
        printf("Error: malformed start time, should be in xx:xx:xx-xxx format.\n");
        return 1;
    }
    if(check(hh1,mm1,ss1,ms1))
    {
        printf("Error: invalid start time.\n");
        return 1;
    }

    int hh2,mm2,ss2,ms2;
    if(4 != std::sscanf(timeEnd.c_str(),"%02d:%02d:%02d-%03d",&hh2,&mm2,&ss2,&ms2))
    {
        printf("Error: malformed end time, should be in xx:xx:xx-xxx format.\n");
        return 1;
    }
    if(check(hh2,mm2,ss2,ms2))
    {
        printf("Error: invalid end time.\n");
        return 1;
    }

    int startMs = ms1;
    startMs += ss1 * 1000;
    startMs += mm1 * 1000 * 60;
    startMs += hh1 * 1000 * 60 * 60;

    int durationMs = ms2;
    durationMs += ss2 * 1000;
    durationMs += mm2 * 1000 * 60;
    durationMs += hh2 * 1000 * 60 * 60;

    // Handle start time > end time as if there were a date change in-between .
    if(startMs > durationMs)
        durationMs += 1000 * 60 * 60 * 24;

    durationMs -= startMs;

    int sec = durationMs / 1000;
    int outms = durationMs - sec * 1000;
    int outhh = sec / (60 * 60);
    sec -= outhh * 60 * 60;
    int outmm = sec / 60;
    int outss = sec % 60;

    printf("Duration: %02d:%02d:%02d-%03d\n",outhh,outmm,outss,outms);
    return 0;
}

int validateString(std::string *s)
{
    std::size_t off = s->find(":");
    if(off != 1 && off != 2)
       return 1;
    if(s->size() - off != 10)
       return 1;
    off++;
    if(s->find(":",off) != off + 2)
       return 1;
    off += 3;
    if(s->find("-",off) != off + 2)
       return 1;
    return 0;
}

int check(int hours, int minutes, int seconds, int milli)
{
    if(hours < 0 || hours > 23)
        return 1;
    if(minutes < 0 || minutes > 59)
        return 1;
    if(seconds < 0 || seconds > 59)
        return 1;
    if(milli < 0 || milli > 999)
        return 1;
    return 0;
}

I fear this code is verbatim usable only on Unix/Linux with gcc and maybe with clang.

Code: [Select]
c++ timediff.cpp -o timediff
generates a small command-line binary which can be run in the terminal.

Code: [Select]
./timediff 12:57:22-900 9:26:03-080
Duration: 20:28:40-180

dosdan

  • Full Member
  • ***
  • Posts: 147
Re: Keep encoding window on screen once enc. done?
« Reply #7 on: July 29, 2019, 02:38:30 AM »

Code: [Select]
./timediff 12:57:22-900 9:26:03-080
Duration: 20:28:40-180

I don't do linux or c++, but I've got a Mingw environment on my Win10 PC since I compile a W64 version of FFPMEG (https://github.com/jb-alvarado/media-autobuild_suite).

So I ran this command (c++ timediff.cpp -o timediff) at the Mintty prompt.  Found out that the milliseconds separator used here was a dash ("-") not a dot/full stop ("."). So I made a few changes. Here are the 2 compiled W64 versions: 

https://dl.dropbox.com/s/5066zvlvqb66v9i/timediff_dash.exe

https://dl.dropbox.com/s/feuhvpg1lzkapp5/timediff_dot.exe

Usage under Windows, using the "dot" version:

timediff_dot start_time end_time

Code: [Select]
timediff_dot.exe  20:26:42.447  20:27:04.305
Duration: 00:00:21.858

Dan.
« Last Edit: July 29, 2019, 03:07:53 AM by dosdan »

hiro

  • Jr. Member
  • **
  • Posts: 52
Re: Keep encoding window on screen once enc. done?
« Reply #8 on: July 29, 2019, 03:49:39 AM »
Hi dosdan & thanx a lot for the two exe's.
+ to eumagga0x2a for the new code. *



My 64-bits Win. 10 required "libgcc_s_seh-1.dll" + "libwinpthread-1.dll", which I downloaded,

but, next, trying to execute the 2 apps, they return a "0xc000007b (couldn't start or initialize)" error,

although I tried on Windows AND also from CMD — "as admin." too, + after applying all available "compatibility modes"...

What could be missing? A .net Framework version, may be?


___________________

Oops / sorry (above).

[ I should quit working on 3 things at a time + answering the phone etc., sometimes... ]

After pasting the two exe's in Avidemux folder, they do work!


(... meaning that "libwinpthread-1.dll" I downloaded doesn't work, but the one shipped with ADM does; while my downloaded "libgcc_s_seh-1.dll" works.)


* Including the goodie, e.g. and encoding session starting around 8 PM and ending around 1 AM (i.e. next day) returns the right duration:

timediff_dot.exe  20:00:01.000 01:00:04.000
Duration: 05:00:03.000



Now, I'd need to "batch" something that'd AUTOextract the two relevant timestamps from "admlog.txt" and feed them to the app,

in order to achieve a one-click duration calc. tool...


« Last Edit: July 29, 2019, 05:22:53 AM by hiro »

hiro

  • Jr. Member
  • **
  • Posts: 52
Re: Keep encoding window on screen once enc. done?
« Reply #9 on: July 30, 2019, 12:41:26 AM »
Here is a... DRAFT!

Tested OK on Win. (10) 64-bit Avidemux 2.7.4 nightly + 2.7.1:

https://www.datafilehost.com/d/e88126e6

Would be nice if 32-bit Win./ ADM compatible too (but well...).


——  Added to instructions : "Remove 'admlog.txt' before (re)encoding using x264 – as the calculator might report a previous encoding duration otherwise" (though not quite sure).


« Last Edit: July 31, 2019, 03:22:25 PM by hiro »