-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat!: Add audio and subtitle stream parsing #50
feat!: Add audio and subtitle stream parsing #50
Conversation
@nathanbabcock: After almost finishing the variant where there was one event and separate struct for each parsed event type (audio, video, ...) I gave the enum-based solution another go. That variant is the subject of this PR. Although I have to match on a generic You can see the "original" variant in a branch in my fork. Its almost complete except changes in the documentation and some small improvements. P.S. Note, that this is a breaking change, since I moved some of the fields, such as P.P.S. I saw that you use the |
* Refactor code into common processing for all streams and spezialized functions for audio and video. * Update code examples * Change line breaks in lib.rs to LF * Add handling of streams that contain additional identifiers in square brackets such as `Stream #0:1[0x2](eng):`. These are found in mov containers.
5828fed
to
3e3d3db
Compare
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.
I really like the solution you landed on for this. The helper methods with matches!
go a long way in making it easy to use. I will leave a few small comments that are mostly stylistic, but other than that I think it is in great shape if you're happy with it as well.
Good point about usize
. I think the original intuition was that fields such as parent_index
and stream_index
would primarily be used with bracket syntax to index into e.g. FfmpegMetadata.outputs[parent_index]
and seems to require a usize
in order to do that. Although funnily enough the FfmpegDuration
struct has input_index: u32
instead which has to be manually cast to usize
elsewhere... 🤦 So clearly some standardization would be helpful. Personally I would go with usize
for indices and u32
for everything else (including the new sample_rate
), but I could be convinced otherwise.
Regardless this is looking good to merge into main. After that we can collect a few other breaking changes (including removing some deprecated functions from a recent PR), and then release a new major version once everything is sorted out!
src/event.rs
Outdated
} | ||
pub fn video_data(&self) -> VideoStream { | ||
if let TypeSpecificData::Video(video_stream) = &self.type_specific_data { | ||
video_stream.clone() |
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 is a nit and works just fine either way, but perhaps we can also return a borrowed &VideoStream
(or Option<&VideoStream>
) and let the user decide whether they want to clone()
. Again taking inspiration from serde_json
which returns a borrowed value.
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.
I agree here, too. This is more in line with Rust's philosophy of not copying implicitly. Thanks for the feedback. I created an additional commit.
You can squash on merge, right? I have been using mostly Gitlab for the past few years, so I don't know where to activate it in Github and whether only you can activate it.
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.
AFAIK,
I just noticed that |
Some other minor things that I thought about:
|
|
The values in stream metadata structs are not related to memory or array indexing and should therefore use "number" types.
I dove deeper into this subject and it is more involved than I thought. One of the realizations I had, is that
You're right. I had forgotten about outputs. I then considered
I realized that the entire
I would prefer not to loose "specific" since it communicates that the attribute of this type contains specialized data only available for certain types of streams. What do you think about I don't have anything else regarding this PR, unless you want to discuss the naming further. From my side, we can merge. |
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.
I pushed one more commit to go with StreamTypeSpecificData
. Since the helper methods cover 99% of use cases, a user would rarely need to import or reference the name of this enum directly, so I think a lengthy extra-descriptive name is fine here!
Thanks for contributing this, and especially for bouncing ideas back and forth. The iteration was super helpful.
I will merge to main
for now and move towards a new version release relatively soon, this weekend or maybe next.
Thank you for the valuable feedback, too. |
brackets such as
Stream #0:1[0x2](eng):
. These are found in movcontainers.
Partly discussed in #49