Commit 531bea6e authored by frankie's avatar frankie 💬
Browse files

correct computation of video duration (consistant w. vlc)

parent 1675579b
......@@ -389,7 +389,7 @@ void VideoStreamPlaybackGeneric::dump() {
std::cout << "\t\t" << "index: " << stream->index << std::endl;
std::cout << "\t\t" << "id: " << stream->id << std::endl;
std::cout << "\t\t" << "time_base: " << stream->time_base.num << "/" << stream->time_base.den << std::endl;
std::cout << "\t\t" << "time_base: " << avrational_to_std_string(stream->time_base).c_str() << std::endl;
std::cout << "\t\t" << "start_time: " << stream->start_time << std::endl;
std::cout << "\t\t" << "duration: " << stream->duration << std::endl;
std::cout << "\t\t" << "nb_frames: " << stream->nb_frames << std::endl;
......@@ -453,6 +453,21 @@ void VideoStreamPlaybackGeneric::dump() {
std::cout << "SwsContext (color conversion required)" << std::endl;
}
std::cout << "VideoStreamPlaybackGeneric" << std::endl;
std::cout << "\t" << "playing: " << playing << std::endl;
std::cout << "\t" << "paused: " << paused << std::endl;
std::cout << "\t" << "loop: " << loop << std::endl;
std::cout << "\t" << "loop_count: " << loop_count << std::endl;
std::cout << "\t" << "image_f_width: " << image_f_width << std::endl;
std::cout << "\t" << "image_f_height: " << image_f_height << std::endl;
std::cout << "\t" << "video_buffer_size: " << video_buffer_size << std::endl;
std::cout << "\t" << "image_buffer_size: " << image_buffer_size << std::endl;
std::cout << "\t" << "video_stream_index: " << video_stream_index << std::endl;
std::cout << "\t" << "audio_stream_index: " << audio_stream_index << std::endl;
std::cout << "\t" << "subtitle_stream_index: " << subtitle_stream_index << std::endl;
std::cout << "\t" << "duration_total: " << duration_total << std::endl;
std::cout << "\t" << "duration_frame: " << duration_frame << std::endl;
}
void VideoStreamPlaybackGeneric::set_file(const String &p_file) {
......@@ -560,6 +575,11 @@ void VideoStreamPlaybackGeneric::set_file(const String &p_file) {
return;
}
/* computation of working params */
AVStream* vid = fmt_ctx->streams[ video_stream_index ];
duration_frame = real_t(vid->r_frame_rate.num)/vid->r_frame_rate.den;
duration_total = vid->nb_frames / duration_frame;
dump();
next_video_frame();
......
......@@ -81,7 +81,6 @@ protected:
int subtitle_stream_index;
int64_t last_pts;
HashMap< AVPixelFormat, SwsContext* > scalers;
SwsContext* get_scaler( const AVPixelFormat& t );
bool prepare_image_f( const AVPixelFormat& pf, const int& width, const int& height );
......@@ -100,6 +99,9 @@ protected:
volatile bool thread_exit;
static void _streaming_thread(void *ud);
real_t duration_total; // in seconds
real_t duration_frame; // in seconds
public:
static std::string to_std_string( const String &str );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment