History

avfilter/af_whisper: fix int64 printf format

Use PRId64 for printing int64_t values in the SRT output. (cherry picked from commit f18b1e23890c1179d41c07f2c195c56fb90ea072)

Vittorio Palmisano committed 1 year ago

Commit d8049e01 parent adc81971 file · +5 −5Browse files

Unified · Split

libavfilter/af_whisper.c+5−5
@@ -150,7 +150,7 @@ static int init(AVFilterContext *ctx) · 149 unmodified lines
150 }150 }
151 151
152 av_log(ctx, AV_LOG_INFO,152 av_log(ctx, AV_LOG_INFO,
153 "Whisper filter initialized: model: %s lang: %s queue: %ld ms\n",153 "Whisper filter initialized: model: %s lang: %s queue: %" PRId64 " ms\n",
154 wctx->model_path, wctx->language, wctx->queue / 1000);154 wctx->model_path, wctx->language, wctx->queue / 1000);
155 155
156 return 0;156 return 0;
@@ -194,7 +194,7 @@ static void run_transcription(AVFilterContext *ctx, AVFrame *frame, int samples) · 37 unmodified lines
194 const float duration = (float) samples / WHISPER_SAMPLE_RATE;194 const float duration = (float) samples / WHISPER_SAMPLE_RATE;
195 195
196 av_log(ctx, AV_LOG_INFO,196 av_log(ctx, AV_LOG_INFO,
197 "run transcription at %ld ms, %d/%d samples (%.2f seconds)...\n",197 "run transcription at %" PRId64 " ms, %d/%d samples (%.2f seconds)...\n",
198 timestamp_ms, samples, wctx->audio_buffer_fill_size, duration);198 timestamp_ms, samples, wctx->audio_buffer_fill_size, duration);
199 199
200 struct whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);200 struct whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
@@ -228,7 +228,7 @@ static void run_transcription(AVFilterContext *ctx, AVFrame *frame, int samples) · 27 unmodified lines
228 const int64_t t0_ms = whisper_full_get_segment_t0(wctx->ctx_wsp, i) * 10;228 const int64_t t0_ms = whisper_full_get_segment_t0(wctx->ctx_wsp, i) * 10;
229 const int64_t t1_ms = whisper_full_get_segment_t1(wctx->ctx_wsp, i) * 10;229 const int64_t t1_ms = whisper_full_get_segment_t1(wctx->ctx_wsp, i) * 10;
230 230
231 av_log(ctx, AV_LOG_DEBUG, " [%ld-%ld%s]: \"%s\"\n",231 av_log(ctx, AV_LOG_DEBUG, " [%" PRId64 "-%" PRId64 "%s]: \"%s\"\n",
232 timestamp_ms + t0_ms, timestamp_ms + t1_ms, turn ? " (turn)" : "", text_cleaned);232 timestamp_ms + t0_ms, timestamp_ms + t1_ms, turn ? " (turn)" : "", text_cleaned);
233 233
234 if (segments_text) {234 if (segments_text) {
@@ -246,13 +246,13 @@ static void run_transcription(AVFilterContext *ctx, AVFrame *frame, int samples) · 11 unmodified lines
246 if (!av_strcasecmp(wctx->format, "srt")) {246 if (!av_strcasecmp(wctx->format, "srt")) {
247 buf =247 buf =
248 av_asprintf248 av_asprintf
249 ("%d\n%02ld:%02ld:%02ld,%03ld --> %02ld:%02ld:%02ld,%03ld\n%s\n\n",249 ("%d\n%02" PRId64 ":%02" PRId64 ":%02" PRId64 ",%03" PRId64 " --> %02" PRId64 ":%02" PRId64 ":%02" PRId64 ",%03" PRId64 "\n%s\n\n",
250 wctx->index, start_t / 3600000,250 wctx->index, start_t / 3600000,
251 (start_t / 60000) % 60, (start_t / 1000) % 60,251 (start_t / 60000) % 60, (start_t / 1000) % 60,
252 start_t % 1000, end_t / 3600000, (end_t / 60000) % 60,252 start_t % 1000, end_t / 3600000, (end_t / 60000) % 60,
253 (end_t / 1000) % 60, end_t % 1000, text_cleaned);253 (end_t / 1000) % 60, end_t % 1000, text_cleaned);
254 } else if (!av_strcasecmp(wctx->format, "json")) {254 } else if (!av_strcasecmp(wctx->format, "json")) {
255 buf = av_asprintf("{\"start\":%ld,\"end\":%ld,\"text\":\"%s\"}\n", start_t, end_t, text_cleaned);255 buf = av_asprintf("{\"start\":%" PRId64 ",\"end\":%" PRId64 ",\"text\":\"%s\"}\n", start_t, end_t, text_cleaned);
256 } else256 } else
257 buf = av_strdup(text_cleaned);257 buf = av_strdup(text_cleaned);
258 258

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t