BugFix MediaPlayer support for GIF animation

Playbin needs a videorate video filter, and thus user cannot change the video effect on a GIF
This commit is contained in:
Bruno Herbelin
2023-08-09 12:11:15 +02:00
parent c2a0e51984
commit 1d329600af
3 changed files with 9 additions and 3 deletions

View File

@@ -68,6 +68,7 @@ MediaPlayer::MediaPlayer()
rate_change_ = RATE_CHANGE_NONE;
decoder_name_ = "";
video_filter_ = "";
video_filter_available_ = true;
position_ = GST_CLOCK_TIME_NONE;
loop_ = LoopMode::LOOP_REWIND;
@@ -346,8 +347,10 @@ void MediaPlayer::execute_open()
g_object_set( G_OBJECT (pipeline_), "flags", flags, NULL);
// hack to compensate for lack of PTS in gif animations
if (media_.codec_name.compare("image/gst-libav-gif") == 0)
video_filter_ = "videorate";
if (media_.codec_name.compare("image/gst-libav-gif") == 0) {
video_filter_ = "videorate rate=1.0";
video_filter_available_ = false;
}
// Add a filter to playbin if provided
if ( !video_filter_.empty()) {

View File

@@ -258,6 +258,7 @@ public:
* */
void setVideoEffect(const std::string &pipeline_element);
inline std::string videoEffect() { return video_filter_; }
inline bool videoEffectAvailable() { return video_filter_available_; }
/**
* Accept visitors
* */
@@ -302,6 +303,7 @@ private:
bool rewind_on_disable_;
bool force_software_decoding_;
std::string decoder_name_;
bool video_filter_available_;
std::string video_filter_;
// Play speed

View File

@@ -376,7 +376,8 @@ void SourceControlWindow::Render()
{
if (ImGui::MenuItem( ICON_FA_REDO_ALT " Reload" ))
mediaplayer_active_->reopen();
if (ImGuiToolkit::MenuItemIcon(16, 16, "Gstreamer effect") )
if (ImGuiToolkit::MenuItemIcon(16, 16, "Gstreamer effect", nullptr,
false, mediaplayer_active_->videoEffectAvailable()) )
mediaplayer_edit_pipeline_ = true;
if (ImGui::BeginMenu(ICON_FA_SNOWFLAKE " On deactivation"))
{