Skip to content
Snippets Groups Projects
Commit 53da9361 authored by Philippe Gorley's avatar Philippe Gorley
Browse files

encoder: fix recording

Recorder has multiple streams, and needs to know which streams it's
writing the packet to. Also reverts the change to a hardcoded timebase
of 1/20.

Change-Id: I75989ceafe4e4956ebb1adbbd53d13564aa942ea
parent 28938f7c
No related branches found
No related tags found
No related merge requests found
......@@ -419,7 +419,7 @@ MediaEncoder::encode(AVFrame* frame, int streamIdx)
}
if (pkt.size) {
if (send(pkt))
if (send(pkt, streamIdx))
break;
}
}
......@@ -429,15 +429,17 @@ MediaEncoder::encode(AVFrame* frame, int streamIdx)
}
bool
MediaEncoder::send(AVPacket& pkt)
MediaEncoder::send(AVPacket& pkt, int streamIdx)
{
auto streamIdx = currentStreamIdx_;
if (streamIdx < 0)
streamIdx = currentStreamIdx_;
auto encoderCtx = encoders_[streamIdx];
pkt.stream_index = streamIdx;
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(pkt.pts, AVRational{1, 20},
pkt.pts = av_rescale_q(pkt.pts, encoderCtx->time_base,
outputCtx_->streams[streamIdx]->time_base);
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts = av_rescale_q(pkt.dts, AVRational{1, 20},
pkt.dts = av_rescale_q(pkt.dts, encoderCtx->time_base,
outputCtx_->streams[streamIdx]->time_base);
// write the compressed frame
auto ret = av_write_frame(outputCtx_, &pkt);
......
......@@ -73,7 +73,7 @@ public:
void startIO();
void setIOContext(const std::unique_ptr<MediaIOHandle> &ioctx);
bool send(AVPacket& packet);
bool send(AVPacket& packet, int streamIdx = -1);
#ifdef RING_VIDEO
int encode(VideoFrame &input, bool is_keyframe, int64_t frame_number);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment