-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pasue事件实现效果不好;
- Loading branch information
Showing
29 changed files
with
652 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1 @@ | ||
#include "decoder.h" | ||
#include "frame.hpp" | ||
#include "packet.h" | ||
|
||
extern "C" { | ||
#include <libavformat/avformat.h> | ||
} | ||
|
||
namespace Ffmpeg { | ||
|
||
void calculatePts(Frame *frame, AVContextInfo *contextInfo, FormatContext *formatContext) | ||
{ | ||
auto tb = contextInfo->stream()->time_base; | ||
auto frame_rate = formatContext->guessFrameRate(contextInfo->stream()); | ||
// 当前帧播放时长 | ||
auto duration = (frame_rate.num && frame_rate.den | ||
? av_q2d(AVRational{frame_rate.den, frame_rate.num}) | ||
: 0); | ||
// 当前帧显示时间戳 | ||
auto *avFrame = frame->avFrame(); | ||
auto pts = (avFrame->pts == AV_NOPTS_VALUE) ? NAN : avFrame->pts * av_q2d(tb); | ||
frame->setDuration(duration * AV_TIME_BASE); | ||
frame->setPts(pts * AV_TIME_BASE); | ||
// qDebug() << "Frame duration:" << duration << "pts:" << pts << "tb:" << tb.num << tb.den | ||
// << "frame_rate:" << frame_rate.num << frame_rate.den; | ||
} | ||
|
||
void calculatePts(Packet *packet, AVContextInfo *contextInfo) | ||
{ | ||
auto tb = contextInfo->stream()->time_base; | ||
// 当前帧播放时长 | ||
auto *avPacket = packet->avPacket(); | ||
auto duration = avPacket->duration * av_q2d(tb); | ||
// 当前帧显示时间戳 | ||
auto pts = (avPacket->pts == AV_NOPTS_VALUE) ? NAN : avPacket->pts * av_q2d(tb); | ||
packet->setDuration(duration * AV_TIME_BASE); | ||
packet->setPts(pts * AV_TIME_BASE); | ||
// qDebug() << "Packet duration:" << duration << "pts:" << pts << "tb:" << tb.num << tb.den; | ||
} | ||
|
||
} // namespace Ffmpeg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.