Index: ffmpeg-4.2.1/libavcodec/h261.h
===================================================================
--- ffmpeg-4.2.1.orig/libavcodec/h261.h	2018-11-01 21:34:23.000000000 +0300
+++ ffmpeg-4.2.1/libavcodec/h261.h	2019-10-25 17:46:40.350845752 +0300
@@ -35,10 +35,11 @@
  * H261Context
  */
 typedef struct H261Context {
     MpegEncContext s;
 
+    int freeze_picture_release; // 1 if freeze picture release bit is set in the picture header
     int current_mba;
     int mba_diff;
     int mtype;
     int current_mv_x;
     int current_mv_y;
Index: ffmpeg-4.2.1/libavcodec/h261dec.c
===================================================================
--- ffmpeg-4.2.1.orig/libavcodec/h261dec.c	2019-07-08 20:45:25.000000000 +0300
+++ ffmpeg-4.2.1/libavcodec/h261dec.c	2019-10-25 18:32:09.985391558 +0300
@@ -500,13 +500,13 @@ static int h261_decode_picture_header(H2
     s->picture_number = (s->picture_number & ~31) + i;
 
     s->avctx->framerate = (AVRational) { 30000, 1001 };
 
     /* PTYPE starts here */
-    skip_bits1(&s->gb); /* split screen off */
-    skip_bits1(&s->gb); /* camera  off */
-    skip_bits1(&s->gb); /* freeze picture release off */
+    skip_bits1(&s->gb); /* split screen indicator */
+    skip_bits1(&s->gb); /* document camera indicator */
+    h->freeze_picture_release = get_bits1(&s->gb); /* freeze picture release */
 
     format = get_bits1(&s->gb);
 
     // only 2 formats possible
     if (format == 0) { // QCIF
@@ -530,11 +530,12 @@ static int h261_decode_picture_header(H2
     if (skip_1stop_8data_bits(&s->gb) < 0)
         return AVERROR_INVALIDDATA;
 
     /* H.261 has no I-frames, but if we pass AV_PICTURE_TYPE_I for the first
      * frame, the codec crashes if it does not contain all I-blocks
-     * (e.g. when a packet is lost). */
+     * (e.g. when a packet is lost). We will fix the picture type in the
+     * output frame based on h->freeze_picture_release later. */
     s->pict_type = AV_PICTURE_TYPE_P;
 
     h->gob_number = 0;
     return 0;
 }
@@ -588,10 +589,11 @@ static int h261_decode_frame(AVCodecCont
     const uint8_t *buf = avpkt->data;
     int buf_size       = avpkt->size;
     H261Context *h     = avctx->priv_data;
     MpegEncContext *s  = &h->s;
     int ret;
+    enum AVPictureType pict_type;
     AVFrame *pict = data;
 
     ff_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
     ff_dlog(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
 
@@ -628,19 +630,21 @@ retry:
             return ret;
 
         goto retry;
     }
 
-    // for skipping the frame
-    s->current_picture.f->pict_type = s->pict_type;
-    s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+    // for skipping the frame and keyframe markup
+    pict_type = h->freeze_picture_release ? AV_PICTURE_TYPE_I : s->pict_type;
 
-    if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
-        (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
+    if ((avctx->skip_frame >= AVDISCARD_NONREF && pict_type == AV_PICTURE_TYPE_B) ||
+        (avctx->skip_frame >= AVDISCARD_NONKEY && pict_type != AV_PICTURE_TYPE_I) ||
          avctx->skip_frame >= AVDISCARD_ALL)
         return get_consumed_bytes(s, buf_size);
 
+    s->current_picture.f->pict_type = s->pict_type;
+    s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+
     if (ff_mpv_frame_start(s, avctx) < 0)
         return -1;
 
     ff_mpeg_er_frame_start(s);
 
@@ -658,10 +662,15 @@ retry:
     av_assert0(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type);
     av_assert0(s->current_picture.f->pict_type == s->pict_type);
 
     if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
         return ret;
+
+    // fix picture type and correctly mark keyframes
+    pict->pict_type = pict_type;
+    pict->key_frame = pict_type == AV_PICTURE_TYPE_I;
+
     ff_print_debug_info(s, s->current_picture_ptr, pict);
 
     *got_frame = 1;
 
     return get_consumed_bytes(s, buf_size);
