diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index f825500139..6a2c3d3886 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -1546,8 +1546,13 @@ gst_h264_parse_handle_frame (GstBaseParse * parse, /* expect at least 3 bytes start_code, and 1 bytes NALU header. * the length of the NALU payload can be zero. * (e.g. EOS/EOB placed at the end of an AU.) */ - if (size - current_off < 4) + if (size - current_off < 4) { + /* Finish the frame if there is no more data in the stream */ + if (drain) + break; + goto more; + } } end: diff --git a/gst/videoparsers/gsth265parse.c b/gst/videoparsers/gsth265parse.c index 26be12d390..33cb962fa7 100644 --- a/gst/videoparsers/gsth265parse.c +++ b/gst/videoparsers/gsth265parse.c @@ -1341,8 +1341,13 @@ gst_h265_parse_handle_frame (GstBaseParse * parse, /* expect at least 3 bytes start_code, and 2 bytes NALU header. * the length of the NALU payload can be zero. * (e.g. EOS/EOB placed at the end of an AU.) */ - if (G_UNLIKELY (size - current_off < 5)) + if (G_UNLIKELY (size - current_off < 5)) { + /* Finish the frame if there is no more data in the stream */ + if (drain) + break; + goto more; + } } end: