Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th October 2020, 02:25   #1  |  Link
Starduster
Registered User
 
Starduster's Avatar
 
Join Date: Jun 2007
Location: Ann Arbor, MI
Posts: 117
How force a constant bit rate for audio created with ffmpeg?

I'm putting title pages between video clips and concatenating them together so I need all the clips to be the same. I am creating the title slides with:

Code:
fa=Tone(length=3.0, type="Silence", samplerate=22050, channels=2)
v=BlankClip(90, 960, 540, pixel_type="RGB24", fps=29.97).ConvertToYV12(matrix="rec709").AddAlphaPlane()
AudioDub(v, fa).Subtitle("This is a test", align=5, size=24)
I'm creating the .mp4 clip using ffmpeg with:
Code:
ffmpeg -i gsn_10.avs -b:a 128 gsn_10.mp4
if I use -b:a 128k or don't use that parameter at all, it becomes variable rate and I need constant rate. Using the -b:a 128 makes it constant, but the bit rate doesn't change.

MediaInfo gives: "Bit rate: 1 084 b/s" and all other clips have "Bit rate: 128 kb/s"

The bit rate is the only difference in the clips. When I concat them with:
Code:
ffmpeg -f concat -safe 0 -i render.txt -c copy highlight.mp4
I get a ton of "Non-monotonous DTS in output stream" errors.

The resulting .mp4 is 19+ hours long when I should be about 6 minutes.

So, is there a way to force a constant bit rate of 128kb in AviSynth or do I need to find another way to do that in ffmpeg.
__________________
Life is more interesting viewed upside down
Starduster is offline   Reply With Quote
Old 12th October 2020, 07:36   #2  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,669
Quote:
Originally Posted by Starduster View Post
So, is there a way to force a constant bit rate of 128kb in AviSynth or do I need to find another way to do that in ffmpeg.
Avisynth is a frameserver, i.e it doesn't encode anything, it outputs an uncompressed A/V stream which is "served" to an encoder (in your case, FFMpeg). So... no, you can't "force" a bitrate in Avisynth.
By the way, speaking of FFMpeg, setting -b:a 128k as you've done should set it to CBR (constant bitrate) 'cause AAC needs the flag -vbr to be encoded as variable bitrate.
The only thing I can think about is the fact that you're using the FFMpeg built-in AAC encoder for which this thing might not be true...? (I'm speculating).
Just to be sure, how about trying with libfdk_aac?

Can you try with:

Code:
ffmpeg -i "gsn_10.avs" -c:v libx264 -crf 18 -preset:v medium -ac 2 -c:a libfdk_aac -b:a 128k -f mp4 "gsn_10.mp4"
where the video settings have to be the same as the one of your other video (my command line is just for the sake of completeness) and the audio settings are the ones I provided?

Last edited by FranceBB; 12th October 2020 at 09:31.
FranceBB is offline   Reply With Quote
Old 12th October 2020, 08:41   #3  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,237
The bitrate must be: -b:a 128k

Seems work fine with a ffmpeg with enabled libfdk_aac.

The internal ffmpeg encoder seems can't encode silence at a CBR of 128k(uses 1084 b/s)
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 12th October 2020, 09:32   #4  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,669
Quote:
Originally Posted by tebasuna51 View Post
The bitrate must be: -b:a 128k
Oops. Fixed. I wrote it correctly in the text and I pasted it incorrectly in the code section. xD
I had coffee, but for me it's still early in the morning...
I'm more of a night owl than an early bird...
FranceBB is offline   Reply With Quote
Old 12th October 2020, 12:48   #5  |  Link
Starduster
Registered User
 
Starduster's Avatar
 
Join Date: Jun 2007
Location: Ann Arbor, MI
Posts: 117
Well, Yea!... and Oh crap!.. That did work perfectly but I had to dig around a while to find a version of ffmpeg that contained the libfdk_acc component. I'll have to take a look a what that means since it's "non-free"... (not even sure what that means!) Anyway, thanks for finding the Solution to this!
__________________
Life is more interesting viewed upside down
Starduster is offline   Reply With Quote
Reply

Tags
constant bit rate, ffmpeg audio

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:11.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.