diff options
author | Marton Balint <cus@passwd.hu> | 2022-04-10 19:24:57 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2022-04-22 22:54:58 +0200 |
commit | 0d666200d30be1643aa46fa67073f257c11937ac (patch) | |
tree | cdb38d8b51a3ae78eb392abdad6d07368b23a3cd /libavutil/timecode.c | |
parent | 8dd5bb728038f21d17ec789e21d65fe8f3f364a6 (diff) | |
download | ffmpeg-0d666200d30be1643aa46fa67073f257c11937ac.tar.gz |
avutil/timecode: use timecode fps for number of frame digits
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil/timecode.c')
-rw-r--r-- | libavutil/timecode.c | 7 |
1 files 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; } |