Opened 13 years ago

Closed 12 years ago

#566 closed defect (fixed)

Encoding AAC stereo audio which starts silently to mpeg-ts causes 0-channel audio output.

Reported by: tungj Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: aac mpegts
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

When encoding a video with stereo audio which starts with 6 seconds of silence to mpeg-ts, 'ffprobe' on the output .ts reports it to have an audio track with 0 channels of audio despite the audio playing in FFplay and vlc. This means the 0-channel audio stream is lost (in newest GIT N-33724-gefb1ce2 FFmpeg with libfaac 1.28), or causes an 'encoding 0 channels is not allowed' error in older FFmpeg git-N-29122-gb8a4444 libfaac 1.26 builds when doing any encoding on that output later on.

Encoding the video to mpeg-ts:

tungj@tungj-ffmpeg:~/bugreport$ ffmpeg -y -i 'initialSilence.mp4' -f mpegts -t 10 -acodec libfaac -ab 40k -ar 22050 initialSilence.ts
ffmpeg version N-33724-gefb1ce2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 11:00:29 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'initialSilence.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
  Duration: 00:00:10.02, start: 0.000000, bitrate: 84 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 200x200, 5 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 72 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
[buffer @ 0xa9fc620] w:200 h:200 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
[mpegts @ 0xa9fc6e0] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'initialSilence.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
    Stream #0:0(und): Video: mpeg2video, yuv420p, 200x200, q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac, 22050 Hz, stereo, s16, 40 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
Stream mapping:
  Stream #0.0 -> #0.0 (h264 -> mpeg2video)
  Stream #0.1 -> #0.1 (aac -> libfaac)
Press [q] to stop, [?] for help
frame=  250 fps=  0 q=2.0 Lsize=     197kB time=00:00:09.96 bitrate= 161.7kbits/s    
video:124kB audio:34kB global headers:0kB muxing overhead 24.226776%

The mpegts stream claims to have zero channels:

tungj@tungj-ffmpeg:~/bugreport$ ffmpeg -v 9 -loglevel 99 -i initialSilence.ts
ffmpeg version N-33724-gefb1ce2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 11:00:29 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mpegts @ 0x9c24aa0] Format mpegts probed with size=2048 and score=100
[mpegts @ 0x9c24aa0] stream=0 stream_type=2 pid=100 prog_reg_desc=
[mpegts @ 0x9c24aa0] stream=1 stream_type=f pid=101 prog_reg_desc=
[aac @ 0x9c290c0] Unsupported bit depth: 0
[mpeg2video @ 0x9c288e0] Unsupported bit depth: 0
[mpegts @ 0x9c24aa0] max_analyze_duration 5000000 reached at 5000000
[NULL @ 0x9c290c0] start time is not set in estimate_timings_from_pts
Input #0, mpegts, from 'initialSilence.ts':
  Duration: 00:00:09.96, start: 1.400000, bitrate: 161 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100], 127, 1/90000: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 200x200 [SAR 1:1 DAR 1:1], 1/50, 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](und), 0, 1/90000: Audio: aac ([15][0][0][0] / 0x000F), 0 channels, s16
At least one output file must be specified

When doing futher processing, the original audio is lost in output.mp4:

tungj@tungj-ffmpeg:~/bugreport$ ffmpeg -y -i 'initialSilence.ts' -vcodec copy -acodec libfaac -ab 40k -ar 22050 output.mp4
ffmpeg version N-33724-gefb1ce2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 11:00:29 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mpegts @ 0x9346aa0] max_analyze_duration 5000000 reached at 5000000
[NULL @ 0x934b0c0] start time is not set in estimate_timings_from_pts
Input #0, mpegts, from 'initialSilence.ts':
  Duration: 00:00:09.96, start: 1.400000, bitrate: 161 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 200x200 [SAR 1:1 DAR 1:1], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, s16
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf53.16.0
    Stream #0:0: Video: mpeg2video (a[0][0][0] / 0x0061), yuv420p, 200x200 [SAR 1:1 DAR 1:1], q=2-31, 104857 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0 (copy)
Press [q] to stop, [?] for help
frame=  250 fps=  0 q=-1.0 Lsize=     127kB time=00:00:09.96 bitrate= 104.5kbits/s    
video:124kB audio:0kB global headers:0kB muxing overhead 2.308019%

Details of the input file:

tungj@tungj-ffmpeg:~/bugreport$ ffmpeg -v 9 -loglevel 99 -i initialSilence.mp4 
ffmpeg version N-33724-gefb1ce2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 11:00:29 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xa374aa0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xa374aa0] ISO: File Type Major Brand: isom
[aac @ 0xa3852a0] Unsupported bit depth: 0
[h264 @ 0xa37b5c0] no picture
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xa374aa0] All info found
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'initialSilence.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
  Duration: 00:00:10.02, start: 0.000000, bitrate: 84 kb/s
    Stream #0:0(und), 3, 1/25: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 200x200, 1/50, 5 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und), 1, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 72 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
At least one output file must be specified

Interestingly, the problem seems to occur at the silence-to-audio boundary; encoding either before the sound starts

ffmpeg -y -i 'initialSilence.mp4' -f mpegts -t 5 -acodec libfaac -ab 40k -ar 22050 initialSilence.ts

or after the silence ends

ffmpeg -y -i 'initialSilence.mp4' -f mpegts -ss 8 -acodec libfaac -ab 40k -ar 22050 initialSilence.ts

produce mpegts files which ffprobe reports as having stereo audio output.

Attachments (1)

initialSilence.mp4 (103.5 KB ) - added by tungj 13 years ago.
Video file which begins with ~7 seconds of silence

Download all attachments as: .zip

Change History (14)

by tungj, 13 years ago

Attachment: initialSilence.mp4 added

Video file which begins with ~7 seconds of silence

comment:1 by Carl Eugen Hoyos, 13 years ago

Is this also reproducible with the native aac encoder (and libvo-aacenc and libaacplus)?

comment:2 by tungj, 13 years ago

Thanks for the fast response! It still gives 0 channels using the native aac encoder; I'll recompile with libvo-aacenc and libaacplus and try those.

tungj@tungj-ffmpeg:~/bugreport/native$ ffmpeg -y -i 'initialSilence.mp4' -f mpegts -strict experimental -t 10 -acodec aac -ab 40k -ar 22050 initialSilence.ts
ffmpeg version N-33724-gefb1ce2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 11:00:29 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'initialSilence.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
  Duration: 00:00:10.02, start: 0.000000, bitrate: 84 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 200x200, 5 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 72 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
[buffer @ 0x90ce6c0] w:200 h:200 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
[mpegts @ 0x90ce760] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'initialSilence.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
    Stream #0:0(und): Video: mpeg2video, yuv420p, 200x200, q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac, 22050 Hz, stereo, s16, 40 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
Stream mapping:
  Stream #0.0 -> #0.0 (h264 -> mpeg2video)
  Stream #0.1 -> #0.1 (aac -> aac)
Press [q] to stop, [?] for help
frame=  250 fps=  0 q=2.0 Lsize=     189kB time=00:00:09.96 bitrate= 155.2kbits/s    
video:124kB audio:26kB global headers:0kB muxing overhead 25.718152%

FFprobe reports 0 channels:

tungj@tungj-ffmpeg:~/bugreport/native$ ffprobe initialSilence.ts
ffprobe version N-33724-gefb1ce2, Copyright (c) 2007-2011 the FFmpeg developers
  built on Oct 17 2011 11:00:29 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mpegts @ 0x9fc7b80] max_analyze_duration 5000000 reached at 5000000
[NULL @ 0x9fcc0e0] start time is not set in estimate_timings_from_pts
Input #0, mpegts, from 'initialSilence.ts':
  Duration: 00:00:09.96, start: 1.400000, bitrate: 155 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 200x200 [SAR 1:1 DAR 1:1], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, s16
Last edited 13 years ago by tungj (previous) (diff)

in reply to:  2 ; comment:3 by Carl Eugen Hoyos, 13 years ago

Replying to tungj:

It still gives 0 channels using the native aac encoder

Only reproducible with -ar 22050, is that correct?

in reply to:  3 comment:4 by tungj, 13 years ago

Replying to cehoyos:

Replying to tungj:

It still gives 0 channels using the native aac encoder

Only reproducible with -ar 22050, is that correct?

It seems to be reproducible with anything below a certain rate, in this case, around 37000.

for rate in 22050 33050 35000 36000 37000 44050; do ffmpeg -y -i 'initialSilence.mp4' -f mpegts -t 10 -acodec libfaac -ab 40k -ar $rate initialSilence.ts 2>/dev/null 1>&2; echo $rate; ffprobe initialSilence.ts 2>&1 | grep Audio; done;
22050
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, s16
33050
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, s16
35000
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, s16
36000
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, s16
37000
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 32000 Hz, stereo, s16, 4 kb/s
44050
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16, 5 kb/s

in reply to:  1 comment:5 by tungj, 13 years ago

Replying to cehoyos:

Is this also reproducible with the native aac encoder (and libvo-aacenc and libaacplus)?

libvo-aacenc correctly outputs two channels; while libaacplus gives an 'bad aac setting: br:40000, AACch:1, AACsr:22050' error for these particular rates. The native aac encoder gave output with 0 channels.

This was with libvo-aacenc 0.1.1 from http://sourceforge.net/projects/opencore-amr/files/vo-aacenc/vo-aacenc-0.1.1.tar.gz/download and libaacplus-2.0.2.tar.gz from http://tipok.org.ua/node/17

libaacplus:

tungj@tungj-ffmpeg:~/bugreport/aacplus$ ffmpeg -y -i 'initialSilence.mp4' -f mpegts -t 10 -acodec libaacplus -ab 40k -ar 22050 initialSilence.ts
ffmpeg version N-33724-gefb1ce2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 16:30:42 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libaacplus --enable-libvo-aacenc
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'initialSilence.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
  Duration: 00:00:10.02, start: 0.000000, bitrate: 84 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 200x200, 5 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 72 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
[buffer @ 0x95e5620] w:200 h:200 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
libaacplus: bad aac setting: br:40000, AACch:1, AACsr:22050
[libaacplus @ 0x95e5120] libaacplus doesn't support this output format!
Output #0, mpegts, to 'initialSilence.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
    Stream #0:0(und): Video: mpeg2video, yuv420p, 200x200, q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac, 22050 Hz, stereo, s16, 40 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
Stream mapping:
  Stream #0.0 -> #0.0 (h264 -> mpeg2video)
  Stream #0.1 -> #0.1 (aac -> libaacplus)
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height

libvo-aacenc gives 2 channels as expected:

tungj@tungj-ffmpeg:~/bugreport/libvo_aacenc$ ffmpeg -y -i 'initialSilence.mp4' -f mpegts -t 10 -acodec libvo_aacenc -ab 40k -ar 22050 initialSilence.ts
ffmpeg version N-33724-gefb1ce2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 16:30:42 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libaacplus --enable-libvo-aacenc
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'initialSilence.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
  Duration: 00:00:10.02, start: 0.000000, bitrate: 84 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 200x200, 5 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 72 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
[buffer @ 0x9653620] w:200 h:200 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
[mpegts @ 0x96536e0] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'initialSilence.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
    Stream #0:0(und): Video: mpeg2video, yuv420p, 200x200, q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac, 22050 Hz, stereo, s16, 40 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
Stream mapping:
  Stream #0.0 -> #0.0 (h264 -> mpeg2video)
  Stream #0.1 -> #0.1 (aac -> libvo_aacenc)
Press [q] to stop, [?] for help
frame=  250 fps=  0 q=2.0 Lsize=     214kB time=00:00:09.96 bitrate= 175.9kbits/s    
video:124kB audio:50kB global headers:0kB muxing overhead 23.044944%


tungj@tungj-ffmpeg:~/bugreport/libvo_aacenc$ ffprobe output.mp4 
ffprobe version N-33724-gefb1ce2, Copyright (c) 2007-2011 the FFmpeg developers
  built on Oct 17 2011 16:30:42 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libaacplus --enable-libvo-aacenc
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.16.0
  Duration: 00:00:10.07, start: 0.000000, bitrate: 130 kb/s
    Stream #0:0(und): Video: mpeg2video (Main) (mp4v / 0x7634706D), yuv420p, 200x200 [SAR 1:1 DAR 1:1], 104857 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, s16, 25 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00

comment:6 by Carl Eugen Hoyos, 13 years ago

I can fix the problem with --analyzeduration 1000000000, does this also (always) work for you?

in reply to:  6 comment:7 by tungj, 13 years ago

Replying to cehoyos:

I can fix the problem with --analyzeduration 1000000000, does this also (always) work for you?

Yes, thank you very much! I wasn't aware of that setting; it's listed in ffmpeg -h but not the man docs (unless I've compiled those incorrectly). The mpegts is correctly reported to have audio with

ffprobe -analyzeduration 1000000000 initialSilence.ts

and the output .mp4 from further processing has an audio track.

ffmpeg -analyzeduration 1000000000 -i initialSilence.ts -vcodec copy -acodec libfaac -ar 22050 -ab 40k initialSilence.mp4

Looking at the code, avformat_find_stream_info checks up to max_analyze_duration which defaults to 5 * AV_TIME_BASE (defined as 1000000; 1 second); in my case I had more than 5 seconds of silence so it probably didn't find the start of the audio despite finding the audio track. I'm not sure why it correctly reports stereo audio when there's only silence though:

ffmpeg -y -i 'initialSilence.mp4' -f mpegts -t 5 -acodec libfaac -ab 40k -ar 22050 initialSilence.ts; 
ffprobe initialSilence.ts

reports Stream #0.1[0x101](und): Audio: aac, 22050 Hz, stereo, s16, 2 kb/s

I'm also not sure why ffprobe on the .ts created by libvo_aacenc correctly reports two channels without explicitly setting -analyzeduration; exporting the -acodec libvo_aacenc initialSilence.ts file to a .wav with

ffmpeg -i initialSilence.ts -vn libvo_silence.wav

seems to just start with silence (a long sequence of null bytes after the RIFF...WAVEfmt...data header), slightly longer than the silence in the .wav from the exported -acodec libfaac.

comment:8 by Terran Vigil, 13 years ago

This ticket seems to be closely related to #542. We found that reverting a change from last November also provides a workaround. See the ticket fore more details:

https://ffmpeg.org/trac/ffmpeg/ticket/542

Last edited 13 years ago by Carl Eugen Hoyos (previous) (diff)

in reply to:  8 comment:9 by tungj, 13 years ago

Replying to terran:

This ticket seems to be closely related to #542. We found that reverting a change from last November also provides a workaround. See the ticket fore more details:

https://ffmpeg.org/trac/ffmpeg/ticket/542

Thanks for the suggestion, but it seems the problem is still reproducible after adding back the rate tolerance from change 2c5168afed8ddd798dae5909dba85ae3b611f894 as mentioned on comment 51 of #542.

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 7410112..eeaad71 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -296,6 +296,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
     if (avctx->level > 0)
         x4->params.i_level_idc = avctx->level;
 
+    x4->params.rc.f_rate_tolerance =
+        (float)avctx->bit_rate_tolerance/avctx->bit_rate;
+
     x4->params.pf_log               = X264_log;
     x4->params.p_log_private        = avctx;
     x4->params.i_log_level          = X264_LOG_DEBUG;

ffprobe initialSilence.ts still returns (0 channels) after recompiling and rerunning ffmpeg -y -i '../initialSilence.mp4' -f mpegts -t 10 -acodec libfaac -ab 40k -ar 22050 initialSilence.ts ; and the audio track is lost when running ffmpeg -y -i 'initialSilence.ts' -vcodec copy -acodec libfaac -ab 40k -ar 22050 output.mp4.

comment:10 by Carl Eugen Hoyos, 13 years ago

Of course the mentioned patch is not responsible for the problem: It is not even necessary to compile the file in question to reproduce the problem.

Isn't using libvo-aacenc sufficient as a work-around?

in reply to:  10 comment:11 by tungj, 13 years ago

Replying to cehoyos:

Of course the mentioned patch is not responsible for the problem: It is not even necessary to compile the file in question to reproduce the problem.

Isn't using libvo-aacenc sufficient as a work-around?

Yes, thanks, both of your suggestions libvo-aacenc on encoding or -analyzeduration 1000000000 on ffprobe/further encoding are good workarounds (I'm using the latter). I was just posting results of testing the suggestion in comment 8.

comment:12 by Carl Eugen Hoyos, 13 years ago

Keywords: aac ts added
Reproduced by developer: set
Status: newopen

comment:13 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedavformat
Keywords: mpegts added; ts removed
Resolution: fixed
Status: openclosed
Version: unspecifiedgit-master

Fixed in current git head and 1.0.

Note: See TracTickets for help on using tickets.