Convert .mp4 to .mpeg4 using Converter - python-3.x

I have an MP4 file, which I would like to convert into an MPEG4 file. TO do this, I have found the PythonVideoConvert package. On the PyPI page, the following code is given:
from converter import Converter
conv = Converter()
info = conv.probe('test/test1.avi')
PATH = 'C:/Users/.../'
convert = conv.convert(PATH +'Demo.mp4', PATH + 'Demo.mpeg4', {
'format': 'mpeg4',
'audio': {
'codec': 'aac',
'samplerate': 11025,
'channels': 2
},
'video': {
'codec': 'hevc',
'width': 720,
'height': 400,
'fps': 25
}})
When I run this code, a convert object is created. However, there is no .mpeg4 video in the PATH directory.
Therefore, I have two questions:
Is the code above correct for converting a .mp4 file into a .mpeg4 file
What do I need to run to save the converted video as a .mpeg4 file?
Based on Selcuk's comment, I ran the following code:
for timecode in convert:
pass
This gives the error:
Traceback (most recent call last):
File "<ipython-input-60-14c9225c3ac2>", line 1, in <module>
for timecode in convert:
File "C:\Users\20200016\Anaconda3\lib\site-packages\converter\__init__.py", line 229, in convert
optlist = self.parse_options(options, twopass)
File "C:\Users\20200016\Anaconda3\lib\site-packages\converter\__init__.py", line 60, in parse_options
raise ConverterError(f'Requested unknown format: {str(f)}')
ConverterError: Requested unknown format: mpeg4
So, my suggested format seems incorrect. What can I do to convert a video into .mpeg4?

I don't think PythonVideoConverter is meant to be used in Windows.
I was getting an exception AttributeError: module 'signal' has no attribute 'SIGVTALRM', because SIGVTALRM is not a valid signal in Windows.
The default path of FFmpeg an FFprobe command line tools, also doesn't make sense for Windows.
We may still use the package in Windows, but it's recommended to set ffmpeg_path and ffprobe_path.
Example:
conv = Converter(ffmpeg_path=r'c:\FFmpeg\bin\ffmpeg.exe', ffprobe_path=r'c:\FFmpeg\bin\ffprobe.exe')
We also have to disable the timeout feature, by setting timeout=None argument.
mpeg4 is not a valid FFmpeg format, but we can still use it as a file extension.
(format is FFmpeg terminology usually applies container format).
When non-standart file extension is used, we have to set the format entry.
Setting 'format': 'mp4' creates MP4 file container (may be created with the non-standart .mpeg4 file extension).
Complete code sample:
from converter import Converter
conv = Converter(ffmpeg_path=r'c:\FFmpeg\bin\ffmpeg.exe', ffprobe_path=r'c:\FFmpeg\bin\ffprobe.exe')
#info = conv.probe('test/test1.avi')
PATH = 'C:/Users/Rotem/'
convert = conv.convert(PATH + 'Demo.mp4', PATH + 'Demo.mpeg4', {
'format': 'mp4', #'format': 'mpeg4',
'audio': {
'codec': 'aac',
'samplerate': 11025,
'channels': 2
},
'video': {
'codec': 'hevc',
'width': 720,
'height': 400,
'fps': 25
}},
timeout=None)
# https://pypi.org/project/PythonVideoConverter/
for timecode in convert:
print(f'\rConverting ({timecode:.2f}) ...')
We may see the media information of Demo.mpeg4 using MediaInfo tool:
General
Complete name : C:\Users\Rotem\Demo.mpeg4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/mp41)
File size : 207 KiB
Duration : 10 s 148 ms
Overall bit rate mode : Variable
Overall bit rate : 167 kb/s
Writing application : Lavf58.45.100
FileExtension_Invalid : braw mov mp4 m4v m4a m4b m4p m4r 3ga 3gpa 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma ismt f4a f4b f4v
Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main#L3#Main
Codec ID : hev1
Codec ID/Info : High Efficiency Video Coding
Duration : 10 s 0 ms
Bit rate : 82.5 kb/s
Width : 720 pixels
Height : 400 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.011
Stream size : 101 KiB (49%)
Writing library : x265 3.4+28-419182243:[Windows][GCC 9.3.0][64 bit] 8bit+10bit+12bit
Encoding settings : ...
Color range : Limited
Codec configuration box : hvcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 10 s 148 ms
Duration_LastFrame : -70 ms
Bit rate mode : Variable
Bit rate : 79.1 kb/s
Maximum bit rate : 128 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 11.025 kHz
Frame rate : 10.767 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 98.0 KiB (47%)
Title : IsoMedia File Produced by Google, 5-11-2011
Language : English
Default : Yes
Alternate group : 1
In MediaInfo output, the MP4 file container applies "MPEG-4" format...
Note:
The HEVC video format applies H.265 video codec - in most cases the codec is considered to be more relevant then container.

