[FFmpeg-user] Encoding multiple files for adaptive bit rate streaming using RTMP and HLS

Joel Lopez badassmexican at gmail.com
Tue May 12 21:08:02 CEST 2015


Thanks for the advice.  Now I guess I should encode a video using
double pass and CFR and compare them.  There seems to be a hot debate
about which is best.

The settings below are what the apple.com recommends for 4:3.  Forgive
my slowness but I'm having a tough time converting what sites
recommend into ffmpeg commands.  Now especially double pass and CFR.


>From the wiki page on encoding for streaming they show this example
https://trac.ffmpeg.org/wiki/EncodingForStreamingSites

ffmpeg -i input.mkv -vcodec libx264 -preset medium -maxrate 3000k
-bufsize 6000k \
-vf "scale=1280:-1,format=yuv420p" -g 50 -acodec libmp3lame -b:a 128k
-ac 2 -ar 44100 file.flv

so is this how I should change it?  attempting the highest and lowest

ffmpeg -i input.mp4 -vcodec libx264 -preset medium -maxrate 264k -bufsize 500k \
-vf "scale=400:-1,format=yuv420p" -g 50 -acodec aac -b:a 64k -ac 2 -ar
48000 output_400.mp4

ffmpeg -i input.mp4 -vcodec libx264 -preset medium -maxrate 5120k
-bufsize 10000k \
-vf "scale=1280:-1,format=yuv420p" -g 50 -acodec aac -b:a 128k -ac 2
-ar 48000 output_1280.mp4

I'm totally guessing on -bufsize by doubling the -maxrate.  What
should it actually be?
Also on the scale, what's the difference between -1 and -2?
Since the -g = 50 does this mean my keyframes will be aligned 5 seconds apart?

400x300
Frame Rate = 12
Total Bit Rate = 264
Video Bit Rate = 200
Audio Bit Rate = 64
Audio Sample Rate = 48
Keyframe = 36
Profile = Baseline, 3.0
B-frames = 0
Segment Size = 9

480x360
Frame Rate = 15
Total Bit Rate = 464
Video Bit Rate = 400
Audio Bit Rate = 64
Audio Sample Rate = 48
Keyframe = 45
Profile = Baseline, 3.0
B-frames = 0
Segment Size = 9

640x480
Frame Rate = 29.97
Total Bit Rate = 664
Video Bit Rate = 600
Audio Bit Rate = 64
Audio Sample Rate = 48
Keyframe = 90
Profile = Baseline, 3.0
B-frames = 0
Segment Size = 9

640x480
Frame Rate = 29.97
Total Bit Rate = 1296
Video Bit Rate = 1200
Audio Bit Rate = 96
Audio Sample Rate = 48
Keyframe = 90
Profile = Baseline, 3.1
B-frames = 0
Segment Size = 9

960x720
Frame Rate = 29.97
Total Bit Rate = 3596
Video Bit Rate = 3500
Audio Bit Rate = 96
Audio Sample Rate = 48
Keyframe = 90
Profile = Main, 3.1
B-frames = as needed
Segment Size = 9

1280x960
Frame Rate = 29.97
Total Bit Rate = 5128
Video Bit Rate = 5000
Audio Bit Rate = 128
Audio Sample Rate = 48
Keyframe = 90
Profile = Main, 3.1
B-frames = as needed
Segment Size = 9

On Tue, May 12, 2015 at 10:36 AM, Henk D. Schoneveld <belcampo at zonnet.nl> wrote:
>
> On 12 May 2015, at 16:32, Henk D. Schoneveld <belcampo at zonnet.nl> wrote:
>
>>
>> On 12 May 2015, at 15:50, Werner Robitza <werner.robitza at gmail.com> wrote:
>>
>>> On Tue, May 12, 2015 at 3:16 PM, Henk D. Schoneveld <belcampo at zonnet.nl> wrote:
>>>>
>>>>> On 12 May 2015, at 13:50, Werner Robitza <werner.robitza at gmail.com> wrote:
>>>>>
>>>>> On Tue, May 12, 2015 at 11:47 AM, Henk D. Schoneveld <belcampo at zonnet.nl> wrote:
>>>>>> Would you be so kind to explain why to NOT use the crf option?
>>>>>
>>>>> CRF is essentially a constant quality mode, which results in variable
>>>>> bitrate depending on the spatiotemporal complexity of the scenes.
>>>> Your goal is max quality within a given link-capacity I assume.
>>>> Upfront choosing an arbitrary bitrate to achieve max possible quality seems sub-optimal/contradictionary to me.
>>>> A. to many bits for talking heads
>>>> B. to few bits for action dominant events.
>>>
>>> Yes, but that's still what's typically done, unless you choose a CQ
>>> encoding type with a max-rate (which is what libvpx recommends too).
>> But libvpx is much less efficient than libx264 for the same quality.
>>>
>>> You should've mentioned that you're experienced with this -- otherwise
>>> I would've given a different answer.
>> Hm what difference does it make if I know a little bit more or less to how/what you’re answering ?
>> Another option to ‘optimise’ quality for a given bitrate is to use anamorphic encoding. I know YouTube doesn’t accept that but all modern players I know of handle it without any problem.
>> For 720p I use -s 880x720 which works for me pretty well. With this you’ll get a reduction of (1280-880)/1280=31% in needed bits for very reasonable quality. At least a lot better then reducing the bitrate by that % and using 1:1 ie. -s 1280x720 encoding.
> Test results by doing as forementioned
> 2442734 May 12  2015 Source_Code-crf22-1280.mp4
> 1656672 May 12  2015 Source_Code-crf22-880.mp4
> 2045725 May 12  2015 Source_Code-crf23-1280.mp4
> 1403091 May 12  2015 Source_Code-crf23-880.mp4
>
> This are video only files.
>>>
>>>> I see the difference between the methods, but I don’t really understand what it’s trying to tel me. What does the X-axis say, total stream-size/#frames/ ?
>>>
>>> It's the frame number (index) in a 3 minute sequence.
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list