diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index c13df62..3b248b9 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -390,18 +390,24 @@ static inline void update_double_stat(AudioStatsContext *s, ChannelStats *p, dou
     p->nb_denormals += type == FP_SUBNORMAL;
 }
 
-static void set_meta(AVDictionary **metadata, int chan, const char *key,
-                     const char *fmt, double val)
+static av_printf_format(4, 5) void set_meta(AVDictionary **metadata, int chan,
+        const char *key, const char *value, ...)
 {
-    uint8_t value[128];
-    uint8_t key2[128];
-
-    snprintf(value, sizeof(value), fmt, val);
-    if (chan)
-        snprintf(key2, sizeof(key2), "lavfi.astats.%d.%s", chan, key);
-    else
-        snprintf(key2, sizeof(key2), "lavfi.astats.%s", key);
-    av_dict_set(metadata, key2, value, 0);
+    va_list argument_list;
+
+    va_start(argument_list, value);
+    if (value) {
+        char keybuf[128];
+        char valbuf[128];
+        if (chan) {
+            snprintf(keybuf, sizeof(keybuf), "lavfi.astats.%d.%s", chan, key);
+        } else {
+            snprintf(keybuf, sizeof(keybuf), "lavfi.astats.%s", key);
+        }
+        vsnprintf(valbuf, sizeof(valbuf), value, argument_list);
+        av_dict_set(metadata, keybuf, valbuf, 0);
+    }
+    va_end(argument_list);
 }
 
 #define LINEAR_TO_DB(x) (log10(x) * 20)
@@ -484,28 +490,28 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
         if (s->measure_perchannel & MEASURE_FLAT_FACTOR)
             set_meta(metadata, c + 1, "Flat_factor", "%f", LINEAR_TO_DB((p->min_runs + p->max_runs) / (p->min_count + p->max_count)));
         if (s->measure_perchannel & MEASURE_PEAK_COUNT)
-            set_meta(metadata, c + 1, "Peak_count", "%f", (float)(p->min_count + p->max_count));
+            set_meta(metadata, c + 1, "Peak_count", "%"PRId64, p->min_count + p->max_count);
         if (s->measure_perchannel & MEASURE_NOISE_FLOOR)
             set_meta(metadata, c + 1, "Noise_floor", "%f", LINEAR_TO_DB(p->noise_floor));
         if (s->measure_perchannel & MEASURE_NOISE_FLOOR_COUNT)
-            set_meta(metadata, c + 1, "Noise_floor_count", "%f", p->noise_floor_count);
+            set_meta(metadata, c + 1, "Noise_floor_count", "%"PRId64, p->noise_floor_count);
         if (s->measure_perchannel & MEASURE_BIT_DEPTH) {
             bit_depth(s, p->mask, p->imask, &depth);
-            set_meta(metadata, c + 1, "Bit_depth", "%f", depth.num);
-            set_meta(metadata, c + 1, "Bit_depth2", "%f", depth.den);
+            set_meta(metadata, c + 1, "Bit_depth", "%u", depth.num);
+            set_meta(metadata, c + 1, "Bit_depth2", "%u", depth.den);
         }
         if (s->measure_perchannel & MEASURE_DYNAMIC_RANGE)
             set_meta(metadata, c + 1, "Dynamic_range", "%f", LINEAR_TO_DB(2 * FFMAX(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
         if (s->measure_perchannel & MEASURE_ZERO_CROSSINGS)
-            set_meta(metadata, c + 1, "Zero_crossings", "%f", p->zero_runs);
+            set_meta(metadata, c + 1, "Zero_crossings", "%"PRId64, p->zero_runs);
         if (s->measure_perchannel & MEASURE_ZERO_CROSSINGS_RATE)
             set_meta(metadata, c + 1, "Zero_crossings_rate", "%f", p->zero_runs/(double)p->nb_samples);
         if ((s->is_float || s->is_double) && s->measure_perchannel & MEASURE_NUMBER_OF_NANS)
-            set_meta(metadata, c + 1, "Number of NaNs", "%f", p->nb_nans);
+            set_meta(metadata, c + 1, "Number_of_NaNs", "%"PRId64, p->nb_nans);
         if ((s->is_float || s->is_double) && s->measure_perchannel & MEASURE_NUMBER_OF_INFS)
-            set_meta(metadata, c + 1, "Number of Infs", "%f", p->nb_infs);
+            set_meta(metadata, c + 1, "Number_of_Infs", "%"PRId64, p->nb_infs);
         if ((s->is_float || s->is_double) && s->measure_perchannel & MEASURE_NUMBER_OF_DENORMALS)
-            set_meta(metadata, c + 1, "Number of denormals", "%f", p->nb_denormals);
+            set_meta(metadata, c + 1, "Number_of_denormals", "%"PRId64, p->nb_denormals);
     }
 
     if (s->measure_overall & MEASURE_DC_OFFSET)
@@ -540,17 +546,17 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
         set_meta(metadata, 0, "Overall.Noise_floor_count", "%f", noise_floor_count / (double)s->nb_channels);
     if (s->measure_overall & MEASURE_BIT_DEPTH) {
         bit_depth(s, mask, imask, &depth);
-        set_meta(metadata, 0, "Overall.Bit_depth", "%f", depth.num);
-        set_meta(metadata, 0, "Overall.Bit_depth2", "%f", depth.den);
+        set_meta(metadata, 0, "Overall.Bit_depth", "%u", depth.num);
+        set_meta(metadata, 0, "Overall.Bit_depth2", "%u", depth.den);
     }
     if (s->measure_overall & MEASURE_NUMBER_OF_SAMPLES)
-        set_meta(metadata, 0, "Overall.Number_of_samples", "%f", nb_samples / s->nb_channels);
+        set_meta(metadata, 0, "Overall.Number_of_samples", "%"PRId64, nb_samples / s->nb_channels);
     if ((s->is_float || s->is_double) && s->measure_overall & MEASURE_NUMBER_OF_NANS)
-        set_meta(metadata, 0, "Number of NaNs", "%f", nb_nans / (float)s->nb_channels);
+        set_meta(metadata, 0, "Overall.Number_of_NaNs", "%f", nb_nans / (float)s->nb_channels);
     if ((s->is_float || s->is_double) && s->measure_overall & MEASURE_NUMBER_OF_INFS)
-        set_meta(metadata, 0, "Number of Infs", "%f", nb_infs / (float)s->nb_channels);
+        set_meta(metadata, 0, "Overall.Number_of_Infs", "%f", nb_infs / (float)s->nb_channels);
     if ((s->is_float || s->is_double) && s->measure_overall & MEASURE_NUMBER_OF_DENORMALS)
-        set_meta(metadata, 0, "Number of denormals", "%f", nb_denormals / (float)s->nb_channels);
+        set_meta(metadata, 0, "Overall.Number_of_denormals", "%f", nb_denormals / (float)s->nb_channels);
 }
 
 #define UPDATE_STATS_P(type, update_func, update_float, channel_func)           \
