diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
index 2ca6a0549712c8ae4f780570ae3e72c7d151b933..1985bc5f86527f74fab06fd990d74eb2ffb5590b 100644
--- a/doc/examples/filtering_video.c
+++ b/doc/examples/filtering_video.c
@@ -198,9 +198,8 @@ int main(int argc, char **argv)
             }
 
             if (got_frame) {
-                if (frame.pts == AV_NOPTS_VALUE)
-                    frame.pts = frame.pkt_dts == AV_NOPTS_VALUE ?
-                        frame.pkt_dts : frame.pkt_pts;
+                frame.pts = av_frame_get_best_effort_timestamp(&frame);
+
                 /* push the decoded frame into the filtergraph */
                 av_vsrc_buffer_add_frame(buffersrc_ctx, &frame, 0);