diff mbox

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

Message ID 1474988473-15177-1-git-send-email-fu.qiuping@hotmail.com
State Superseded
Headers show

Commit Message

fu.qiuping@hotmail.com Sept. 27, 2016, 3:01 p.m. UTC
From: frankos2 <frankqpfu@localhost.localdomain>

---
 libavformat/flvenc.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Comments

Steven Liu Sept. 27, 2016, 3:12 p.m. UTC | #1
2016-09-27 23:01 GMT+08:00 <fu.qiuping@hotmail.com>:

> From: frankos2 <frankqpfu@localhost.localdomain>
>
> ---
>  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;
>
maybe you want support 48000HZ for mp3?

> +                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);
> --
> 1.7.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Steven Liu Sept. 27, 2016, 3:15 p.m. UTC | #2
2016-09-27 23:01 GMT+08:00 <fu.qiuping@hotmail.com>:

> From: frankos2 <frankqpfu@localhost.localdomain>
>
> ---
>  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;
>
and you can support aac too.

> +                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);
> --
> 1.7.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
fu.qiuping@hotmail.com Sept. 27, 2016, 3:30 p.m. UTC | #3
AAC 48khz has alreay been supported in flv_enc.c file, when the flv with audio format is aac

it just set it into:

if (enc->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
        return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ |
               FLV_SAMPLESSIZE_16BIT | FLV_STEREO;

when i use ffmpeg in the live video stream project, some user publish the rtmp stream with (h264 and mp3 48khz)
then i need to use ffmpeg to convert the "rtmp" live stream to "flv" live stream,  ffmpeg can not support and make a warning.
so i change this code to make it support this.
________________________________
发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu <lingjiujianke@gmail.com>
发送时间: 2016年9月27日 15:15
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] [PATCH] flv format support mp3 audio with 48khz

2016-09-27 23:01 GMT+08:00 <fu.qiuping@hotmail.com>:

> From: frankos2 <frankqpfu@localhost.localdomain>

>

> ---

>  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;

>

and you can support aac too.

> +                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);

> --

> 1.7.1

>

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
ffmpeg.org
This list is about FFmpeg development discussions and patches; but not for bug-reports. Please read the Code-of-conduct. To see the collection of prior postings to ...



>

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Steven Liu Sept. 27, 2016, 3:55 p.m. UTC | #4
2016-09-27 23:30 GMT+08:00 付 秋平 <fu.qiuping@hotmail.com>:

> AAC 48khz has alreay been supported in flv_enc.c file, when the flv with
> audio format is aac
>
> it just set it into:
>
> if (enc->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
>         return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ |
>                FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
>
> when i use ffmpeg in the live video stream project, some user publish the
> rtmp stream with (h264 and mp3 48khz)
> then i need to use ffmpeg to convert the "rtmp" live stream to "flv" live
> stream,  ffmpeg can not support and make a warning.
> so i change this code to make it support this.
> ________________________________
> 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu <
> lingjiujianke@gmail.com>
> 发送时间: 2016年9月27日 15:15
> 收件人: FFmpeg development discussions and patches
> 主题: Re: [FFmpeg-devel] [PATCH] flv format support mp3 audio with 48khz
>
> 2016-09-27 23:01 GMT+08:00 <fu.qiuping@hotmail.com>:
>
> > From: frankos2 <frankqpfu@localhost.localdomain>
> >
> > ---
> >  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;
> >
> and you can support aac too.
>
> > +                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);
> > --
> > 1.7.1
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
> ffmpeg.org
> This list is about FFmpeg development discussions and patches; but not for
> bug-reports. Please read the Code-of-conduct. To see the collection of
> prior postings to ...
>
>
>
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Ok, LGTM, thanks!
Michael Niedermayer Sept. 27, 2016, 7:57 p.m. UTC | #5
On Tue, Sep 27, 2016 at 08:01:13AM -0700, fu.qiuping@hotmail.com wrote:

> From: frankos2 <frankqpfu@localhost.localdomain>

This is not a name and email address
is this intended as "Author" information for git ?
Or is this a mistake ?
If its a mistake please correct it and resubmit the patch

thx

[...]
Yusuke Nakamura Sept. 27, 2016, 9:15 p.m. UTC | #6
2016-09-28 0:01 GMT+09:00 <fu.qiuping@hotmail.com>:

> From: frankos2 <frankqpfu@localhost.localdomain>
>
> ---
>  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;
> +                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);
> --
> 1.7.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Out of the spec I think. Did you confirm that Adobe (Flash Player) allows
48kHz mp3? About AAC, the spec (Adobe Flash Video File Format
Specification) says the Flash Player ignores sample rate in AudioTagHeader,
which is a dummy, and extracts the actual sample rate from AAC bitstream.
But the spec does not say about MP3 in the same way.
fu.qiuping@hotmail.com Sept. 28, 2016, 2:34 p.m. UTC | #7
I have already tried the "mp3_audio_48khz" flv live stream and rtmp live stream in the adobe flash player.

It supports the format and works well.

________________________________
发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
发送时间: 2016年9月27日 21:15
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] [PATCH] flv format support mp3 audio with 48khz

2016-09-28 0:01 GMT+09:00 <fu.qiuping@hotmail.com>:

> From: frankos2 <frankqpfu@localhost.localdomain>

>

> ---

>  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;

> +                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);

> --

> 1.7.1

>

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
ffmpeg.org
This list is about FFmpeg development discussions and patches; but not for bug-reports. Please read the Code-of-conduct. To see the collection of prior postings to ...



>


Out of the spec I think. Did you confirm that Adobe (Flash Player) allows
48kHz mp3? About AAC, the spec (Adobe Flash Video File Format
Specification) says the Flash Player ignores sample rate in AudioTagHeader,
which is a dummy, and extracts the actual sample rate from AAC bitstream.
But the spec does not say about MP3 in the same way.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
fu.qiuping@hotmail.com Sept. 28, 2016, 2:35 p.m. UTC | #8
Sorry, this is a mistake.

I will change it and resubmit the patch.

________________________________
发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Michael Niedermayer <michael@niedermayer.cc>
发送时间: 2016年9月27日 19:57
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] [PATCH] flv format support mp3 audio with 48khz

On Tue, Sep 27, 2016 at 08:01:13AM -0700, fu.qiuping@hotmail.com wrote:

> From: frankos2 <frankqpfu@localhost.localdomain>


This is not a name and email address
is this intended as "Author" information for git ?
Or is this a mistake ?
If its a mistake please correct it and resubmit the patch

thx

[...]
--
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.
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);