diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
index 4d94fa69beab142295a8cc8b07dccd8f0e7554e6..b6e785cb67af3751b22ed39dc3e68a8841033fbe 100644
--- a/libavutil/samplefmt.c
+++ b/libavutil/samplefmt.c
@@ -204,3 +204,22 @@ int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
 
     return 0;
 }
+
+int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples,
+                           int nb_channels, enum AVSampleFormat sample_fmt)
+{
+    int planar      = av_sample_fmt_is_planar(sample_fmt);
+    int planes      = planar ? nb_channels : 1;
+    int block_align = av_get_bytes_per_sample(sample_fmt) * (planar ? 1 : nb_channels);
+    int data_size   = nb_samples * block_align;
+    int fill_char   = (sample_fmt == AV_SAMPLE_FMT_U8 ||
+                     sample_fmt == AV_SAMPLE_FMT_U8P) ? 0x80 : 0x00;
+    int i;
+
+    offset *= block_align;
+
+    for (i = 0; i < planes; i++)
+        memset(audio_data[i] + offset, fill_char, data_size);
+
+    return 0;
+}
diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h
index 9011889e6896ac61f5719c575d182454909da4da..e3aa6a9c36ac2c39275d421fb26e33d10bc01ee6 100644
--- a/libavutil/samplefmt.h
+++ b/libavutil/samplefmt.h
@@ -209,4 +209,16 @@ int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
                     int src_offset, int nb_samples, int nb_channels,
                     enum AVSampleFormat sample_fmt);
 
+/**
+ * Fill an audio buffer with silence.
+ *
+ * @param audio_data  array of pointers to data planes
+ * @param offset      offset in samples at which to start filling
+ * @param nb_samples  number of samples to fill
+ * @param nb_channels number of audio channels
+ * @param sample_fmt  audio sample format
+ */
+int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples,
+                           int nb_channels, enum AVSampleFormat sample_fmt);
+
 #endif /* AVUTIL_SAMPLEFMT_H */