[FFmpeg-user] Deal with AAC priming when join file

Fabrice RAFART frafart at free.fr
Thu Dec 26 21:53:33 CET 2013


Hello,

How to deal with AAC priming when I join files ?

AAC imply priming (and padding) as describe in 
https://developer.apple.com/library/mac/technotes/tn2258/_index.html.

Normally, AAC's decoder deal with this and suppress blank sound at the 
begin and at the end of file.

How can I join several mp4/AAC file, without reencoding ?

I can't use concat because ffmpeg see only 1 input, so the primping of 
the second (and others) file isn't suppressed.


The mp4 file came from :

udp stream -> TS file
ffmpeg -i udp://$AdresseIP:5000 -threads 1 -force_key_frames 1 -c:a mp2 
-c:v mpeg2video -map 0 -f segment -segment_time 30.000 
-segment_time_delta 0.005 /tmp/segment/video_%03d.ts
ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
   built on Dec 20 2013 15:33:41 with gcc 4.7 (Debian 4.7.2-5)
   configuration: --prefix=/home/yacuser/ffmpeg_build 
--extra-cflags=-I/home/yacuser/ffmpeg_build/include 
--extra-ldflags=-L/home/yacuser/ffmpeg_build/lib --extra-libs=-ldl 
--enable-gpl --enable-libass --enable-libaacplus --enable-libx264 
--enable-nonfree
   libavutil      52. 48.101 / 52. 48.101
   libavcodec     55. 39.101 / 55. 39.101
   libavformat    55. 19.104 / 55. 19.104
   libavdevice    55.  5.100 / 55.  5.100
   libavfilter     3. 90.100 /  3. 90.100
   libswscale      2.  5.101 /  2.  5.101
   libswresample   0. 17.104 /  0. 17.104
   libpostproc    52.  3.100 / 52.  3.100
[mpeg2video @ 0x23f8fe0] Invalid frame dimensions 0x0.
     Last message repeated 22 times
Input #0, mpegts, from 'udp://226.168.22.8:5000':
   Duration: N/A, start: 76691.618500, bitrate: 192 kb/s
   Program 515
     Stream #0:0[0x140]: Video: mpeg2video (Main) ([2][0][0][0] / 
0x0002), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 
fps, 25 tbr, 90k tbn, 50 tbc
     Stream #0:1[0x14a](fra): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 
Hz, stereo, s16p, 192 kb/s
Output #0, segment, to '/yacast/segment/video_%03d.ts':
   Metadata:
     encoder         : Lavf55.19.104
     Stream #0:0: Video: mpeg2video, yuv420p, 720x576 [SAR 64:45 DAR 
16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
     Stream #0:1(fra): Audio: mp2, 48000 Hz, stereo, s16, 128 kb/s
Stream mapping:
   Stream #0:0 -> #0:0 (mpeg2video -> mpeg2video)
   Stream #0:1 -> #0:1 (mp2 -> mp2)
Press [q] to stop, [?] for help
frame=47392 fps= 25 q=31.0 size=N/A time=00:31:35.60 bitrate=N/A dup=27 
drop=0



TS file -> mp4/m4a file (I give only the audio/only command)

ffmpeg -i ts/audio_${i}.ts -c:a libaacplus -ab 64k -ac 2 
mp4/audio_${i}.m4a; done
ffmpeg version 1.2.4 Copyright (c) 2000-2013 the FFmpeg developers
   built on Nov 29 2013 19:09:44 with gcc 4.7 (Debian 4.7.2-5)
   configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector 
--param=ssp-buffer-size=4 -Wformat -Werror=format-security ' 
--extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared 
--enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis 
--enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc 
--enable-x11grab --enable-libgsm --enable-libtheora 
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 
--enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx 
--enable-libschroedinger --disable-encoder=libschroedinger 
--enable-version3 --enable-libopenjpeg --enable-librtmp 
--enable-avfilter --enable-libfreetype --enable-libvo-aacenc 
--disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus 
--libdir=/usr/lib/i386-linux-gnu --disable-vda --enable-libbluray 
--enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl 
--enable-libass --enable-libopus --enable-fontconfig --enable-libpulse 
--disable-mips32r2 --disable-mipsdspr1 --disab  libavutil      52. 
18.100 / 52. 18.100
   libavcodec     54. 92.100 / 54. 92.100
   libavformat    54. 63.104 / 54. 63.104
   libavdevice    54.  3.103 / 54.  3.103
   libavfilter     3. 42.103 /  3. 42.103
   libswscale      2.  2.100 /  2.  2.100
   libswresample   0. 17.102 /  0. 17.102
   libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0x89964c0] max_analyze_duration 5000000 reached at 5015467 
microseconds
Input #0, mpegts, from 'ts/audio_000.ts':
   Duration: 00:00:29.99, start: 0.000000, bitrate: 182 kb/s
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Audio: mp2 ([3][0][0][0] / 0x0003), 44100 Hz, 
stereo, s16p, 128 kb/s
Output #0, ipod, to 'mp4/audio_000.m4a':
   Metadata:
     encoder         : Lavf54.63.104
     Stream #0:0: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 
64 kb/s
Stream mapping:
   Stream #0:0 -> #0:0 (mp2 -> libaacplus)
Press [q] to stop, [?] for help
size=     242kB time=00:00:30.04 bitrate=  65.9kbits/s
video:0kB audio:235kB subtitle:0 global headers:0kB muxing overhead 
2.930555%

For the concatenation, I try MP4Box (with -inter 0) :

MP4Box -inter 0 -force-cat -cat mp4/audio_000.m4a -cat mp4/audio_001.m4a 
-cat mp4/audio_002.m4a -new mp4/segment_mp4box.m4a
Appending file mp4/audio_000.m4a
No suitable destination track found - creating new one (type soun)
Appending file mp4/audio_001.m4a
WARNING: Concatenating track ID 1 even though sample descriptions do not 
match
Appending file mp4/audio_002.m4a
WARNING: Concatenating track ID 1 even though sample descriptions do not 
match
Setting up iTunes/iPod file...
Saving mp4/segment_mp4box.m4a: Flat storage

Regards,
Sorry for my poor english.
Fabrice.


More information about the ffmpeg-user mailing list