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

Add VIDEO_FORMAT header when writing to string/file from ALE adpater #462

Merged
merged 4 commits into from
Mar 27, 2019

Conversation

mikekoetter
Copy link
Contributor

So, the Media Composer seems to be a bit picky about ALE headers and it will complain if we don't set a VIDEO_FORMAT. This MR looks to do that.

The first thing it does is add a `video_format` kwarg to the adapter signature, allowing you to set the format on output.

If we don't set that variable it will try to preserve the existing header column (if set).
This would likely only be set if the time-line was read in from a previous ALE

When the header column is not found, it searches each clips ALE metadata for an "Image Size" setting to infer a project format. 

If none of that is found it defaults to the adapters DEFAULT_VIDEO_FORMAT (1080)

1080p is probably the most popular format being used right now, but I am open to suggestions if anyone has other thoughts on default settings

Adds a video_format kwarg to the adapter signature, allowing you to set
the format on output. The fallback is to preserve the existing header
column, if set. Finally it searches each clips ALE metadata for an
"Image Size" setting to infer a project format. If none of that is found
it defaults to the adapters DEFAULT_VIDEO_FORMAT (1080)
@codecov-io
Copy link

codecov-io commented Mar 20, 2019

Codecov Report

Merging #462 into master will increase coverage by 0.77%.
The diff coverage is 96.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #462      +/-   ##
==========================================
+ Coverage   87.21%   87.99%   +0.77%     
==========================================
  Files          67       68       +1     
  Lines        6819     6878      +59     
==========================================
+ Hits         5947     6052     +105     
+ Misses        872      826      -46
Impacted Files Coverage Δ
...elineio_contrib/adapters/tests/test_ale_adapter.py 98.33% <100%> (+0.96%) ⬆️
opentimelineio_contrib/adapters/ale.py 87.86% <93.54%> (+4.52%) ⬆️
opentimelineio_contrib/adapters/extern_rv.py 0% <0%> (ø) ⬆️
opentimelineio/console/console_utils.py 100% <0%> (ø)
...elineio_contrib/adapters/aaf_adapter/aaf_writer.py 93.62% <0%> (+0.02%) ⬆️
...elineio_contrib/adapters/tests/test_aaf_adapter.py 98.1% <0%> (+0.02%) ⬆️
...neio_contrib/adapters/advanced_authoring_format.py 90.62% <0%> (+0.04%) ⬆️
opentimelineio/console/otiocat.py 96.29% <0%> (+12.96%) ⬆️
opentimelineio/console/otioconvert.py 93.42% <0%> (+40.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 44a06b0...e8488d5. Read the comment docs.

Copy link
Collaborator

@ssteinbach ssteinbach left a comment

Choose a reason for hiding this comment

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

Looks good, just had a couple small tweaks. Thanks!

opentimelineio_contrib/adapters/ale.py Show resolved Hide resolved
@@ -109,6 +111,20 @@ def _parse_data_line(line, columns, fps):
))


def get_video_format(width, height):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be a good idea to bump this map up to the top level and/or add a comment about how to use this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what 'top level' means in an adapter file, but I added a brief comment and made it "private"

Move metadata search and the video_format mapping into private methods
outside of `write_to_string`
def _video_format(width, height):
"""Utility function to map a width and hight to an Avid Project Format"""

format_map = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant that this map could be moved outside the function as a module level constant -- AVID_PROJECT_HEIGHT_TO_WIDTH_MAP = {...} or something. We're trying to call out these kinds of constant definitions to make them easier to find in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I think I understand the request, however I don't think that dict would be very useful unless you are applying the width check for resolutions wider than 1920, which avid (currently) considers CUSTOM

I can move the _video_format(...) function to the top of the file and make give that a "public" syntax if you think that would be helpful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ssteinbach - I moved and renamed it. please let me know if that is more what you are thinking

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, looks great. Thanks!

rename _video_format() to AVID_PROJECT_FORMAT_FROM_WIDTH_HEIGHT()
Rename function to AVID_VIDEO_FORMAT_ from AVID_PROJECT_FORMAT_ to be
more accurate to what is being mapped
Copy link
Collaborator

@ssteinbach ssteinbach left a comment

Choose a reason for hiding this comment

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

Looks great, thanks.

@ssteinbach ssteinbach merged commit af1a817 into AcademySoftwareFoundation:master Mar 27, 2019
@ssteinbach ssteinbach added this to the Public Beta 10 milestone Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants