[FFmpeg-trac] #3175(avformat:new): audio (aac) silently on streamcopy from mpegts to flv

FFmpeg trac at avcodec.org
Wed Nov 27 12:31:12 CET 2013


#3175: audio (aac) silently on streamcopy from mpegts to flv
-------------------------------------+-------------------------------------
             Reporter:  iluvatar     |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:  avformat     |                  Version:  git-
             Keywords:  aac          |  master
  streamcopy flv                     |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 If you do streamcopy from mpegts to flv with audiocodec aac audio in
 output is silently.
 Reproduced with internal aac encoder, faac and libfdk_aac.
 The problem occurs, because AudioSpecificConfig (ASC) is not written on
 streamcopy. Bitstream filter aac_adtstoasc_bsf.c writes ASC correctly
 (line 94-99) but too late (after flv header).
 If you write ASC in flvenc.c manually, encoded file is written correctly:
 {{{
 --- a/libavformat/flvenc.c
 +++ b/libavformat/flvenc.c
 @@ -397,7 +397,8 @@ 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
 -                avio_write(pb, enc->extradata, enc->extradata_size);
 +                avio_wb16(pb, 5000); // ^= 0x1388; AAC LC, 22050 Hz, 1
 channel
 +                //avio_write(pb, enc->extradata, enc->extradata_size);
              } else {
                  avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
                  avio_w8(pb, 0); // AVC sequence header
 }}}
 More information about ASC:
 http://wiki.multimedia.cx/index.php?title=MPEG-
 4_Audio#Audio_Specific_Config
 I don't know if you can call bitstream filter before writing flv header.

 How to reproduce:
 {{{
 % ffmpeg -re -i /tmp/input.ts -c:v copy -c:a libfaac -b:a 32k -ar 22050
 -ac 1 -f mpegts udp://localhost:1234
 ffmpeg version N-58470-g3c846fd Copyright (c) 2000-2013 the FFmpeg
 developers
   built on Nov 26 2013 14:56:57 with gcc 4.4.5 (Debian 4.4.5-8)
   configuration: --enable-nonfree --enable-libfaac --enable-libx264
 --enable-gpl --enable-libzmq --enable-libfreetype --enable-ffplay
 --enable-librtmp --enable-libfdk-aac --enable-libmp3lame --enable-libvpx
   libavutil      52. 55.100 / 52. 55.100
   libavcodec     55. 44.100 / 55. 44.100
   libavformat    55. 21.102 / 55. 21.102
   libavdevice    55.  5.100 / 55.  5.100
   libavfilter     3. 91.100 /  3. 91.100
   libswscale      2.  5.101 /  2.  5.101
   libswresample   0. 17.104 /  0. 17.104
   libpostproc    52.  3.100 / 52.  3.100
 Input #0, mpegts, from '/tmp/input.ts':
   Duration: 00:01:00.00, start: 1.378667, bitrate: 2319 kb/s
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
 yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
     Stream #0:1[0x101](deu): Audio: aac ([15][0][0][0] / 0x000F), 48000
 Hz, stereo, fltp, 121 kb/s
 Output #0, mpegts, to 'udp://localhost:1234':
   Metadata:
     encoder         : Lavf55.21.102
     Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 1280x720
 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 90k tbn, 50 tbc
     Stream #0:1(deu): Audio: aac (libfaac), 22050 Hz, mono, s16, 32 kb/s
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
   Stream #0:1 -> #0:1 (aac -> libfaac)
 Press [q] to stop, [?] for help

 % ffmpeg -i udp://localhost:1234 -c copy -bsf:a aac_adtstoasc -f flv
 output.flv

 }}}

 My intention is to stream one mpegts (with one h264 and multiple languages
 -> aac) to a local udp port and then steam each language in extra
 processes to different flash servers.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/3175>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list