mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 19:29: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 ) {
|
if ( !video_stream_info.isimage ) {
|
||||||
video_stream_info.timeline.setEnd( gst_discoverer_info_get_duration (info) );
|
video_stream_info.timeline.setEnd( gst_discoverer_info_get_duration (info) );
|
||||||
video_stream_info.seekable = gst_discoverer_info_get_seekable (info);
|
video_stream_info.seekable = gst_discoverer_info_get_seekable (info);
|
||||||
guint frn = gst_discoverer_video_info_get_framerate_num(vinfo);
|
video_stream_info.framerate_n = gst_discoverer_video_info_get_framerate_num(vinfo);
|
||||||
guint frd = gst_discoverer_video_info_get_framerate_denom(vinfo);
|
video_stream_info.framerate_d = gst_discoverer_video_info_get_framerate_denom(vinfo);
|
||||||
if (frn == 0 || frd == 0) {
|
if (video_stream_info.framerate_n == 0 || video_stream_info.framerate_d == 0) {
|
||||||
frn = 25;
|
video_stream_info.framerate_n = 25;
|
||||||
frd = 1;
|
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>(video_stream_info.framerate_d)) / (static_cast<guint64>(video_stream_info.framerate_n)) );
|
||||||
video_stream_info.timeline.setStep( (GST_SECOND * static_cast<guint64>(frd)) / (static_cast<guint64>(frn)) );
|
|
||||||
}
|
}
|
||||||
// try to fill-in the codec information
|
// try to fill-in the codec information
|
||||||
GstCaps *caps = gst_discoverer_stream_info_get_caps (tmpinf);
|
GstCaps *caps = gst_discoverer_stream_info_get_caps (tmpinf);
|
||||||
@@ -223,7 +222,17 @@ void MediaPlayer::execute_open()
|
|||||||
string description = "uridecodebin uri=" + uri_ + " ! ";
|
string description = "uridecodebin uri=" + uri_ + " ! ";
|
||||||
if (media_.interlaced)
|
if (media_.interlaced)
|
||||||
description += "deinterlace method=2 ! ";
|
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
|
// parse pipeline descriptor
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -938,7 +947,7 @@ std::string MediaPlayer::filename() const
|
|||||||
|
|
||||||
double MediaPlayer::frameRate() 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
|
double MediaPlayer::updateFrameRate() const
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ struct MediaInfo {
|
|||||||
guint par_width; // width to match pixel aspect ratio
|
guint par_width; // width to match pixel aspect ratio
|
||||||
guint height;
|
guint height;
|
||||||
guint bitrate;
|
guint bitrate;
|
||||||
gdouble framerate;
|
guint framerate_n;
|
||||||
|
guint framerate_d;
|
||||||
std::string codec_name;
|
std::string codec_name;
|
||||||
bool isimage;
|
bool isimage;
|
||||||
bool interlaced;
|
bool interlaced;
|
||||||
@@ -38,7 +39,8 @@ struct MediaInfo {
|
|||||||
width = par_width = 640;
|
width = par_width = 640;
|
||||||
height = 480;
|
height = 480;
|
||||||
bitrate = 0;
|
bitrate = 0;
|
||||||
framerate = 0.0;
|
framerate_n = 1;
|
||||||
|
framerate_d = 25;
|
||||||
codec_name = "unknown";
|
codec_name = "unknown";
|
||||||
isimage = false;
|
isimage = false;
|
||||||
interlaced = false;
|
interlaced = false;
|
||||||
@@ -56,7 +58,8 @@ struct MediaInfo {
|
|||||||
this->par_width = b.par_width;
|
this->par_width = b.par_width;
|
||||||
this->height = b.height;
|
this->height = b.height;
|
||||||
this->bitrate = b.bitrate;
|
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->codec_name = b.codec_name;
|
||||||
this->valid = b.valid;
|
this->valid = b.valid;
|
||||||
this->isimage = b.isimage;
|
this->isimage = b.isimage;
|
||||||
|
|||||||
@@ -707,23 +707,6 @@ void UserInterface::NewFrame()
|
|||||||
fileDialogPending_ = false;
|
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
|
// overlay to ensure file dialog is modal
|
||||||
if (fileDialogPending_){
|
if (fileDialogPending_){
|
||||||
@@ -741,20 +724,6 @@ void UserInterface::NewFrame()
|
|||||||
|
|
||||||
void UserInterface::Render()
|
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
|
// warning modal dialog
|
||||||
Log::Render();
|
Log::Render();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user