Skip to content

Conversation

reinecke
Copy link
Collaborator

This resolves #69

The image sequence is expressed with:

  • target_url_base - everything leading up to the file name in the target_url
  • name_prefix - everything in the file name leading up to the frame number
  • name_suffix - everything after the frame number in the file name
  • start_frame - first frame number used in file names
  • frame_step - step between frame numbers in file names (every other frame is a step of 2)
  • rate - double frame rate if every frame in the sequence were played back (ignoring skip frames)
  • frame_zero_padding - Number of digits to pad zeros out to (e.x. frame 10 with a pad of 4 would be 0010)
  • missing_frame_policy - enum ImageSequenceReference.MissingFramePolicy {error, hold, black} allows hinting about how a consuming app should behave if an image for which a url is returned should be handled when missing from disk

An example for 24fps media with a sample provided each frame numbered 1-1000 with a path /show/sequence/shot/sample_image_sequence.%04d.exr might be:

{
  "available_range": {
    "start_time": {
      "value": 0,
      "rate": 24
    },
    "duration": {
      "value": 1000,
      "rate": 24
    }
  },
  "start_frame": 1,
  "frame_step": 1,
  "rate": 24,
  "target_url_base": "file:///show/sequence/shot/",
  "name_prefix": "sample_image_sequence.",
  "name_suffix": ".exr"
  "frame_zero_padding": 4,
}

The same duration sequence but with only every 2nd frame available in the sequence would be:

{
  "available_range": {
    "start_time": {
      "value": 0,
      "rate": 24
    },
    "duration": {
      "value": 1000,
      "rate": 24
    }
  },
  "start_frame": 1,
  "frame_step": 2,
  "rate": 24,
  "target_url_base": "file:///show/sequence/shot/",
  "name_prefix": "sample_image_sequence.",
  "name_suffix": ".exr"
  "frame_zero_padding": 4,
}

A target url is generated using the equivalent of the following python format string:
f"{target_url_prefix}{(start_frame + (sample_number * frame_step)):0{value_zero_padding}}{target_url_postfix}"

Negative start_frame is also handled. The above example with a start_frame of -1 would yield the first three target urls as:

  • file:///show/sequence/shot/sample_image_sequence.-0001.exr
  • file:///show/sequence/shot/sample_image_sequence.-0000.exr
  • file:///show/sequence/shot/sample_image_sequence.0001.exr

Benefits of this approach include:

  • The ability to derive the times each image map to
  • Avoids having to support and potentially implement a rich format string system in otio

Downsides:

  • A bit heavier than using format strings
  • Not as flexible/extensible as format strings

References:

Related PRs:

Co-authored by: @apetrynet

reinecke and others added 4 commits May 28, 2020 11:28
Added ImageSequenceReference MediaReference subclass schema.
* * Added initial support for `ImageSequenceReference`

* * Added sample otio file with `ImageSequenceReference`
* Added test for creating an rv session file with the sample file above

* * Use the `frame_zero_padding` from the `ImageSequenceReference` in stead of `start_frame` for frame substitution base

* * renamed _in and _out variables

* * lint fix
* * create and delete temp file and file descriptors through `setUp()` and `tearDown()` methods to prevent fd leak
* * Close tmp file descriptor in `setUp()` to avoid trouble in Windows
* Removed redundant assertions as suggested in PR comments
* Added support for ImageSequenceReference to the example OTIO RV reader plugin

* Removed debug print

* Switched to using opentime.to_frames to compute rv's in and out frames

Co-authored-by: Robyn Rindge <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2020

Codecov Report

Merging #722 into master will increase coverage by 1.33%.
The diff coverage is 86.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #722      +/-   ##
==========================================
+ Coverage   81.88%   83.21%   +1.33%     
==========================================
  Files          72       74       +2     
  Lines        2755     2884     +129     
==========================================
+ Hits         2256     2400     +144     
+ Misses        499      484      -15     
Flag Coverage Δ
#py27 83.13% <84.61%> (+1.26%) ⬆️
#py36 83.20% <86.15%> (+1.33%) ⬆️
#py37 83.20% <86.15%> (+1.33%) ⬆️
Impacted Files Coverage Δ
src/opentimelineio/imageSequenceReference.h 62.50% <62.50%> (ø)
src/opentimelineio/imageSequenceReference.cpp 91.42% <91.42%> (ø)
src/opentimelineio/typeRegistry.cpp 85.29% <100.00%> (+0.14%) ⬆️
...entimelineio-bindings/otio_serializableObjects.cpp 94.96% <100.00%> (+0.44%) ⬆️
src/opentimelineio/serializableObject.h 88.11% <0.00%> (+0.99%) ⬆️
src/opentimelineio/serialization.cpp 83.61% <0.00%> (+1.00%) ⬆️
src/opentimelineio/errorStatus.cpp 38.46% <0.00%> (+3.84%) ⬆️
src/opentimelineio/deserialization.cpp 58.51% <0.00%> (+5.31%) ⬆️
... and 2 more

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 39aae41...389130a. 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. Can the documentation be passed through the pybind code so that it shows up in the serialized help documentation (and just in help() in python?)

Thanks!

Comment on lines 361 to 367
*documentation*:

```
None
```

parameters:
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we get some of the documentation to flow through the python bindings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added docstrings in the bindings. I'd love to have someone give feedback on wether or not it all makes sense. The bulk of the content is forklifted from this PR.

@reinecke
Copy link
Collaborator Author

I think the build failure is a transient error, the python3.6 build just needs to be re-run.

@reinecke reinecke requested a review from ssteinbach May 29, 2020 00:39
@reinecke reinecke merged commit 2a1551e into master Jun 30, 2020
@ssteinbach ssteinbach added this to the Public Beta 13 milestone Jul 7, 2020
@meshula meshula deleted the imagesequence branch February 18, 2021 23:52
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.

Image sequence support
7 participants