'FFmpeg re-wrap of a TS-AAC audio transport stream file to M4A-AAC: what happens by default (no "-codec copy" etc.)?
What happens if you simply do ffmpeg -i aFile.ts aFile.m4a as opposed to ffmpeg -i aFile.ts -codec copy aFile.m4a, when the TS file contains only a single stream, namely AAC, and knowing that m4a files also typically contain AAC.
Does ffmpeg - even in the absence of any filters etc. - decode the original AAC and re-encode back to AAC (with whatever default parameters ffmpeg assumes for that - not necessarily matching those of the original)? Or does it do something else?
I tried this both with and without "-codec copy" and the results in each case were AAC but the files were significantly different in size (Original TS: 8.5 MB, ffmpeg'd without "-codec copy" 7 MB, ffmpeg'd with latter 5.1 MB.
At https://ffmpeg.org/ffmpeg.html it is stated (under "3.2 Stream copy"...
Stream copy is a mode selected by supplying the copy parameter to the -codec option. It makes ffmpeg omit the decoding and encoding step for the specified stream, so it does only demuxing and muxing. It is useful for changing the container format or modifying container-level metadata. Implied by the inverse of that situation is that, in the absence of "-codec copy", ffmpeg will carry out the decoding and encoding steps.
Solution 1:[1]
Does ffmpeg - even in the absence of any filters etc. - decode the original AAC and re-encode back to AAC (with whatever default parameters ffmpeg assumes for that - not necessarily matching those of the original)?
This is correct. You can look up the default setups via
ffmpeg -h muxer=mp4
This prints out a lot of info, mostly the muxer specific output options, but right at the top it says:
Muxer mp4 [MP4 (MPEG-4 Part 14)]:
Common extensions: mp4.
Mime type: video/mp4.
Default video codec: h264.
Default audio codec: aac.
So, .m4a output file by default uses aac audio encoder.
Then, you can try to get the details on the aac encoder by
ffmpeg -h encoder=aac
This returns
General capabilities: delay small
Threading capabilities: none
Supported sample rates: 96000 88200 64000 48000 44100 32000 24000 22050 16000 12000 11025 8000 7350
Supported sample formats: fltp
AAC encoder AVOptions:
-aac_coder <int> E...A...... Coding algorithm (from 0 to 2) (default twoloop)
anmr 0 E...A...... ANMR method
twoloop 1 E...A...... Two loop searching method
fast 2 E...A...... Default fast search
-aac_ms <boolean> E...A...... Force M/S stereo coding (default auto)
-aac_is <boolean> E...A...... Intensity stereo coding (default true)
-aac_pns <boolean> E...A...... Perceptual noise substitution (default true)
-aac_tns <boolean> E...A...... Temporal noise shaping (default true)
-aac_ltp <boolean> E...A...... Long term prediction (default false)
-aac_pred <boolean> E...A...... AAC-Main prediction (default false)
-aac_pce <boolean> E...A...... Forces the use of PCEs (default false)
So, the builtin AAC encoder uses the default -b:a / -q:a options to set its default bitrate/quality, and neither of which default values we don't know without deep-diving into the source.
Last but perhaps the most important, there is a FFmpeg wiki entry on AAC encoding if you haven't seen it already.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kesh |
