Improve:time stamp bug.
This commit is contained in:
parent
19aa5e1599
commit
da5aa894c7
|
@ -225,7 +225,7 @@ int FfmpegEncoder::EncodeData(AVFrame *frame, AVStream *stream, std::function<vo
|
|||
// LogInfo("Write stream->time_base.num: %d\n", stream->time_base.num);
|
||||
// LogInfo("Write stream->time_base.den: %d\n", stream->time_base.den);
|
||||
mTmpPkt->stream_index = stream->index;
|
||||
LogInfo("Write frame mTmpPkt->pts: %llu\n", mTmpPkt->pts);
|
||||
LogInfo("aaaaaaaaaaaaaaaaaaaaaaa Write frame mTmpPkt->pts: %llu\n", mTmpPkt->pts);
|
||||
|
||||
if (callback) {
|
||||
// save_code_stream_file(mTmpPkt->data, mTmpPkt->size);
|
||||
|
@ -355,10 +355,12 @@ AVFrame *FfmpegEncoder::ConvertAudioFrame(AVFrame *decodeFrame, struct SwrContex
|
|||
LogError("Error while converting\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mFrame->pts = av_rescale_q(decodeFrame->pts, (AVRational){1, SOURCE_AUDIO_SAMPEL_RATE}, mCodecCtx->time_base);
|
||||
LogInfo("decodeFrame->pts = %d\n", decodeFrame->pts);
|
||||
LogInfo("mFrame->pts = %d\n", mFrame->pts);
|
||||
LogInfo("mCodecCtx->time_base.num = %d, mCodecCtx->time_base.den=%d\n",
|
||||
mCodecCtx->time_base.num,
|
||||
mCodecCtx->time_base.den);
|
||||
mFrame->pts = av_rescale_q(decodeFrame->pts, (AVRational){1, 1000000}, mCodecCtx->time_base);
|
||||
// LogInfo("decodeFrame->pts = %d\n", decodeFrame->pts);
|
||||
// LogInfo("mFrame->pts = %d\n", mFrame->pts);
|
||||
mSamplesCount += dst_nb_samples;
|
||||
return mFrame;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ bool FfmpegOutputStream::Init(AVFormatContext *outputFormat)
|
|||
* @brief There is no need to set time_base here, time_base will be automatically corrected inside ffmpeg.
|
||||
*
|
||||
*/
|
||||
// mStream->time_base = (AVRational){1, 15};
|
||||
mStream->time_base = (AVRational){1, 15};
|
||||
mStream->codecpar->codec_id = AV_CODEC_ID_H264;
|
||||
mStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
mStream->codecpar->width = 1920;
|
||||
|
@ -109,8 +109,9 @@ void FfmpegOutputStream::WriteSourceData(const void *data, const size_t &size, c
|
|||
constexpr int64_t ZERO_MEANS_UNKNOWN = 0;
|
||||
tmpPkt->duration = ZERO_MEANS_UNKNOWN;
|
||||
// tmpPkt->pts = u64Interval * 1000; // ת<><D7AA><EFBFBD><EFBFBD> us
|
||||
tmpPkt->pts = av_rescale_q(pts, (AVRational){1, 15}, mStream->time_base);
|
||||
// LogInfo("pts:%llu, duration:%d\n", tmpPkt->pts, tmpPkt->duration);
|
||||
tmpPkt->pts = av_rescale_q(pts, (AVRational){1, 1000000}, mStream->time_base);
|
||||
LogInfo("vvvvvvvvvvvvvvvvvvvvvvvvv num:%d, den:%d\n", mStream->time_base.num, mStream->time_base.den);
|
||||
LogInfo("vvvvvvvvvvvvvvvvvvvvvvvvv pts:%llu, duration:%d\n", tmpPkt->pts, tmpPkt->duration);
|
||||
// tmpPkt->pts = pts;
|
||||
u64Interval++;
|
||||
tmpPkt->dts = tmpPkt->pts;
|
||||
|
|
Loading…
Reference in New Issue
Block a user