admin 管理员组文章数量: 1184232
2024年4月24日发(作者:数据库exists)
do {
double segment_time = 0.0;
AVPacket packet;
double packetStartTime = 0.0;
double packetDuration = 0.0;
if (!decode_done)
{
decode_done = av_read_frame(ic, &packet);
if (!decode_done)
{
if (_index != video_index &&
_index != audio_index)
{
av_free_packet(&packet);
continue;
}
timeStamp =
(double)() *
(double)(ic->streams[_index]->time_) /
(double)(ic->streams[_index]->time_);
if (av_dup_packet(&packet) < 0)
{
fprintf(stderr, "Could not duplicate packetn");
av_free_packet(&packet);
break;
}
insertPacket(streamLace, &packet, timeStamp);
}
}
if (countPackets(streamLace) < 50 && !decode_done)
{
/* allow the queue to fill up so that the packets can be sorted properly */
continue;
}
if (!removePacket(streamLace, &packet))
{
if (decode_done)
{
/* the queue is empty, we are done */
break;
}
assert(decode_done);
continue;
}
packetStartTime =
(double)() *
(double)(ic->streams[_index]->time_) /
(double)(ic->streams[_index]->time_);
packetDuration =
(double)(on) *
(double)(ic->streams[_index]->time_) /
(double)(ic->streams[_index]->time_);
#if !defined(NDEBUG) && (defined(DEBUG) || defined(_DEBUG))
if (av_log_get_level() >= AV_LOG_VERBOSE)
fprintf(stderr,
"stream %i, packet [%f, %f)n",
_index,
packetStartTime,
packetStartTime + packetDuration);
#endif
segment_duration = packetStartTime + packetDuration - prev_segment_time;
// NOTE: segments are supposed to start on a keyframe.
// If the keyframe interval and segment duration do not match
// forcing the segment creation for "better seeking behavior"
// will result in decoding artifacts after seeking or stream switching.
if (_index == video_index && ( & AV_PKT_FLAG_KEY || strict_segment_duration)) {
segment_time = packetStartTime;
}
else if (video_index < 0) {
segment_time = packetStartTime;
}
else {
版权声明:本文标题:HLS(HTTPLiveStreaming)协议之m3u8文件生成方式 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1713969065a659814.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论