[FFmpeg-devel] [PATCH 2/3] ffmpeg: more expressive sample rate automatic selection.

Clément Bœsch ubitux at gmail.com
Tue Mar 20 16:38:13 CET 2012


From: Clément Bœsch <clement.boesch at smartjog.com>

Output now lists the available sample rates with commands like
ffmpeg -f lavfi -i aevalsrc=0 -ar 20000 -y /tmp/out.mp3
---
 ffmpeg.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 6d1d3f7..a0558c6 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -949,7 +949,18 @@ static void choose_sample_rate(AVStream *st, AVCodec *codec)
             }
         }
         if (best_dist) {
-            av_log(st->codec, AV_LOG_WARNING, "Requested sampling rate unsupported using closest supported (%d)\n", best);
+            int i;
+            const int *sample_rates = codec->supported_samplerates;
+            av_log(st->codec, AV_LOG_WARNING,
+                   "Requested sampling rate (%dHz) unsupported, using %dHz instead\n"
+                   "Available sampling rates for %s:",
+                   st->codec->sample_rate, best, codec->name);
+            for (i = 0; sample_rates[i]; i++) {
+                if (!sample_rates[i + 1]) av_log(st->codec, AV_LOG_WARNING, " and");
+                else if (i)               av_log(st->codec, AV_LOG_WARNING, ",");
+                av_log(st->codec, AV_LOG_WARNING, " %d", sample_rates[i]);
+            }
+            av_log(st->codec, AV_LOG_WARNING, ".\n");
         }
         st->codec->sample_rate = best;
     }
-- 
1.7.9.1



More information about the ffmpeg-devel mailing list