BabitMF / bmf

Cross-platform, customizable multimedia/video processing framework. With strong GPU acceleration, heterogeneous design, multi-language support, easy to use, multi-framework compatible and high performance, the framework is ideal for transcoding, AI inference, algorithm integration, live video streaming, and more.
https://babitmf.github.io/
Apache License 2.0
809 stars 71 forks source link

VideoFrame #151

Open x850044053wwt opened 4 days ago

x850044053wwt commented 4 days ago

How to understand the pts in VideoFrame and the timestamp of Packet? I have a 30fps video.In generateMode, VideoFrame timebase 1 / 19200, pts increments 1280 or 1920, and the timestamp is always -1

JackLau1222 commented 4 days ago

First, I think the meaning of pts and timestamp in BMF is the same as in FFmpeg , but bmf_sdk::Packet is more like a general data structure, it can pack any data, so if you want to use the variable, you need to set the timestamp every time you create a bmf_sdk::Packet , so the timestamp defaults to -1.

Second, the VideoFrame is just like AVFrame in FFmpeg, this data structure is used to pack various Frame from different video frame like ffmpeg or cuda.

For example, the pts is same as AVFrame in ffmpeg_decoder and ffmpeg_encoder module. you can see the details:

> grep -r "set_pts"
...
./c_modules/src/ffmpeg_decoder.cpp:    video_frame.set_pts(frame->pts);
./c_modules/src/ffmpeg_decoder.cpp:    audio_frame.set_pts(frame->pts);
./c_modules/src/ffmpeg_decoder.cpp:        av_packet.set_pts(pkt->pts);
./c_modules/src/ffmpeg_decoder.cpp:        video_frame.set_pts(frame->pts); // sync with avframe
./c_modules/src/ffmpeg_decoder.cpp:        audio_frame.set_pts(frame->pts); // sync with avframe
./c_modules/src/ffmpeg_decoder.cpp:        bmf_av_packet.set_pts(av_packet->pts); // sync with AVPacket
./c_modules/src/ffmpeg_decoder.cpp:            bmf_pkt.set_pts((int64_t)BMF_EOF);
./c_modules/src/ffmpeg_decoder.cpp:            bmf_pkt.set_pts(BMF_EOF);
./c_modules/src/ffmpeg_filter.cpp:        video_frame.set_pts(frame->pts);
./c_modules/src/ffmpeg_filter.cpp:        audio_frame.set_pts(frame->pts);
./c_modules/src/ffmpeg_encoder.cpp:    video_frame.set_pts(frame->pts);
...