From 4cd735f61d187c57581576d49ff8b5d67c600e85 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 2 Jun 2024 13:34:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E7=A0=81H264=E6=97=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=97=B6=E9=97=B4=E6=88=B3=E9=80=8F=E4=BC=A0=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E6=88=B3=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Codec/H264Encoder.cpp | 2 ++ src/Codec/H264Encoder.h | 3 +++ src/Common/Device.cpp | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Codec/H264Encoder.cpp b/src/Codec/H264Encoder.cpp index 92ac2a39..414eb5f1 100644 --- a/src/Codec/H264Encoder.cpp +++ b/src/Codec/H264Encoder.cpp @@ -321,6 +321,8 @@ int H264Encoder::inputData(char *yuv[3], int linesize[3], int64_t cts, H264Frame _aFrames[i].iType = pNal.i_type; _aFrames[i].iLength = pNal.i_payload; _aFrames[i].pucData = pNal.p_payload; + _aFrames[i].dts = _pPicOut->i_dts; + _aFrames[i].pts = _pPicOut->i_pts; } *out_frame = _aFrames; return iNal; diff --git a/src/Codec/H264Encoder.h b/src/Codec/H264Encoder.h index 46c86150..8906c269 100644 --- a/src/Codec/H264Encoder.h +++ b/src/Codec/H264Encoder.h @@ -27,6 +27,9 @@ public: int iType; int iLength; uint8_t *pucData; + + int64_t dts; + int64_t pts; } H264Frame; H264Encoder(); diff --git a/src/Common/Device.cpp b/src/Common/Device.cpp index 9b652911..2d424091 100644 --- a/src/Common/Device.cpp +++ b/src/Common/Device.cpp @@ -39,7 +39,7 @@ bool DevChannel::inputYUV(char *yuv[3], int linesize[3], uint64_t cts) { int frames = _pH264Enc->inputData(yuv, linesize, cts, &out_frames); bool ret = false; for (int i = 0; i < frames; i++) { - ret = inputH264((char *) out_frames[i].pucData, out_frames[i].iLength, cts) ? true : ret; + ret = inputH264((char *) out_frames[i].pucData, out_frames[i].iLength, out_frames[i].dts, out_frames[i].pts) ? true : ret; } return ret; }