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 > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th April 2012, 09:52   #41  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
What if I'd like to change the quantizer value to a specific fixed bitrate value? Or can I use the command --bitrate for this purpose) such as --bitrate xxx --qpfile?
Yes, if CBR or ABR is fine and you don't need different manually specified sizes for different frames. Just set quantizers to -1 in qpfile and use whatever rate control you want.

Quote:
Originally Posted by skyjuice View Post
To use qpfile, I just have to type the contents in a text file and name it qpfile and run it using --qpfile, right?
You can name the text file whatever.xyz and run x264 with --qpfile whatever.xyz
nm is offline   Reply With Quote
Old 17th April 2012, 11:18   #42  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
As a side note: "-1" can be omitted. So:
Code:
0 K -1
645 K -1
8456 K -1
is the same as:
Code:
0 K
645 K
8456 K
sneaker_ger is offline   Reply With Quote
Old 17th April 2012, 17:46   #43  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Quote:
Originally Posted by nm View Post
Yes, if CBR or ABR is fine and you don't need different manually specified sizes for different frames. Just set quantizers to -1 in qpfile and use whatever rate control you want.
The problem is I need to specify a higher fixed bitrate for I-frame and lower fixed bitrate value for P-frame. Is this possible using any of the methods discussed before?
skyjuice is offline   Reply With Quote
Old 20th April 2012, 17:33   #44  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Anyway, I tried using the command

Code:
ffmpeg -i input.mp4 -f image2 frame-%03d.pgm
after encoding my sequence of pgm file and the result is individual decoded frames. To calculate the PSNR of the first frame (original and decoded), I used the command pnmpsnr [original] [decoded] and was told that

Quote:
images do not have the same maxval. The first image has maxval 65535 while the second has 255
I believe this is due to the process where x264 has compressed some bit per pixel out of the image. Is there anyway to rectify this?
skyjuice is offline   Reply With Quote
Old 20th April 2012, 17:37   #45  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by skyjuice View Post
The problem is I need to specify a higher fixed bitrate for I-frame and lower fixed bitrate value for P-frame. Is this possible using any of the methods discussed before?
Why? Usually you only have a single I-Frame once in a while. Talking about a "bit rate" (which usually is expressed as kilobits per second) for a single frame that only lasts for 1/25 or 1/50 second is kind of strange.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 20th April 2012, 18:28   #46  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
Quote:
images do not have the same maxval. The first image has maxval 65535 while the second has 255
I believe this is due to the process where x264 has compressed some bit per pixel out of the image. Is there anyway to rectify this?
You have 16-bit images as source and x264 converts them to 8-bit before actually encoding them. One option is to convert the original images to a suitable format yourself, so that x264 won't preprocess the input and the final PSNR score isn't influenced by different conversions. The most common format is 8-bit YUV 4:2:0, but other subsamplings and even RGB are possible if you instruct x264 properly. 10-bit video can be encoded with a 10-bit enabled x264 build.

With grayscale images, you don't need to worry about chroma subsampling, but you might want to dither if the original source is really 16-bit and not upconverted 8-bit. ImageMagick's convert tool should do the trick, for example. Or even ffmpeg if you don't need fancy dithering.
nm is offline   Reply With Quote
Old 5th May 2012, 07:19   #47  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Anyway, I solved the problem by using the 'compare' command to get the PSNR output. One thing that puzzles me is the --bitrate option.

1) Why is it the encoded bitrate is not the same as the one that I specified? For example, when I type:
Code:
x264 img_%04d.pgm --bitrate 500 -o outputvideo.mkv
I get "encoded 8 frames, 3.52 fps, 1069.47 kb/s" instead. The same goes for "--fps" command.

2) Is it possible to specify the bitrate value, say 500.54 instead of 500? As I know x264 only accepts integer value.
skyjuice is offline   Reply With Quote
Old 5th May 2012, 08:54   #48  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
1 - 8 frames is far too short for rate control to do anything. Use 2-pass if you need a specific size or use crf.
2 - No. A modification to allow bits/s to be set might be possible but is it really necessary? Rate control probably is not precise enough for that anyway.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 11th May 2012, 09:08   #49  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Is it possible if I want to specify the decoded frames to be of certain bitrate in term of bit/pixels? I am trying to plot a graph of PSNR vs bitrate (bit/pixel) which looks something like this

skyjuice is offline   Reply With Quote
Old 16th May 2012, 15:42   #50  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Quote:
Originally Posted by J_Darnley View Post
1 - 8 frames is far too short for rate control to do anything. Use 2-pass if you need a specific size or use crf.
2 - No. A modification to allow bits/s to be set might be possible but is it really necessary? Rate control probably is not precise enough for that anyway.
I still dont quite get it here. I need to have a constant rate control (using --fps and --bitrate) so that I get a fair output for comparison. How many frames should I be using to ensure that the encoder can apply the value of fps or bitrate that I enter because right now I got the following message whenever i encode

Quote:
Stream #0: not enough frames to estimate rate; consider increasing probesize

Last edited by skyjuice; 16th May 2012 at 16:21.
skyjuice is offline   Reply With Quote
Old 16th May 2012, 17:54   #51  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
I still dont quite get it here. I need to have a constant rate control (using --fps and --bitrate) so that I get a fair output for comparison. How many frames should I be using to ensure that the encoder can apply the value of fps or bitrate that I enter because right now I got the following message whenever i encode
You'll need about 50 to 100 frames and run two passes:

x264 --bitrate 500 --pass 1 -o output.264 input
x264 --bitrate 500 --pass 2 -o output.264 input

Or perhaps more if you want accurate results with a short clip:

x264 --bitrate 500 --pass 1 -o output.264 input
x264 --bitrate 500 --pass 3 -o output.264 input (--pass 3 is not a typo here!)
x264 --bitrate 500 --pass 3 -o output.264 input
x264 --bitrate 500 --pass 3 -o output.264 input
...

But if three passes isn't accurate enough, fourth isn't going to help. You'll need a longer clip then.


IMO, 8 frames is not enough for any video testing. You need at least a couple seconds at a realistic framerate (10 to 60 fps) for real world video comparisons.

Quote:
Originally Posted by skyjuice View Post
Stream #0: not enough frames to estimate rate; consider increasing probesize
That message comes from libav/FFmpeg which demuxes and decodes your input video. Use --force-cfr --fps 25 (or whatever your real framerate is) to override its guesses.

Last edited by nm; 16th May 2012 at 17:58.
nm is offline   Reply With Quote
Reply

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 19:14.


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