[FFmpeg-cvslog] avformat/hlsenc: Fix initial setting for start_pts
Hongcheng Zhong
git at videolan.org
Thu Mar 12 07:05:48 EET 2020
ffmpeg | branch: master | Hongcheng Zhong <sj.hc_Zhong at sjtu.edu.cn> | Fri Mar 6 11:58:22 2020 +0800| [5c72bb62a97fa6ae407ca55184fc0519e641f727] | committer: Steven Liu
avformat/hlsenc: Fix initial setting for start_pts
This patch fixes Bug #8469
If x264 baseline profile is used with other profiles,
start_pts will be initialized to audio stream's first pts,
while the duration is calculated based on video stream's pts.
In this patch the start_pts is initialized with the correct stream's first pts.
Signed-off-by: Hongcheng Zhong <sj.hc_Zhong at sjtu.edu.cn>
Reviewed-by: Steven Liu <liuqi05 at kuaishou.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c72bb62a97fa6ae407ca55184fc0519e641f727
---
libavformat/hlsenc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f6dd894343..19aa2b1208 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -126,6 +126,7 @@ typedef struct VariantStream {
int has_video;
int has_subtitle;
int new_start;
+ int start_pts_from_audio;
double dpp; // duration per packet
int64_t start_pts;
int64_t end_pts;
@@ -2274,6 +2275,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
if (vs->start_pts == AV_NOPTS_VALUE) {
vs->start_pts = pkt->pts;
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
+ vs->start_pts_from_audio = 1;
+ }
+ if (vs->start_pts_from_audio && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && vs->start_pts > pkt->pts) {
+ vs->start_pts = pkt->pts;
+ vs->start_pts_from_audio = 0;
}
if (vs->has_video) {
More information about the ffmpeg-cvslog
mailing list