-
Notifications
You must be signed in to change notification settings - Fork 57
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
Shortcuts to tracks values #95
Comments
I'm afraid we can't do that. There are a lot attributes that are present in multiple tracks.
I'm thinking of something like Would that work for you? If you're working with one image, you would only have to do |
If I understand well, it would take the first instance present (e.g. Width of video if there is both video and image).
this is actually similar to the upstream API :-p, except that it is more dynamic (like
It may be expanded in the future... But very rare, not expected at short term. |
Hi Jérôme, I'm always amazed at how quickly you appear in pymediainfo issues, do you get a notification whenever MediaInfoLib is mentioned 😛?
I don't really like that, maybe if more users request that feature I will consider it but at the moment, I feel weird about exposing those unrelated attributes at the top level.
OK, good to know, I guess this list hasn't changed for several years. |
I forgot to answer that: maybe I could also do it this way without breaking compatibility: mediainfo.tracks[0] # index is an int, returns the first track
mediainfo.tracks["image"] # index is a str, returns Image tracks @JulienPalard what do you think? |
Same. I also got sch request (as well as not having an array for "general" part as it is always 1) but I currently prefer to have a coherent API rather than a simple one. But as you (in pymediainfo) list all tracks in sequence, a
"watch the project", "be notified of all conversations" GitHub feature 😛. |
Do you mean "instead of"?
Ah cool, I wondered whether you were watching pymediainfo or just getting notifications for your own project. |
"or" (I edited my comment). |
Thanks @JeromeMartinez for hopping in and @sbraz for the fast replies :) It feel weired too, to me, to expose all values in the root scope and mix them (that's why I opened a discussion instead of a PR), and I had not searched enough to get the list of all attributes all tracks can have to estimate the number of collisions, and their importance. You seem to agree that those collisions could be surprising to users (leading to unexpected values, potentially leading to bugs), to add this feature, I trust you. About
Which is nice, for the (niche?) case of someone already knowing it and migrating to Python. (I was unable to find the doc though, can you link it to us?) The info = MediaInfo.parse("file.jpg")
print(info.image_tracks[0].width, info.image_tracks[0].height) which is more reliable than the To help me see the difference, I'm trying to see what would change with the documentation example: from pprint import pprint
from pymediainfo import MediaInfo
media_info = MediaInfo.parse("my_video_file.mp4")
for track in media_info.tracks:
if track.track_type == "Video":
print("Bit rate: {t.bit_rate}, Frame rate: {t.frame_rate}, "
"Format: {t.format}".format(t=track)
)
print("Duration (raw value):", track.duration)
print("Duration (other values:")
pprint(track.other_duration)
elif track.track_type == "Audio":
print("Track data:")
pprint(track.to_data()) could be rewritten as: from pprint import pprint
from pymediainfo import MediaInfo
media_info = MediaInfo.parse("my_video_file.mp4")
for track in media_info.video_tracks:
print("Bit rate: {t.bit_rate}, Frame rate: {t.frame_rate}, "
"Format: {t.format}".format(t=track)
)
print("Duration (raw value):", track.duration)
print("Duration (other values:")
pprint(track.other_duration)
for track in media_info.audio_tracks:
print("Track data:")
pprint(track.to_data()) Are you happy with this? Looks good to me, and I like the side effect of dropping an indentation level. Would asking for At least, forcing pymediainfo users to write I'm searching a bit on github to see if actual uses of pymediainfo (mine might not be representative) could benefit from it:
So yes, it looks like it would be usefull. Seeing people using Bonne journée. |
@JeromeMartinez any idea where I could find a very small sample that contains an I could also test from a saved XML file if that's not possible. |
In order to improve tests, chapters are added to sample.mkv and an image is added to test files.
In order to improve tests, chapters are added to sample.mkv and an image is added to test files.
In order to improve tests, chapters are added to sample.mkv and an image is added to test files.
Also add the following to improve tests: * Chapters to sample.mkv. * An image test file. * A MediaInfo XML output for a file containing tracks of type "Other".
I'm working in a project that currently only handle jpg, so I always have only two tracks: General and Image, and at the moment I only need width and height, so I have to do something like:
And cross my fingers General and Image never get swapped in certain specific contexts.
Or I could do:
Which is still a bit verbose.
What about:
It could be easily implemented by adding to the
MediaInfo
class:which would allow things like:
to work with images and videos.
Alternatives
or providing access to tracks by name (I know there can be multiple tracks with the same name):
To discuss
Currently a
Track
returnsNone
on non-existing attribute, should we mirror this here?The text was updated successfully, but these errors were encountered: