diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 7d348d23382c0a4b2d26c13aec6fe166a93ee8e7..da43f1e4575097df2d2d2814b3088fb766650a26 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1104,8 +1104,12 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
     h->x264_build   = -1;
     ff_h264_reset_sei(h);
     if (avctx->codec_id == AV_CODEC_ID_H264) {
-        if (avctx->ticks_per_frame == 1)
-            s->avctx->time_base.den *= 2;
+        if (avctx->ticks_per_frame == 1) {
+            if(s->avctx->time_base.den < INT_MAX/2) {
+                s->avctx->time_base.den *= 2;
+            } else
+                s->avctx->time_base.num /= 2;
+        }
         avctx->ticks_per_frame = 2;
     }