mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Fixed loading and playing of GIF animation
This commit is contained in:
@@ -138,14 +138,13 @@ static MediaInfo UriDiscoverer_(std::string uri)
|
||||
if ( !video_stream_info.isimage ) {
|
||||
video_stream_info.timeline.setEnd( gst_discoverer_info_get_duration (info) );
|
||||
video_stream_info.seekable = gst_discoverer_info_get_seekable (info);
|
||||
guint frn = gst_discoverer_video_info_get_framerate_num(vinfo);
|
||||
guint frd = gst_discoverer_video_info_get_framerate_denom(vinfo);
|
||||
if (frn == 0 || frd == 0) {
|
||||
frn = 25;
|
||||
frd = 1;
|
||||
video_stream_info.framerate_n = gst_discoverer_video_info_get_framerate_num(vinfo);
|
||||
video_stream_info.framerate_d = gst_discoverer_video_info_get_framerate_denom(vinfo);
|
||||
if (video_stream_info.framerate_n == 0 || video_stream_info.framerate_d == 0) {
|
||||
video_stream_info.framerate_n = 25;
|
||||
video_stream_info.framerate_d = 1;
|
||||
}
|
||||
video_stream_info.framerate = static_cast<double>(frn) / static_cast<double>(frd);
|
||||
video_stream_info.timeline.setStep( (GST_SECOND * static_cast<guint64>(frd)) / (static_cast<guint64>(frn)) );
|
||||
video_stream_info.timeline.setStep( (GST_SECOND * static_cast<guint64>(video_stream_info.framerate_d)) / (static_cast<guint64>(video_stream_info.framerate_n)) );
|
||||
}
|
||||
// try to fill-in the codec information
|
||||
GstCaps *caps = gst_discoverer_stream_info_get_caps (tmpinf);
|
||||
@@ -223,7 +222,17 @@ void MediaPlayer::execute_open()
|
||||
string description = "uridecodebin uri=" + uri_ + " ! ";
|
||||
if (media_.interlaced)
|
||||
description += "deinterlace method=2 ! ";
|
||||
description += "videoconvert chroma-resampler=2 n-threads=2 ! appsink name=sink";
|
||||
description += "videoconvert chroma-resampler=2 n-threads=2 ! ";
|
||||
|
||||
// hack to compensate for lack of PTS in gif animations
|
||||
if (media_.codec_name.compare("image/gst-libav-gif") == 0){
|
||||
description += "videorate ! video/x-raw,framerate=";
|
||||
description += std::to_string(media_.framerate_n) + "/";
|
||||
description += std::to_string(media_.framerate_d) + " ! ";
|
||||
}
|
||||
|
||||
// set app sink
|
||||
description += "appsink name=sink";
|
||||
|
||||
// parse pipeline descriptor
|
||||
GError *error = NULL;
|
||||
@@ -938,7 +947,7 @@ std::string MediaPlayer::filename() const
|
||||
|
||||
double MediaPlayer::frameRate() const
|
||||
{
|
||||
return media_.framerate;
|
||||
return static_cast<double>(media_.framerate_n) / static_cast<double>(media_.framerate_d);;
|
||||
}
|
||||
|
||||
double MediaPlayer::updateFrameRate() const
|
||||
|
||||
@@ -27,7 +27,8 @@ struct MediaInfo {
|
||||
guint par_width; // width to match pixel aspect ratio
|
||||
guint height;
|
||||
guint bitrate;
|
||||
gdouble framerate;
|
||||
guint framerate_n;
|
||||
guint framerate_d;
|
||||
std::string codec_name;
|
||||
bool isimage;
|
||||
bool interlaced;
|
||||
@@ -38,7 +39,8 @@ struct MediaInfo {
|
||||
width = par_width = 640;
|
||||
height = 480;
|
||||
bitrate = 0;
|
||||
framerate = 0.0;
|
||||
framerate_n = 1;
|
||||
framerate_d = 25;
|
||||
codec_name = "unknown";
|
||||
isimage = false;
|
||||
interlaced = false;
|
||||
@@ -56,7 +58,8 @@ struct MediaInfo {
|
||||
this->par_width = b.par_width;
|
||||
this->height = b.height;
|
||||
this->bitrate = b.bitrate;
|
||||
this->framerate = b.framerate;
|
||||
this->framerate_n = b.framerate_n;
|
||||
this->framerate_d = b.framerate_d;
|
||||
this->codec_name = b.codec_name;
|
||||
this->valid = b.valid;
|
||||
this->isimage = b.isimage;
|
||||
|
||||
@@ -707,23 +707,6 @@ void UserInterface::NewFrame()
|
||||
fileDialogPending_ = false;
|
||||
}
|
||||
}
|
||||
// if (sessionFileDialogLoadFinished_) {
|
||||
// sessionFileDialogLoadFinished_ = false;
|
||||
// if (!sessionFileDialogFilename_.empty()) {
|
||||
// if (sessionFileDialogImport_)
|
||||
// Mixer::manager().import(sessionFileDialogFilename_);
|
||||
// else
|
||||
// Mixer::manager().open(sessionFileDialogFilename_);
|
||||
// Settings::application.recentSessions.path = SystemToolkit::path_filename(sessionFileDialogFilename_);
|
||||
// }
|
||||
// }
|
||||
// if (sessionFileDialogSaveFinished_) {
|
||||
// sessionFileDialogSaveFinished_ = false;
|
||||
// if (!sessionFileDialogFilename_.empty()) {
|
||||
// Mixer::manager().saveas(sessionFileDialogFilename_);
|
||||
// Settings::application.recentSessions.path = SystemToolkit::path_filename(sessionFileDialogFilename_);
|
||||
// }
|
||||
// }
|
||||
|
||||
// overlay to ensure file dialog is modal
|
||||
if (fileDialogPending_){
|
||||
@@ -741,20 +724,6 @@ void UserInterface::NewFrame()
|
||||
|
||||
void UserInterface::Render()
|
||||
{
|
||||
// ImVec2 geometry(static_cast<float>(Rendering::manager().Width()), static_cast<float>(Rendering::manager().Height()));
|
||||
// // file modal dialog
|
||||
// geometry.x *= 0.4f;
|
||||
// geometry.y *= 0.4f;
|
||||
// if ( !currentFileDialog.empty() && FileDialog::Instance()->Render(currentFileDialog.c_str(), geometry)) {
|
||||
// if (FileDialog::Instance()->IsOk == true) {
|
||||
// std::string filePathNameText = FileDialog::Instance()->GetFilepathName();
|
||||
// // done
|
||||
// currentFileDialog = "";
|
||||
// }
|
||||
// FileDialog::Instance()->CloseDialog(currentFileDialog.c_str());
|
||||
// }
|
||||
// FileDialog::RenderCurrent();
|
||||
|
||||
// warning modal dialog
|
||||
Log::Render();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user