'Requested unknown format: mpeg4'
*.mpeg4 is not valid container. mpeg4 is codec, *.something (avi, mp4, mov, mkv, ...) are containers.
basicly: codec.CONTAINER or your_mpeg4_video.mkv etc.
video codec (like mpeg4) handle only video, but you need more than only visual, you need audio, many audio tracks (eng, de, nl, 2.0, 5.1, 7.1 ...), subtitles, etc and these stuff are inside container.
install ffmpeg: https://ffmpeg.org/
try this basic script:
import subprocess
input_file = 'Demo.mp4'
output_file = 'Demo.mkv' # or .mp4, .mov, ...
ffmpeg_cli = "ffmpeg -i '{}' -vcodec libx265 '{}'".format(input_file, output_file)
subprocess.call(ffmpeg_cli, shell=True)
I don't know what are you doing (what you want, what are your expectations) but if you looking for way how to degrese size of video,
look here: https://github.com/MarcelSuleiman/convert_h264_to_h265
simple.

Related

3GP video with "jpeg" video codec

I have cheap feature phone which can record videos in 3gp file format. When I upload such video to computer and inspect it with mediainfo it gives mysteriuos output:
Format : MPEG-4
Format profile : 3GPP Media Release 5
Codec ID : 3gp5 (3gp5)
File size : 4.69 MiB
Duration : 1 min 7 s
Overall bit rate : 585 kb/s
Encoded date : UTC 1970-01-01 00:02:13
Tagged date : UTC 1970-01-01 00:02:13
Video
ID : 2
Format : JPEG
Codec ID : jpeg
Duration : 1 min 7 s
Source duration : 1 min 7 s
Bit rate : 571 kb/s
Width : 240 pixels
Height : 320 pixels
Display aspect ratio : 0.750
Frame rate mode : Variable
Frame rate : 9.137 FPS
Minimum frame rate : 3.686 FPS
Maximum frame rate : 17.192 FPS
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.813
Stream size : 4.57 MiB (97%)
Source stream size : 4.57 MiB (97%)
Language : English
Encoded date : UTC 1970-01-01 00:02:13
Tagged date : UTC 1970-01-01 00:02:13
mdhd_Duration : 67133
The video codec is "JPEG".
When I play video in Totem Video Player, codec name is "JPEG still images".
I tested that my phone doesn't support MJPEG and mediainfo shows that codec is (also) identified as MPEG-4. When I opened video in hex editor it appeared as sequences of JPEG images, which shouldn't be possible (3gp container supports H.263 and MPEG-4 not MJPEG). On the other hand sample video converted to 3gp MPEG-4 gives this mediainfo output:
Format profile : 3GPP Media Release 4
Codec ID : 3gp4 (isom/iso2/3gp4)
File size : 1.84 MiB
Duration : 16 s 50 ms
Overall bit rate mode : Variable
Overall bit rate : 960 kb/s
Video
ID : 1
Format : MPEG-4 Visual
Format profile : Simple#L3
Format settings, BVOP : No
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (H.263)
Codec ID : mp4v-20
Duration : 16 s 50 ms
Bit rate mode : Variable
Bit rate : 659 kb/s
Maximum bit rate : 1 000 kb/s
Width : 240 pixels
Height : 180 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 20.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.763
Stream size : 1.26 MiB (69%)
Title : ISO Media file produced by Google Inc.
Writing library : XviD 69
So as you can see technically it is also MPEG-4. Totem identifies this second video as MPEG-4.
Second video is playable on my phone.
My question is how can I make/encode my own 3gp video with "jpeg" video codec?
Chipset of my phone is sc6531e (datasheet is avaliable in internet)
I have figured it out, it is just Apple Quicktime MJPEG codec. It is not compatibile with 3GP container, it is intended to work with MOV. My phone just changes few bytes in header and makes it look like 3GP although it is MOV. Here are the specs:
https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFPreface/qtffPreface.html.

convert G.723.1 to normal wav and split channels?

