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

Make FFmpeg log level configurable #2439

Closed
wants to merge 2 commits into from
Closed

Conversation

mthrok
Copy link
Collaborator

@mthrok mthrok commented Jun 3, 2022

and set the default level to 8 for less verbose logging.

Undesired logs are one of the loudest UX complains we get.
Yet, loading media files involves uncertainty which is
difficult to debug without debug log.

This commit introduces utility functions to configure logging level
so that we can ask users to enable it when they encounter an issue,
while defaulting to non-verbose option.

Copy link
Contributor

@carolineechen carolineechen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utility function looks good, just want to double check default log value -- description mentions 0 but it is 8 in the code. generally enabling it for errors (16) by default makes more sense to me, but do you find this to be too noisy?

we can ask users to enable it when they encounter an issue

is there a good place we could add this message upon failure so users are aware of this log setting utility

Arguments:
level (int): Log level. The larger, the more verbose.

The following values are valid values, the corresponding ``ffmpeg``'s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if they enter an invalid value? should we add a check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they will boil down to a simple level comparison, so it's safe to put other values.

https://ffmpeg.org/doxygen/4.1/log_8c_source.html#l00316

It's just normally, log-levels are set by ffmpeg CLI, which exposes the listed values. Let me rephrase, common values, instead of saying valid values.

@mthrok
Copy link
Collaborator Author

mthrok commented Jun 3, 2022

description mentions 0 but it is 8 in the code.

Description also says 8. In test code it's reset to 0.

generally enabling it for errors (16) by default makes more sense to me, but do you find this to be too noisy?

16 can repeat messages across decoding units, so, decoding one audio file can still flood the log.

is there a good place we could add this message upon failure so users are aware of this log setting utility

Decoder errors are not necessarily failure, that's why it's tricky. You would still get the tensor and keep going. But if you are training a model with many files, then the size of the training log could blow up with the decoding issues that is not an issue for DL practitioners.

@mthrok mthrok marked this pull request as ready for review June 3, 2022 18:49
@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@carolineechen carolineechen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description also says 8.

I meant it says 0 in the PR description, but yea code looks good if 8 is intended.

For the second point, was more wondering if there was a good spot in the ffmpeg documentation or logging output to let users know that this logging functionality exists (this is not blocking)

Copy link
Contributor

@hwangjeff hwangjeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you considered introducing constants for the different log levels, e.g. FATAL and WARNING, similar to logging?

test/torchaudio_unittest/utils/ffmpeg_utils_test.py Outdated Show resolved Hide resolved
except Exception:
_IS_FFMPEG_AVAILABLE = False
return _IS_FFMPEG_AVAILABLE
return torchaudio._extension._FFMPEG_INITIALIZED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change relate to log level configurability?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not technically. but as I write the test, I realized that the logic is duplicated in library and test util.

@mthrok
Copy link
Collaborator Author

mthrok commented Jun 3, 2022

I meant it says 0 in the PR description, but yea code looks good if 8 is intended.

Oh my bad, fixed the description.

For the second point, was more wondering if there was a good spot in the ffmpeg documentation or logging output to let users know that this logging functionality exists (this is not blocking)

Good point, let me update the doc.

@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mthrok
Copy link
Collaborator Author

mthrok commented Jun 3, 2022

have you considered introducing constants for the different log levels, e.g. FATAL and WARNING, similar to logging?

I thought about it, but unlike the logging module which is all about logging, this utility module is things more general about ffmpeg runtime configuration, so, I did not think putting alias at module level makes much sense, then thought adding some ENUM-like features for the set_log_level is kinda overkill.

Summary:
and set the default level to 8 for less verbose logging.

Undesired logs are one of the loudest UX complains we get.
Yet, loading media files involves uncertainty which is
difficult to debug without debug log.

This commit introduces utility functions to configure logging level
so that we can ask users to enable it when they encounter an issue,
while defaulting to non-verbose option.

Pull Request resolved: pytorch#2439

Reviewed By: xiaohui-zhang

Differential Revision: D36903763

Pulled By: mthrok

fbshipit-source-id: ed495641a868ed9a3f34c2a5f37fa3e5b135d0ec
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D36903763

@mthrok
Copy link
Collaborator Author

mthrok commented Jun 3, 2022

@carolineechen let me revert the default log level modification, as it might be disruptive if other libraries / existing code base expects log level with already set.

@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@github-actions
Copy link

github-actions bot commented Jun 4, 2022

Hey @mthrok.
You merged this PR, but labels were not properly added. Please add a primary and secondary label (See https://github.com/pytorch/audio/blob/main/.github/process_commit.py)

@mthrok mthrok deleted the loglevel branch June 4, 2022 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants