[FFmpeg-cvslog] ffmpeg: more expressive sample rate automatic selection.

Clément Bœsch git at videolan.org
Mon Mar 26 22:48:10 CEST 2012


ffmpeg | branch: master | Clément Bœsch <clement.boesch at smartjog.com> | Tue Mar 20 16:19:49 2012 +0100| [21d650cb69fd6ec42d3f0c8115978f5cf8b34277] | committer: Clément Bœsch

ffmpeg: more expressive sample rate automatic selection.

Output now lists the available sample rates with commands like
ffmpeg -f lavfi -i aevalsrc=0 -ar 20000 -y /tmp/out.mp3

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21d650cb69fd6ec42d3f0c8115978f5cf8b34277
---

 ffmpeg.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index d3be033..eb535fe 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -953,7 +953,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;
     }



More information about the ffmpeg-cvslog mailing list