I have a wav file who's info is
ion#aurora:~/Inbound$ mediainfo 48401-3405-48403--18042018170000.wav
General
Complete name : 48401-3405-48403--18042018170000.wav
Format : Wave
File size : 327 KiB
Duration : 4mn 11s
Overall bit rate : 10.7 Kbps
Audio
Format : G.723.1
Codec ID : A100
Duration : 4mn 11s
Bit rate : 10.7 Kbps
Channel(s) : 2 channels
Sampling rate : 8 000 Hz
Stream size : 327 KiB (100%)
and the audacity shows like this
To tackle it I tried
ffmpeg -i 48401-3405-48403--18042018170000.wav -f wav test.wav
But it just appends the second channel at the back of first channel , So I get only single channel.
and its media info is:
ion#aurora:~/Inbound$ mediainfo test.wav
General
Complete name : test.wav
Format : Wave
File size : 7.67 MiB
Duration : 8mn 22s
Overall bit rate mode : Constant
Overall bit rate : 128 Kbps
Writing application : Lavf56.40.101
Audio
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 8mn 22s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 1 channel
Sampling rate : 8 000 Hz
Bit depth : 16 bits
Stream size : 7.67 MiB (100%)
Any idea how to solve this?
PS: When I hear the original wav file, It feels like the talking is too fast.
This is how the media info of processed file should look like.
ion#aurora:~/Downloads/Call Recordings$ mediainfo 9417648939\ \(G\ Call\)_Done.wav
General
Complete name : 9417648939 (G Call)_Done.wav
Format : Wave
File size : 8.01 MiB
Duration : 8mn 44s
Overall bit rate mode : Constant
Overall bit rate : 128 Kbps
Audio
Format : ADPCM
Format profile : U-Law
Codec ID : 7
Codec ID/Hint : CCITT
Duration : 8mn 44s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 2 channels
Sampling rate : 8 000 Hz
Bit depth : 8 bits
Stream size : 8.01 MiB (100%)
1) ffmpeg from ubuntu (18.04) repository has a bug (ffmpeg does not detect stereo channel in g723). Use FFmpeg from git repository https://github.com/FFmpeg/FFmpeg
git clone https://github.com/FFmpeg/FFmpeg
cd FFmpeg/ && ./configure --disable-x86asm && make
2) Now you can convert audio:
FFmpeg/ffmpeg -i test.g723 test.wav
3) And separate channels:
FFmpeg/ffmpeg -i test.wav -filter_complex 'channelsplit=channel_layout=stereo[L][R]' -map '[L]' test.wav -map '[R]' test.wav

Replicate the format of a video to another

