Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pbar #57

Merged
merged 3 commits into from
Apr 11, 2020
Merged

Pbar #57

merged 3 commits into from
Apr 11, 2020

Conversation

kylon
Copy link
Collaborator

@kylon kylon commented Apr 11, 2020

progress bar tested on linux and windows 10 (cmd and PS)

kylon added 2 commits April 11, 2020 13:16
Move ts files to src, build and output js files to build folder
@kylon kylon mentioned this pull request Apr 11, 2020
this is triggered by signal events
@lukaarma
Copy link
Collaborator

I would leave the message that tell the user that there were no errors...or make it behind verbose

Personally I like to know when a program like this runs successfully

@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

which message?

@lukaarma
Copy link
Collaborator

The one you removed in the last commit

@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

ok, you can't print a success message when exit code is 0 because exit code could 0 when the program dies for other reasons, so we don't know what happened, but we know we should not tell the user everything is ok.

@lukaarma
Copy link
Collaborator

lukaarma commented Apr 11, 2020 via email

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

I'll merge this as it is for now and we can tweak it as we go.
Exit 0 is usually a good thing but as with everything, it depends. ffmpeg may consider downloading the video track without audio a success... We probably need some checks at the very end before we have the confidence to say everything went alright.

@snobu snobu merged commit 9faa0c4 into snobu:tokencache Apr 11, 2020
@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

I'm quite sure that if the program dies for any reason other than returning at the end of the execution the code will not be 0 @snobu, your opinion on the exit message question?

signals can stop the execution and return 0 but it is not a success

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

Yup, here's a CTRL-C in Node and PowerShell reporting back a happy exit 0.

C:\destreamer [tokencache ≡]> node
Welcome to Node.js v13.11.0.
Type ".help" for more information.
>
(To exit, press ^C again or ^D or type .exit)
>
C:\destreamer>echo $?
True

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

Note to everyone involved, don't do a pull, start a fresh clone in a new folder since the structure has now dramatically changed to src/ and build/. I believe this to be the right move at this point as it was getting out of hand with those files sprayed out everywhere.

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

@kylon,

Where is this coming from?

C:\destreamer [tokencache ≡]> node build/destreamer.js --videoUrls https://xxxxx.microsoftstream.com/video/e3f0-xxx-xxxx-xxxx-xxx 

internal/modules/cjs/loader.js:979
  throw err;
  ^

Error: Cannot find module 'C:\destreamer\build\destreamer.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
    at Function.Module._load (internal/modules/cjs/loader.js:859:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Is this expected or i'm launching it all wrong?

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

Ah found it, it's building in build/src/*.js instead of build/*.js.
Is this what you wanted?

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

So the progress works nicely but it never exists, just hangs like this:
image

The file is there in the target output dir and is completed (muxed).

I believe it hangs awaiting on the progress bar.
If i add a manual exit(0) it does exit.

            .on('end', () => {
                console.log(colors.green(`\nDownload finished: ${outputPath}`));
                process.exit(0);
            });

LATER EDIT: We could piggyback on .end() and pull the bar to 100% so it exists cleanly - tested, works. I'll let @kylon decide on the final implementation.

            .on('end', () => {
                pbar.update(100);
                console.log(colors.green(`\nDownload finished: ${outputPath}`));
            });

@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

the progress bar should "kill" itself when the progress is 100% but here it is not, so it is waiting for the next update

i would like to know why it s not 100, what is the currentChunk value and duration value (total chunks)

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

Looks like it's an off by one problem as it always reaches 97%. Just print the chunks as it goes along maybe it reveals the flaw.

@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

my videos reach 100, i ll try more videos or is your video public?

my ideas are:
1 wrong chunks calculation for some reasons
2 ffmpeg skips progress event and goes to end for the last chunk

if the latter is the case, yeah we should move the bar ourself, otherwise it is probably better to see what happen to prevent future issues

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

For some videos it goes all the way to 100% but still doesn't exit.

image

with currentChunks -
image

@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

try this, it seems ffmpeg goes to end for the last chunk

add this before ffmepg()
let pre = 0;

 on('progress', progress => {
                 const currentChunks = ffmpegTimemarkToChunk(progress.timemark);
                const cc = currentChunks - pre;

                 pbar.increment(cc, {
                     speed: progress.currentKbps
                 });
                 pre = currentChunks
             })

@snobu
Copy link
Owner

snobu commented Apr 11, 2020

The question is, how reliable is the chunk counter, if we just do pbar.update(100) inside .on('end..
we have a much better chance to avoid off-by-a-chunk hangs that we may not be able to handle now since we haven't seen them. They may not exist but that's just speculation at this point.

I'm more worried about what ffmpeg is feeding us than what we do in our method. There are dozens, dozens of slightly different builds of ffmpeg out there people use.

@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

yeah, i m fixing the video download and progress bar
i m using both, i found that the code above is more precise then update() and update(100) just to be sure when done

@snobu snobu added the enhancement New feature or request label Apr 11, 2020
@snobu snobu added this to the v2.0 milestone Apr 11, 2020
@kylon
Copy link
Collaborator Author

kylon commented Apr 11, 2020

I'm more worried about what ffmpeg is feeding us than what we do in our method. There are dozens, dozens of slightly different builds of ffmpeg out there people use.

what you mean?
we are using fluent, the worst case is ffmpeg changes and fluent can no longer give us the timemark

@lukaarma
Copy link
Collaborator

I think that what @snobu meant is that being many different version of ffmpeg they might elaborate chunks slightly differently or they might feed sliglty different data into fluent-ffmpeg so we don't want to rely only on that and use that update(100)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants