Giter Club home page Giter Club logo

Comments (10)

mikeboers avatar mikeboers commented on June 26, 2024

Unfortunately, I don't think that sort of information is available from FFmpeg/Libav, as it may not be a common thing for codecs to encode into individual frames/packets.

from pyav.

mkassner avatar mkassner commented on June 26, 2024

ok, that makes sense. I just thought it might be possible because of a few members in the AVframe struct:

int     coded_picture_number
    #picture number in bitstream order 

int     display_picture_number
    #picture number in display order 

from pyav.

mikeboers avatar mikeboers commented on June 26, 2024

They look promising, but (IIRC) they are set in essentially the same manner as PyAV's Frame.index, and just won't work across a seek. =[

On Jul 12, 2014, at 1:17 AM, mkassner [email protected] wrote:

ok, that makes sense. I just thought it might be possible because of a few members in the AVframe struct:

int coded_picture_number
#picture number in bitstream order

int display_picture_number
#picture number in display order
β€”
Reply to this email directly or view it on GitHub.

from pyav.

mkassner avatar mkassner commented on June 26, 2024

Alright. Thanks for the clarification!

from pyav.

mikeboers avatar mikeboers commented on June 26, 2024

Seems like the documentation should be improved, at the least.

from pyav.

markreidvfx avatar markreidvfx commented on June 26, 2024

If the video is constant frame rate, the frame number should be pts_seconds / frame_rate. That might be good enough for most codecs, assuming the file is encoded correctly, doesn't drop or repeat frames. The only way to do it 100% accurately as far as I understand is to decode every frame and count and then make a pts seek table.
That's what this project does, https://github.com/lbrandy/ffmpeg-fas

from pyav.

mkassner avatar mkassner commented on June 26, 2024

I was hoping for frame indices of variable frame rate videos, otherwise frame index is always just pts/framerate like you said. I was hoping seek tables to already be present in the container. Building one ourselves is not hard so I will go with that!

from pyav.

mikeboers avatar mikeboers commented on June 26, 2024

I'm going to leave this open as a documentation issue.

from pyav.

funkybob avatar funkybob commented on June 26, 2024

In my own code, after much painful and tedious research :) I have the following:

'''
        PTS (Presentation Time Stamp), which indicates when this frame should
        be shown, is expressed according to stream.time_base.

        We can compare the PTS to frame numbers if we scale by:
            (stream.average_rate / stream.time_base)
'''
pts_scale = video_stream.average_rate * video_stream.time_base

frame_pts = int(frame_index / pts_scale)

I'm not certain how portable this is, as we only use MP4 video streams.

from pyav.

jlaine avatar jlaine commented on June 26, 2024

I'm going to close this issue, as the following time-related attributes are properly documented nowadays:

  • dts
  • pts
  • time_base

from pyav.

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.