Signed-off-by: Marton Balint <c...@passwd.hu>
---
 libavutil/timecode.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index a37d725fc7..b93f05b4b8 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -104,7 +104,7 @@ char *av_timecode_make_string(const AVTimecode *tc, char 
*buf, int framenum)
 {
     int fps = tc->fps;
     int drop = tc->flags & AV_TIMECODE_FLAG_DROPFRAME;
-    int hh, mm, ss, ff, neg = 0;
+    int hh, mm, ss, ff, ff_len, neg = 0;
 
     framenum += tc->start;
     if (drop)
@@ -119,9 +119,10 @@ char *av_timecode_make_string(const AVTimecode *tc, char 
*buf, int framenum)
     hh = framenum / (fps*3600LL);
     if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX)
         hh = hh % 24;
-    snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
+    ff_len = fps > 10000 ? 5 : fps > 1000 ? 4 : fps > 100 ? 3 : fps > 10 ? 2 : 
1;
+    snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%0*d",
              neg ? "-" : "",
-             hh, mm, ss, drop ? ';' : ':', ff);
+             hh, mm, ss, drop ? ';' : ':', ff_len, ff);
     return buf;
 }
 
-- 
2.31.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to