Giter Site home page Giter Site logo

Comments (8)

decriptor avatar decriptor commented on September 2, 2024

Thanks. Would you be willing to open a PR with a fix?

from taglib-sharp.

daiplusplus avatar daiplusplus commented on September 2, 2024

But this will mean the foreach( ICodec... code will never be invoked because the two TimeSpan.Zero conditions are collectively exhaustive and there is no mutation of this.duration between the two statements.

I understand that duration == TimeSpan.Zero actually means "unspecified" instead of actually being zero.

I think a better fix (to explicitly allow for a meaningful zero duration) would be to use System.Threading.Timeout.InfiniteTimeSpan (-1) to denote undefined duration.

from taglib-sharp.

Starwer avatar Starwer commented on September 2, 2024

A Zero duration indeed here means: no duration. This is consistent with the rest of the TagLib# properties like Year and feels quite intuitive.
Also I do not think that a video or sample which contains nothing at all is a valid usecase. So the Zero to represent that no duration is available is, IMHO, a pretty fine choice.

@RogerioDuarte : In which case do you encounter a problem with this Zero duration convention ?

from taglib-sharp.

daiplusplus avatar daiplusplus commented on September 2, 2024

Also I do not think that a video or sample which contains nothing at all is a valid usecase.

What is the duration value of a video file that contains a single frame of video, e.g. a single-frame GIF image?

from taglib-sharp.

Starwer avatar Starwer commented on September 2, 2024

What is the duration value of a video file that contains a single frame of video, e.g. a single-frame GIF image?

The duration of such a single frame video should certainly not be 0, but follows this universal formula:
duration = frame_number / frame_rate
As a result, assuming a typical frame-rate of 25 fps, you'll have a duration of 40 milliseconds.

from taglib-sharp.

daiplusplus avatar daiplusplus commented on September 2, 2024

As a result, assuming a typical frame-rate of 25 fps, you'll have a duration of 40 milliseconds.

GIF files do not have a fixed frame-rate though, instead they have a delay value associated with each frame (making it a variable frame-rate file format) ( https://www.w3.org/Graphics/GIF/spec-gif89a.txt - section 23 c). Consider a GIF with a single frame with a Delay Time value of 0 (which is valid, as per the specification). How does TagLib handle this case?

from taglib-sharp.

Starwer avatar Starwer commented on September 2, 2024

Consider a GIF with a single frame with a Delay Time value of 0 (which is valid, as per the specification). How does TagLib handle this case?

Then this should be indeed a duration of Zero. The difference between interpreting it as zero duration, infinite duration, undefined/unknown duration or no duration is quite a philosophical debate... In all those cases, we know that the duration is just irrelevant, just like in a BMP picture.

from taglib-sharp.

windracer avatar windracer commented on September 2, 2024

RogerioDuarte, thank you for posting the fix, I have forced with the same issue, but... After applying your fix, the duration for all files is always Zero.

I, however, found another (I think) issue causing the infinite recursion loop. In file Mpeg\AudioHeader.cs the Duration in some circumstances is calculated via AudioBitrate whereas AudioBitrate uses Duration. The fix is to change all references to Duration (property) in AudioBitrate property to duration (member variable).

The infinite recursion loop occurs on a file with a broken duration (=0).

However, my fix is not correct because in that case you have to call Duration before AudioBitrate when you're reading properties.

from taglib-sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.