@@ -124,14 +124,15 @@ geode::Result<> Recorder::init(const RenderSettings& settings) {
124
124
125
125
int inputPixelFormat = (int )settings.m_pixelFormat ;
126
126
127
- if (!settings.m_colorspaceFilters .empty ()) {
127
+ if (!settings.m_colorspaceFilters .empty () || settings. m_doVerticalFlip ) {
128
128
m_filterGraph = avfilter_graph_alloc ();
129
129
if (!m_filterGraph)
130
130
return geode::Err (" Could not allocate filter graph." );
131
131
132
132
const AVFilter* buffersrc = avfilter_get_by_name (" buffer" );
133
133
const AVFilter* buffersink = avfilter_get_by_name (" buffersink" );
134
134
const AVFilter* colorspace = avfilter_get_by_name (" colorspace" );
135
+ const AVFilter* vflip = avfilter_get_by_name (" vflip" );
135
136
136
137
char args[512 ];
137
138
snprintf (args, sizeof (args),
@@ -150,19 +151,38 @@ geode::Result<> Recorder::init(const RenderSettings& settings) {
150
151
return geode::Err (" Could not create output for filter graph: " + utils::getErrorString (ret));
151
152
}
152
153
153
- if (ret = avfilter_graph_create_filter (&m_colorspaceCtx, colorspace, " colorspace" , settings.m_colorspaceFilters .c_str (), nullptr , m_filterGraph); ret < 0 ) {
154
- avfilter_graph_free (&m_filterGraph);
155
- return geode::Err (" Could not create colorspace for filter graph: " + utils::getErrorString (ret));
154
+ if (!settings.m_colorspaceFilters .empty ()) {
155
+ if (ret = avfilter_graph_create_filter (&m_colorspaceCtx, colorspace, " colorspace" , settings.m_colorspaceFilters .c_str (), nullptr , m_filterGraph); ret < 0 ) {
156
+ avfilter_graph_free (&m_filterGraph);
157
+ return geode::Err (" Could not create colorspace for filter graph: " + utils::getErrorString (ret));
158
+ }
159
+
160
+ if (ret = avfilter_link (m_buffersrcCtx, 0 , m_colorspaceCtx, 0 ); ret < 0 ) {
161
+ avfilter_graph_free (&m_filterGraph);
162
+ return geode::Err (" Could not link filters: " + utils::getErrorString (ret));
163
+ }
164
+
165
+ if (ret = avfilter_link (m_colorspaceCtx, 0 , m_buffersinkCtx, 0 ); ret < 0 ) {
166
+ avfilter_graph_free (&m_filterGraph);
167
+ return geode::Err (" Could not link filters: " + utils::getErrorString (ret));
168
+ }
156
169
}
157
170
158
- if (ret = avfilter_link (m_buffersrcCtx, 0 , m_colorspaceCtx, 0 ); ret < 0 ) {
159
- avfilter_graph_free (&m_filterGraph);
160
- return geode::Err (" Could not link filters: " + utils::getErrorString (ret));
161
- }
162
-
163
- if (ret = avfilter_link (m_colorspaceCtx, 0 , m_buffersinkCtx, 0 ); ret < 0 ) {
164
- avfilter_graph_free (&m_filterGraph);
165
- return geode::Err (" Could not link filters: " + utils::getErrorString (ret));
171
+ if (settings.m_doVerticalFlip ) {
172
+ if (ret = avfilter_graph_create_filter (&m_vflipCtx, vflip, " vflip" , nullptr , nullptr , m_filterGraph); ret < 0 ) {
173
+ avfilter_graph_free (&m_filterGraph);
174
+ return geode::Err (" Could not create vflip for filter graph: " + utils::getErrorString (ret));
175
+ }
176
+
177
+ if (ret = avfilter_link (m_buffersrcCtx, 0 , m_vflipCtx, 0 ); ret < 0 ) {
178
+ avfilter_graph_free (&m_filterGraph);
179
+ return geode::Err (" Could not link filters: " + utils::getErrorString (ret));
180
+ }
181
+
182
+ if (ret = avfilter_link (m_vflipCtx, 0 , m_buffersinkCtx, 0 ); ret < 0 ) {
183
+ avfilter_graph_free (&m_filterGraph);
184
+ return geode::Err (" Could not link filters: " + utils::getErrorString (ret));
185
+ }
166
186
}
167
187
168
188
if (ret = avfilter_graph_config (m_filterGraph, nullptr ); ret < 0 ) {
0 commit comments