View Full Version : Peak Bitrate, or Bitrate Graph?
gongloo
23rd March 2008, 23:57
I'm looking for a way to find the peak bitrate for my x264 encodes, or even better still a way to generate bitrate statistics and/or graph. Bonus points if it's open source and runs on Linux.
Thanks in advance for any pointers you my provide.
Guest
24th March 2008, 00:03
DGAVCIndex's info dialog shows current, average, and maximum bitrate.
gongloo
24th March 2008, 01:24
As I understand, those bitrate statistics are running averages over a given window (of 30 frames, I believe). I'm looking for the peak bitrate over the whole encode.
Guest
24th March 2008, 01:45
Thanks for pointing that out. The manual is in error. The max value is the max encountered over the entire play/preview operation. I will correct the manual.
gongloo
24th March 2008, 03:24
Thanks! I'll definitely give that a shot, then. Know of any Linux solutions (aside from running DGAVCIndex under wine)?
drmpeg
24th March 2008, 04:18
I'm looking for a way to find the peak bitrate for my x264 encodes, or even better still a way to generate bitrate statistics and/or graph. Bonus points if it's open source and runs on Linux.
Thanks in advance for any pointers you my provide.
You mean like this?
http://www.w6rz.net/foxbits.png
http://www.w6rz.net/foxzoom.png
http://www.w6rz.net/foxbps.png
The graphing program is xvgr.
Ron
gongloo
24th March 2008, 04:23
You mean like this?
Yes, exactly like that! What are you using to generate your input to xvgr, though? That's what I'm really after.
drmpeg
24th March 2008, 04:36
Yes, exactly like that! What are you using to generate your input to xvgr, though? That's what I'm really after.
Does x264 insert access unit delimiters into the bitstream? You can check with h264_parse.
http://www.w6rz.net/h264_parse.zip
C:\xfer>h264_parse bits0001.mpv | more
h264_parse - mpeg4ip version 1.5.0.1
Nal length 6 start code 4 bytes <-----------------
ref 0 type 9 Access unit delimeter
primary_pic_type: 0
Nal length 47 start code 4 bytes
ref 3 type 7 Sequence parameter set
profile: 100
constaint_set0_flag: 0
constaint_set1_flag: 0
constaint_set2_flag: 0
constaint_set3_flag: 0
level_idc: 41
seq parameter set id: 0
chroma format idx: 1
bit depth luma minus8: 0
bit depth chroma minus8: 0
Qpprime Y Zero Transform Bypass flag: 0
Seq Scaling Matrix Present Flag: 0
log2_max_frame_num_minus4: 12
pic_order_cnt_type: 0
log2_max_pic_order_cnt_lsb_minus4: 12
num_ref_frames: 4
gaps_in_frame_num_value_allowed_flag: 0
pic_width_in_mbs_minus1: 119 (1920)
pic_height_in_map_minus1: 67
frame_mbs_only_flag: 1
derived height: 1088
direct_8x8_inference_flag: 1
frame_cropping_flag: 1
frame_crop_left_offset: 0
frame_crop_right_offset: 0
frame_crop_top_offset: 0
frame_crop_bottom_offset: 4
vui_parameters_present_flag: 1
aspect_ratio_info_present_flag: 1
aspect_ratio_idc:1
overscan_info_present_flag: 0
video_signal_info_present_flag: 1
video_format: 2
video_full_range_flag: 0
colour_description_present_flag: 1
colour_primaries: 1
transfer_characteristics: 1
matrix_coefficients: 1
chroma_loc_info_present_flag: 0
timing_info_present_flag: 1
num_units_in_tick: 1001
time_scale: 48000
If there are access unit delimiters, it's pretty easy to write a little program to count the bits.
Ron
drmpeg
24th March 2008, 04:46
If there are access unit delimiters, you can try this little program.
/*
H.264 bits per access unit
*/
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
int main(int argc, char **argv)
{
FILE *fp;
static unsigned char buffer[16384];
int i, length;
static int first = TRUE;
static unsigned int parse = 0;
unsigned int picture_size = 0;
if (argc != 2) {
fprintf(stderr, "usage: bits <infile>\n");
exit(-1);
}
/*--- open binary file (for parsing) ---*/
fp = fopen(argv[1], "rb");
if (fp == 0) {
fprintf(stderr, "Cannot open bitstream file <%s>\n", argv[1]);
exit(-1);
}
while(!feof(fp)) {
length = fread(&buffer[0], 1, 16384, fp);
for(i = 0; i < length; i++) {
parse = (parse << 8) + buffer[i];
if (parse == 0x00000109) {
if (first == TRUE) {
first = FALSE;
picture_size = 0;
}
else {
printf("%d\n", picture_size * 8);
picture_size = 0;
}
}
picture_size++;
}
}
fclose(fp);
return 0;
}
Ron
akupenguin
24th March 2008, 05:23
Does x264 insert access unit delimiters into the bitstream?
If and only if you enable --aud.
vpupkind
24th March 2008, 19:24
Get (via mpeg4ip utils, e.g. h264_parse or (in case of a hinted MP4 file) mp4videoinfo) a list of NAL unit sizes and their timestamps.
Discard all non-video (e.g. SEI) NAL units. You can do the same just by looking for 0x000003 NAL start prefix and examining the next byte (which is the NAL header).
Calculate bitrates over a sliding window of the size you want (e.g. 1sec, 2 sec, etc.) for more meaningful results.
brunogm
24th March 2008, 20:18
In the Brazilian DTV is used h264 but the limitations are L4.0 and 20MBps max bitrate, also 1080i. So somebody can tell me if x264 can be used to make compatible broadcasting transport streams.
I mean to convert other files.
thanks
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.