initialize video_first_pts and when setting it need to specify microseconds otherwise we get nanoseconds. White space.
This commit is contained in:
parent
1cb9f98e9b
commit
30fa641186
|
@ -231,8 +231,8 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
|
|||
zm_packet->set_packet(&packet);
|
||||
zm_packet->stream = stream;
|
||||
zm_packet->pts = av_rescale_q(packet.pts, stream->time_base, AV_TIME_BASE_Q);
|
||||
if ( packet.pts != AV_NOPTS_VALUE ) {
|
||||
if ( stream == mVideoStream ) {
|
||||
if (packet.pts != AV_NOPTS_VALUE) {
|
||||
if (stream == mVideoStream) {
|
||||
if (mFirstVideoPTS == AV_NOPTS_VALUE)
|
||||
mFirstVideoPTS = packet.pts;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ ZMPacket::ZMPacket(ZMPacket &p) :
|
|||
av_init_packet(&packet);
|
||||
packet.size = 0;
|
||||
packet.data = nullptr;
|
||||
if ( zm_av_packet_ref(&packet, &p.packet) < 0 ) {
|
||||
if (zm_av_packet_ref(&packet, &p.packet) < 0) {
|
||||
Error("error refing packet");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class ZMPacket {
|
|||
Image *set_image(Image *);
|
||||
|
||||
int is_keyframe() { return keyframe; };
|
||||
int decode( AVCodecContext *ctx );
|
||||
int decode(AVCodecContext *ctx);
|
||||
explicit ZMPacket(Image *image, SystemTimePoint tv);
|
||||
explicit ZMPacket(ZMPacket &packet);
|
||||
ZMPacket();
|
||||
|
@ -88,6 +88,7 @@ class ZMLockedPacket {
|
|||
lck_(packet_->mutex_, std::defer_lock),
|
||||
locked(false) {
|
||||
}
|
||||
|
||||
~ZMLockedPacket() {
|
||||
if (locked) unlock();
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ VideoStore::VideoStore(
|
|||
converted_in_samples(nullptr),
|
||||
filename(filename_in),
|
||||
format(format_in),
|
||||
video_first_pts(0),
|
||||
video_first_dts(0),
|
||||
audio_first_pts(0),
|
||||
audio_first_dts(0),
|
||||
|
@ -990,23 +991,24 @@ int VideoStore::writeVideoFramePacket(const std::shared_ptr<ZMPacket> &zm_packet
|
|||
frame->pkt_duration = 0;
|
||||
|
||||
if (!video_first_pts) {
|
||||
video_first_pts = zm_packet->timestamp.time_since_epoch().count();
|
||||
video_first_pts = static_cast<int64>(std::chrono::duration_cast<Microseconds>(zm_packet->timestamp.time_since_epoch()).count());
|
||||
Debug(2, "No video_first_pts, set to (%" PRId64 ") secs(%.2f)",
|
||||
video_first_pts,
|
||||
FPSeconds(zm_packet->timestamp.time_since_epoch()).count());
|
||||
|
||||
frame->pts = 0;
|
||||
} else {
|
||||
|
||||
Microseconds useconds = std::chrono::duration_cast<Microseconds>(
|
||||
zm_packet->timestamp - SystemTimePoint(Microseconds(video_first_pts)));
|
||||
frame->pts = av_rescale_q(useconds.count(), AV_TIME_BASE_Q, video_out_ctx->time_base);
|
||||
Debug(2,
|
||||
"Setting pts for frame(%d) to (%" PRId64 ") from (start %" PRIu64 " - %" PRIu64 " - us(%" PRIi64 ") @ %d/%d",
|
||||
"Setting pts for frame(%d) to (%" PRId64 ") from (zm_packet->timestamp(%" PRIi64 " - first %" PRId64 " us %" PRId64 " ) @ %d/%d",
|
||||
frame_count,
|
||||
frame->pts,
|
||||
static_cast<int64>(std::chrono::duration_cast<Microseconds>(zm_packet->timestamp.time_since_epoch()).count()),
|
||||
video_first_pts,
|
||||
static_cast<int64>(std::chrono::duration_cast<Microseconds>(useconds).count()),
|
||||
static_cast<int64>(std::chrono::duration_cast<Microseconds>(zm_packet->timestamp.time_since_epoch()).count()),
|
||||
video_out_ctx->time_base.num,
|
||||
video_out_ctx->time_base.den);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue