-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Show FFMPEG Postprocessing Progress #1947
Conversation
Based upon https://github.com/Kenshin9977/yt-dlp/tree/patch-2 , extended fix towards postprocessing
Ex: youtube downloading issues. I didn't do any changes to the youtube downloader side of things apart from changes that were already working in another commit.
Forgot to run flake8 on the recent one. Fixed spacing.
I opened #1720 in hopes of getting a progress for the sponsorblock ad removing code. Since ffmpeg is used in a way to make ffmpeg quick but create somewhat messy/invalid videos I change the concat code to make it re-encode the video instead of a copy which makes ffmpeg take a lot more time. I downloaded the zip https://github.com/raggs1561/yt-dlp/archive/refs/heads/master.zip And got this error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is based at 90% on #1133. Though you say it in your first commit comment it's stated in your PR that you're the original author of this code. There is few ways to improve the clarity and the maintainability of this PR
reg1 = re.match(r"((?P<H>\d\d?):)?((?P<M>\d\d?):)?(?P<S>\d\d?)(\.(?P<f>\d{1,3}))?", time_string) | ||
reg2 = re.match(r"\d+(?P<U>s|ms|us)", time_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear var name for reg1 and reg2
reg1 = re.match(r"((?P<H>\d\d?):)?((?P<M>\d\d?):)?(?P<S>\d\d?)(\.(?P<f>\d{1,3}))?", time_string) | |
reg2 = re.match(r"\d+(?P<U>s|ms|us)", time_string) | |
hms_parsed = re.match(r"((?P<H>\d\d?):)?((?P<M>\d\d?):)?(?P<S>\d\d?)(\.(?P<f>\d{1,3}))?", time_string) | |
smu_parsed = re.match(r"\d+(?P<U>s|ms|us)", time_string) |
|
||
|
||
def compute_prefix(match): | ||
res = int(match.group('E')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear var name
res = int(match.group('E')) | |
no_prefix_int = int(match.group('E')) |
def parse_ffmpeg_time_string(time_string): | ||
time = 0 | ||
reg1 = re.match(r"((?P<H>\d\d?):)?((?P<M>\d\d?):)?(?P<S>\d\d?)(\.(?P<f>\d{1,3}))?", time_string) | ||
reg2 = re.match(r"\d+(?P<U>s|ms|us)", time_string) | ||
if reg1: | ||
if reg1.group('H') is not None: | ||
time += 3600 * int(reg1.group('H')) | ||
if reg1.group('M') is not None: | ||
time += 60 * int(reg1.group('M')) | ||
time += int(reg1.group('S')) | ||
if reg1.group('f') is not None: | ||
time += int(reg1.group('f')) / 1_000 | ||
elif reg2: | ||
time = int(reg2.group('U')) | ||
if reg2.group('U') == 'ms': | ||
time /= 1_000 | ||
elif reg2.group('U') == 'us': | ||
time /= 1_000_000 | ||
return time | ||
|
||
def compute_prefix(match): | ||
res = int(match.group('E')) | ||
if match.group('f') is not None: | ||
res += int(match.group('f')) | ||
if match.group('U') is not None: | ||
if match.group('U') == 'g': | ||
res *= 1_000_000_000 | ||
elif match.group('U') == 'm': | ||
res *= 1_000_000 | ||
elif match.group('U') == 'k': | ||
res *= 1_000 | ||
return res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeat of the functions already present in yt_dlp/downloader/external.py.
Don't repeat yourself otherwise the day we'll have to make some changes it will have to be repeated within both files even though those are the exact same functions.
'status': 'finished', | ||
'processed_bytes': total_filesize | ||
}) | ||
self._hook_progress(status, information) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark applies. There is a way to factorize this chunk of code
res *= 1_000 | ||
return res | ||
|
||
def real_run_ffmpeg(self, input_path_opts, output_path_opts, *, expected_retcodes=(0,), information): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
information
isn't defined anywhere. It can't work as is
'status': 'finished', | ||
'processed_bytes': total_filesize | ||
}) | ||
self._hook_progress(status, information) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._hook_progress
doesn't exist
Superseded by #2475 |
Please follow the guide below
x
into all the boxes [ ] relevant to your pull request (like that [x])Before submitting a pull request make sure you have:
In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
Explanation of your pull request in arbitrary form goes here. Please make sure the description explains the purpose and effect of your pull request and is worded well enough to be understood. Provide as much context and examples as possible.
FFMPEG uses same _hook_progress to track postprocessing progress.
Should close #1720