Let's say I have:
video1.avi which is perfectly played (both sound and image) on my TV's USB media input
video2.avi which is not recognized by the TV: "Imposible to read this format"
I have tried lots of solutions, like:
ffmpeg -i video2.avi -codec:a libmp3lame -q:a 0 -ac 2 -ar 48000 -joint_stereo 0^
-codec:v libxvid -q:v 25 video2_reencoded.avi
and when I compare video1.avi with video2_reencoded.avi with MediaInfo, they look similar in most aspects, but finally the TV won't play video2_reencoded.avi.
Is there a way with ffmpeg, to replicate all the specifications of video1.avi (sound encoding properties, video encoding properties, image size, container type, etc.) on video2.avi?
Appendix: output of MediaInfo for the three videos. In this specific example, video2.avi and video2_reencoded.avi are half-working: image ok but not the sound. In other video examples I tried, video2.avi and video2_reencoded.avi would be both totally "Impossible to read".
video1.avi (i.e. working)
Format : AVI
Format/Info : Audio Video Interleave
File size : 352 MiB
Duration : 51 min 22 s
Overall bit rate : 959 kb/s
Writing application : VirtualDubMod 1.5.10.3 | ... || (build 2550/release)
Writing library : VirtualDubMod build 2550/release
Video
ID : 0
Format : MPEG-4 Visual
Format profile : Advanced Simple#L5
Format settings : BVOP1
Format settings, BVOP : 1
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (MPEG)
Codec ID : XVID
Codec ID/Hint : XviD
Duration : 51 min 22 s
Bit rate : 821 kb/s
Width : 720 pixels
Height : 400 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.114
Stream size : 302 MiB (86%)
Writing library : XviD 1.2.1 (UTC 2008-12-04)
Audio
ID : 1
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 55
Codec ID/Hint : MP3
Duration : 51 min 22 s
Bit rate mode : Constant
Bit rate : 128 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Compression mode : Lossy
Stream size : 47.0 MiB (13%)
Alignment : Aligned on interleaves
Interleave, duration : 40 ms (1.00 video frame)
Interleave, preload duration : 504 ms
Writing library : LAME3.99r
Encoding settings : -m s -V 4 -q 2 -lowpass 17 -b 128
video2.avi (i.e. non-working)
Format : AVI
Format/Info : Audio Video Interleave
File size : 1.37 GiB
Duration : 2 h 12 min
Overall bit rate : 1 478 kb/s
Writing application : VirtualDubMod 1.5.10.2 Fr | ... || (build 2540/release)
Writing library : VirtualDubMod build 2540/release
Video
ID : 0
Format : MPEG-4 Visual
Format profile : Advanced Simple#L5
Format settings : BVOP1
Format settings, BVOP : 1
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (H.263)
Muxing mode : Packed bitstream
Codec ID : XVID
Codec ID/Hint : XviD
Duration : 2 h 12 min
Bit rate : 1 084 kb/s
Width : 624 pixels
Height : 368 pixels
Display aspect ratio : 5:3
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.189
Stream size : 1.00 GiB (73%)
Writing library : XviD 1.2.1 (UTC 2008-12-04)
Audio
ID : 1
Format : AC-3
Format/Info : Audio Coding 3
Codec ID : 2000
Duration : 2 h 12 min
Bit rate mode : Constant
Bit rate : 384 kb/s
Channel(s) : 6 channels
Sampling rate : 48.0 kHz
Compression mode : Lossy
Stream size : 364 MiB (26%)
Alignment : Split accross interleaves
Interleave, duration : 40 ms (1.00 video frame)
Interleave, preload duration : 512 ms
video2_reencoded.avi (i.e. non-working, reencoded, but still non-working)
Format : AVI
Format/Info : Audio Video Interleave
Format profile : OpenDML
File size : 1.13 GiB
Duration : 2 h 12 min
Overall bit rate : 1 227 kb/s
Writing application : Lavf57.26.100
Video
ID : 0
Format : MPEG-4 Visual
Format profile : Advanced Simple#L5
Format settings : BVOP1
Format settings, BVOP : 1
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (H.263)
Muxing mode : Packed bitstream
Codec ID : XVID
Codec ID/Hint : XviD
Duration : 2 h 12 min
Bit rate : 1 084 kb/s
Width : 624 pixels
Height : 368 pixels
Display aspect ratio : 5:3
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.189
Stream size : 1.00 GiB (88%)
Writing library : XviD 1.2.1 (UTC 2008-12-04)
Audio
ID : 1
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 55
Codec ID/Hint : MP3
Duration : 2 h 12 min
Bit rate mode : Constant
Bit rate : 128 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Compression mode : Lossy
Stream size : 120 MiB (10%)
Alignment : Aligned on interleaves
Interleave, duration : 24 ms (0.60 video frame)
Sorry but unfortunately there is no such tool available. Currently the best you can get in this direction is the replication of h264 encoding parameters.

FFMPEG Cutting Commercials puts audio out of sync

Ubuntu 14.04.1 with the real ffmpeg loaded (same problem with the avconv version).
I'm trying to take files created in MythTV with a HDPVR, cut the commercials and put the video into an MP4 container for use with MythRoku.
the command
ffmpeg -i $file -acodec copy -vcodec copy -f mp4 file.mp4
Works fine. Once I update the database, I can watch the file in MythRoku or Plex.
However, when I try to cut out the commercials, the audio gets out of sync by just over 1 second (audio delayed) whenever I cut past the 0 mark. Totem Video player and VLC both play the resulting video fine, but I can see a "hitch" at the beginning while they are syncing the audio, so I know the information on the audio sync is in the file somewhere. Mythroku and Plex both are out of sync when playing the file. The MythTV Frontend player actually does play it correctly, and I can hear the "hitch" as it syncs the audio.
After hours of reading posts and playing with settings, I've got it down to this:
If I say:
ffmpeg -i $file -acodec copy -vcodec copy -f mp4 -ss 0 -t <anything> out.mp4
The file is fine, plays both locally and in MythRoku/Plex
But if I advance the start any amount - even 1 second - audio is out of sync
ffmpeg -i $file -acodec copy -vcodec copy -f mp4 -ss 1 -t <anything> out.mp4
I've tried splitting the video (as mp4) and audio (as ac3) first, splitting them separately, and then putting them back together as the last step, but I get the same results.
The information is in the file - Totem, VLC and the Frontend all can figure it out. How can I get ffmpeg to figure out the sync and write the file so it's correct?
Original file:
mythtv#marvin:~$ mediainfo /var/lib/mythtv/recordings/2225_20140824001500.mpg
General
ID : 0 (0x0)
Complete name : /var/lib/mythtv/recordings/2225_20140824001500.mpg
Format : MPEG-TS
File size : 4.03 GiB
Duration : 1h 45mn
Overall bit rate mode : Variable
Overall bit rate : 5 491 Kbps
Video
ID : 4113 (0x1011)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main#L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Format settings, GOP : M=4, N=32
Codec ID : 27
Duration : 1h 45mn
Bit rate mode : Variable
Bit rate : 4 831 Kbps
Maximum bit rate : 20.0 Mbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 59.940 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.087
Stream size : 3.55 GiB (88%)
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Audio
ID : 4352 (0x1100)
Menu ID : 1 (0x1)
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : 129
Duration : 1h 45mn
Bit rate mode : Constant
Bit rate : 384 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Delay relative to video : -6ms
Stream size : 289 MiB (7%)
File cut from 0:
mythtv#marvin:~$ mediainfo 2225_20140824001500_1.mp4
General
Complete name : 2225_20140824001500_1.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 58.5 MiB
Duration : 1mn 45s
Overall bit rate mode : Variable
Overall bit rate : 4 676 Kbps
Writing application : Lavf54.63.104
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main#L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Format settings, GOP : M=4, N=32
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1mn 45s
Bit rate mode : Variable
Bit rate : 4 281 Kbps
Maximum bit rate : 20.0 Mbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 59.940 fps
Minimum frame rate : 59.920 fps
Maximum frame rate : 59.960 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.077
Stream size : 53.6 MiB (92%)
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : ac-3
Duration : 1mn 45s
Bit rate mode : Constant
Bit rate : 384 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 4.81 MiB (8%)
File cut from 1 second with audio sync problem:
mythtv#marvin:~$ mediainfo 2225_20140824001500_2.mp4
General
Complete name : 2225_20140824001500_2.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 68.0 MiB
Duration : 2mn 0s
Overall bit rate mode : Variable
Overall bit rate : 4 750 Kbps
Writing application : Lavf54.63.104
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main#L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Format settings, GOP : M=4, N=32
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1mn 58s
Bit rate mode : Variable
Bit rate : 4 394 Kbps
Maximum bit rate : 20.0 Mbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 59.940 fps
Minimum frame rate : 59.920 fps
Maximum frame rate : 59.960 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.080
Stream size : 62.3 MiB (92%)
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : ac-3
Duration : 2mn 0s
Bit rate mode : Constant
Bit rate : 384 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 5.49 MiB (8%)

libfaac imposes bitrate limits?

I'm trying to encode some audio on Ubuntu 12.04 Linux. I need to use libfaac (using version 1.28) to encode and I want to encode at a very low bitrate - the total including transport stream overhead must be below 64kbps.
The input audio is: PCM, 48kHz, 2 channel, s16, 1536 kb/s
Using the faac command-line tool, I get the output below, encoding 5 minutes of audio - so there's plenty of time for the bitrate to average out. I cannot get it to go below 64kbps, or above 165kbps for that matter. I have tried setting some of the other parameters, but to no avail. When I set the bitrate > 64, it works fine. Looking through the libfaac code, i don't see anywhere that these limits are being imposed.
$ ./faac -b 40 -w -o /tmp/yellow-audio-40k.mp4 /tmp/yellow-audio.wav
Freeware Advanced Audio Coder
FAAC 1.28
Average bitrate: 64 kbps
Quantization quality: 100
Bandwidth: 5442 Hz
Object type: Low Complexity(MPEG-4) + M/S
Container format: MPEG-4 File Format (MP4)
Encoding /tmp/yellow-audio.wav to /tmp/yellow-audio-40k.mp4
frame | bitrate | elapsed/estim | play/CPU | ETA
14063/14063 (100%)| 64.2 | 10.7/10.7 | 27.91x | 0.0
$ mediainfo /tmp/yellow-audio-40k.mp4
General
Complete name : /tmp/yellow-audio-40k.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42
File size : 2.35 MiB
Duration : 5mn 0s
Overall bit rate mode : Variable
Overall bit rate : 65.7 Kbps
Encoded date : UTC 2012-12-05 00:03:38
Tagged date : UTC 2012-12-05 00:03:49
Writing application : FAAC 1.28
Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 5mn 0s
Bit rate mode : Variable
Bit rate : 64.2 Kbps
Maximum bit rate : 73.7 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 2.30 MiB (98%)
Language : English
Encoded date : UTC 2012-12-05 00:03:38
Tagged date : UTC 2012-12-05 00:03:49

Resources