[FFmpeg-devel] [PATCH]flvenc Allow ffmpeg -copy on rtmp outputs from udp inputs
Michael Niedermayer
michaelni at gmx.at
Mon Jun 2 04:10:10 CEST 2014
On Tue, May 20, 2014 at 01:35:46AM +0200, Tudor SUCIU wrote:
> There is a bug where audio extradata is missing for aac streams when there
> is an mpegts stream as input.
> This patch is probably not the cleanest and the code is already present in
> aacenc.c (and probably in mp4 muxer), but it works.
> It fixes issues with rtmp pushing with -acodec copy from udp mpegts inputs.
> flvenc.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
> 0dd0a2e4d4221f79e9260e8fa6f715cd9ebc78d4 flvcopyextradatafix.patch
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index c16f8eb..9586aae 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -401,11 +401,38 @@ static int flv_write_header(AVFormatContext *s)
> if (enc->codec_id == AV_CODEC_ID_AAC) {
> avio_w8(pb, get_audio_flags(s, enc));
> avio_w8(pb, 0); // AAC sequence header
> + if(enc->extradata_size>=2)
> + av_log(s, AV_LOG_WARNING, "AAC extradata size %d: %02x:%02x.\n", enc->extradata_size, enc->extradata[0], enc->extradata[1]);
> + else
> + {
> + static const int mpeg4audio_sample_rates[16] = {
> + 96000, 88200, 64000, 48000, 44100, 32000,
> + 24000, 22050, 16000, 12000, 11025, 8000, 7350
> + };
> + int sample_rate_index;
> + av_log(s, AV_LOG_WARNING, "AAC extradata empty!.\n");
> + enc->extradata = av_mallocz(2);
lacking malloc failure check
> + enc->extradata_size = 2;
> +
> + for (sample_rate_index = 0; sample_rate_index < 16; sample_rate_index++)
> + if (enc->sample_rate == mpeg4audio_sample_rates[sample_rate_index])
> + break;
> + enc->extradata[0] = 0x10 | (sample_rate_index>>1);
> + enc->extradata[1] = (sample_rate_index & 0x01)<<7 | enc->channels <<3;
> + if(enc->extradata_size>=2)
> + av_log(s, AV_LOG_WARNING, "AAC2 extradata size %d: %02x:%02x.\n", enc->extradata_size, enc->extradata[0], enc->extradata[1]);
> + else
> + av_log(s, AV_LOG_WARNING, "AAC2 extradata size still %d\n", enc->extradata_size);
you just set extradata_size to 2 a few lines above so the else is dead
code also this looks like debug code, and thus should be AV_LOG_DEBUG
this applies to other such calls as well i guess
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140602/e4c2f095/attachment.asc>
More information about the ffmpeg-devel
mailing list