Comments (10)
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.
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.
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 orderint display_picture_number
#picture number in display order
β
Reply to this email directly or view it on GitHub.
from pyav.
Alright. Thanks for the clarification!
from pyav.
Seems like the documentation should be improved, at the least.
from pyav.
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.
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.
I'm going to leave this open as a documentation issue.
from pyav.
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.
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)
- Update some documentation links HOT 6
- Can't use analyzeduration options with rtmp url HOT 1
- Building whl files HOT 1
- Build wheel use my own ffmpeg, but can't find the av.libs path. HOT 1
- pkg-config returned flags we don't understand: -Wl,-rpath,... HOT 1
- Resource temporary unavailable issue when retiming audio HOT 1
- Functional Difference In Data Stream between AV 11.0.0 and AV 12.0.0 HOT 1
- AV 12.0.0 decoded frames do not match source as in AV 11.0.0 (potential colorspace issue) HOT 3
- Missing shared object file after upgrading to Python 3.12 HOT 1
- frame.index is deprecated HOT 1
- Provide Apple M1 binaries for pypy HOT 2
- Compatibility with NumPy 2.0? HOT 9
- to_bytes does not exist on Packet. HOT 2
- Generating a video with numpy and writing it with pyav does not preserve color HOT 1
- Unable to set frame rate HOT 3
- `argument 2 of βav_bsf_list_parse_strβ from incompatible pointer type` in `bitstream.c` HOT 8
- Expose `av_frame_make_writable` HOT 2
- Support for v360 video filter HOT 1
- How do I set the value of slices?
- Allow using the ffmpeg cli API HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyav.