* Merged read_fps code from 2.0 to 2.1 for correctly detecting framerate.
* Changed logging of execution of AMCP commands.
void decode_next_frame()
{
for(int n = 0; n < 8 && muxer_.empty(); ++n)
- {
+ {
if(!muxer_.video_ready())
muxer_.push_video(video_decoder_ ? (*video_decoder_)() : create_frame());
if(!muxer_.audio_ready())
size_type size() const
{
- return index_ != -1 ? packets_.size() : std::numeric_limits<size_type>::max();
+ return index_ > -1 ? packets_.size() : std::numeric_limits<size_type>::max();
}
};
}
}
- auto stream = format_context_->streams[default_stream_index_];
- auto codec = stream->codec;
- auto fixed_target = (target*stream->time_base.den*codec->time_base.num)/(stream->time_base.num*codec->time_base.den)*codec->ticks_per_frame;
+ auto stream = format_context_->streams[default_stream_index_];
+ auto fps = read_fps(*format_context_, 0.0);
- THROW_ON_ERROR2(avformat_seek_file(format_context_.get(), default_stream_index_, std::numeric_limits<int64_t>::min(), fixed_target, fixed_target, 0), print());
+ THROW_ON_ERROR2(avformat_seek_file(
+ format_context_.get(),
+ default_stream_index_,
+ std::numeric_limits<int64_t>::min(),
+ static_cast<int64_t>((target / fps * stream->time_base.den) / stream->time_base.num),
+ std::numeric_limits<int64_t>::max(),
+ 0), print());
video_stream_.push(nullptr);
audio_stream_.push(nullptr);
{
const auto video_context = context.streams[video_index]->codec;
const auto video_stream = context.streams[video_index];
-
+
+ auto frame_rate_time_base = video_stream->avg_frame_rate;
+ std::swap(frame_rate_time_base.num, frame_rate_time_base.den);
+
+ if (is_sane_fps(frame_rate_time_base))
+ {
+ return static_cast<double>(frame_rate_time_base.den) / static_cast<double>(frame_rate_time_base.num);
+ }
+
AVRational time_base = video_context->time_base;
if(boost::filesystem::path(context.filename).extension().string() == ".flv")
return nullptr;
auto stream_time_base = stream_->time_base;
- auto packet_frame_number = static_cast<uint32_t>((static_cast<double>(pkt.pts * stream_time_base.num)/stream_time_base.den)*fps_);
+ auto packet_frame_number = static_cast<uint32_t>((static_cast<double>(pkt.pts * stream_time_base.num) / stream_time_base.den) * fps_);
file_frame_number_ = packet_frame_number;
{
try
{
- caspar::timer timer;
-
try
{
+ caspar::timer timer;
+
auto print = pCurrentCommand->print();
auto params = boost::join(pCurrentCommand->parameters(), L" ");
}
if (pCurrentCommand->Execute())
- CASPAR_LOG(debug) << "Executed command: " << print << " " << timer.elapsed();
+ CASPAR_LOG(debug) << "Executed command (" << timer.elapsed() << "s): " << print;
else
- CASPAR_LOG(warning) << "Failed to execute command: " << print << " " << timer.elapsed();
+ CASPAR_LOG(warning) << "Failed to execute command: " << print;
}
catch (file_not_found&)
{
catch (...)
{
CASPAR_LOG_CURRENT_EXCEPTION();
- CASPAR_LOG(warning) << "Failed to execute command:" << pCurrentCommand->print() << " " << timer.elapsed();
+ CASPAR_LOG(warning) << "Failed to execute command:" << pCurrentCommand->print();
pCurrentCommand->SetReplyString(L"501 " + pCurrentCommand->print() + L" FAILED\r\n");
}