----- On Mar 6, 2020, at 12:55 AM, Andreas Rheinhardt andreas.rheinha...@gmail.com wrote:
> Hongcheng Zhong: >> ----- On Mar 5, 2020, at 11:38 PM, lq l...@chinaffmpeg.org wrote: >> >>>> 2020年3月5日 下午9:41,Hongcheng Zhong <sj.hc_zh...@sjtu.edu.cn> 写道: >>>> >>>> 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_zh...@sjtu.edu.cn> >>>> --- >>>> libavformat/hlsenc.c | 10 +++++++++- >>>> 1 file changed, 9 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >>>> index f6dd894..3b2434f 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,9 +2275,15 @@ 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) { >>>> + if (vs->has_video) { >>> What’s happen with this line? >>>> can_split = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && >>>> ((pkt->flags & AV_PKT_FLAG_KEY) || (hls->flags & >>>> HLS_SPLIT_BY_TIME)); >>>> is_ref_pkt = (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && >>>> (pkt->stream_index == vs->reference_stream_index); >>>> @@ -2751,6 +2758,7 @@ static int hls_init(AVFormatContext *s) >>>> vs->sequence = hls->start_sequence; >>>> vs->start_pts = AV_NOPTS_VALUE; >>>> vs->end_pts = AV_NOPTS_VALUE; >>>> + vs->start_pts_from_audio = 0; >>>> vs->current_segment_final_filename_fmt[0] = '\0'; >>>> >>>> if (hls->flags & HLS_SPLIT_BY_TIME && hls->flags & >>>> HLS_INDEPENDENT_SEGMENTS) { >>>> -- >>>> 2.7.4 >>>> >>>> _______________________________________________ >>>> ffmpeg-devel mailing list >>>> ffmpeg-devel@ffmpeg.org >>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>>> >>>> To unsubscribe, visit link above, or email >>>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >> >> Actually, this line is useless because that vs is initialized as all zero. >> Should I remove this line and submit this patch as v2 again? Thanks for your >> reply. > > But vs->has_video is initialized to a potentially nonzero value in > hls_init(). > > - Andreas > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". I write that line to make sure that vs->start_pts_from_audio is initialized as 0. Since `hls->var_streams = av_mallocz(sizeof(*hls->var_streams) * nb_varstreams);` in hlsenc.c: 1897, var_streams is allocated with av_mallocz(), that line is not necessary. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".