diff mbox

[FFmpeg-devel] flv format support mp3 audio with 48khz

Message ID 1475074067-16687-1-git-send-email-fu.qiuping@hotmail.com
State Accepted
Headers show

Commit Message

fu.qiuping@hotmail.com Sept. 28, 2016, 2:47 p.m. UTC
---
 libavformat/flvenc.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Comments

wm4 Sept. 28, 2016, 3:26 p.m. UTC | #1
On Wed, 28 Sep 2016 07:47:47 -0700
fuqiuping <fu.qiuping@hotmail.com> wrote:

> ---
>  libavformat/flvenc.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index 99903f5..296426a 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -107,6 +107,13 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
>          return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
>      } else {
>          switch (par->sample_rate) {
> +        case 48000:
> +            if (par->codec_id == AV_CODEC_ID_MP3) {
> +                flags |= FLV_SAMPLERATE_44100HZ;

This looks wrong. It should have a code comment why it's right, even
though it 'll look wrong to every single person who look at tit for the
first time.

> +                break;
> +            } else {
> +                goto error;
> +            }
>          case 44100:
>              flags |= FLV_SAMPLERATE_44100HZ;
>              break;
> @@ -124,6 +131,7 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
>                  break;
>              }
>          default:
> +error:
>              av_log(s, AV_LOG_ERROR,
>                     "FLV does not support sample rate %d, "
>                     "choose from (44100, 22050, 11025)\n", par->sample_rate);
Michael Niedermayer Nov. 6, 2016, 9:43 p.m. UTC | #2
On Wed, Sep 28, 2016 at 05:26:35PM +0200, wm4 wrote:
> On Wed, 28 Sep 2016 07:47:47 -0700
> fuqiuping <fu.qiuping@hotmail.com> wrote:
> 
> > ---
> >  libavformat/flvenc.c |    8 ++++++++
> >  1 files changed, 8 insertions(+), 0 deletions(-)
> > 
> > diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> > index 99903f5..296426a 100644
> > --- a/libavformat/flvenc.c
> > +++ b/libavformat/flvenc.c
> > @@ -107,6 +107,13 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
> >          return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
> >      } else {
> >          switch (par->sample_rate) {
> > +        case 48000:
> > +            if (par->codec_id == AV_CODEC_ID_MP3) {
> > +                flags |= FLV_SAMPLERATE_44100HZ;
> 
> This looks wrong. It should have a code comment why it's right, even
> though it 'll look wrong to every single person who look at tit for the
> first time.

added comment
applied

thx

[...]
diff mbox

Patch

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 99903f5..296426a 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -107,6 +107,13 @@  static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
         return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
     } else {
         switch (par->sample_rate) {
+        case 48000:
+            if (par->codec_id == AV_CODEC_ID_MP3) {
+                flags |= FLV_SAMPLERATE_44100HZ;
+                break;
+            } else {
+                goto error;
+            }
         case 44100:
             flags |= FLV_SAMPLERATE_44100HZ;
             break;
@@ -124,6 +131,7 @@  static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
                 break;
             }
         default:
+error:
             av_log(s, AV_LOG_ERROR,
                    "FLV does not support sample rate %d, "
                    "choose from (44100, 22050, 11025)\n", par->sample_rate);