History

examples/decode_filter_video: Add loop for draining the filtergraph

Depending on the filters used, the filtergraph may produce trailing data after feeding it the last input frame. Update the example to include the necessary loop for draining the filtergraph.

Tobias Rapp committed 2 years ago

Commit 02eb2fc1 parent 55ce6661 file · +19 −0Browse files

Unified · Split

doc/examples/decode_filter_video.c+19−0
@@ -276,6 +276,25 @@ int main(int argc, char **argv) · 275 unmodified lines
276276 }
277277 av_packet_unref(packet);
278278 }
279+ if (ret == AVERROR_EOF) {
280+ /* signal EOF to the filtergraph */
281+ if (av_buffersrc_add_frame_flags(buffersrc_ctx, NULL, 0) < 0) {
282+ av_log(NULL, AV_LOG_ERROR, "Error while closing the filtergraph\n");
283+ goto end;
284+ }
285+
286+ /* pull remaining frames from the filtergraph */
287+ while (1) {
288+ ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
289+ if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
290+ break;
291+ if (ret < 0)
292+ goto end;
293+ display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
294+ av_frame_unref(filt_frame);
295+ }
296+ }
297+
279298 end:
280299 avfilter_graph_free(&filter_graph);
281300 avcodec_free_context(&dec_ctx);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t