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 29th February 2012, 23:04   #21  |  Link
Brother John
(schein)heilig
 
Brother John's Avatar
 
Join Date: Jun 2003
Location: Germany
Posts: 512
Quote:
Originally Posted by Ghitulescu View Post
The standard might be found here -> http://www-ee.uta.edu/Dip/Courses/EE...andard2007.pdf
Better still: Get the most recent published version directly from the ITU site.
__________________
Brother John

When lost in BeSweet's options, have a look at the Commandline Reference.
DVD nach MPEG-4 klappt nicht? Verzweifelt? Auf zum Encodingwissen!
Brother John is offline   Reply With Quote
Old 6th March 2012, 16:18   #22  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Thanks everyone for their replies. Now I can finally encode my pictures (TIF) to a smaller size with good quality. However, using the default command line I can only encode each picture at once (if I need to compress 5 pics, I would need to encode all 5 of them individually).

Is there a way where I can encode them (say 5 or 10 pics at the input) simultaneously so that the output will also be in the form continuous pictures (video in mkv for example)?
skyjuice is offline   Reply With Quote
Old 6th March 2012, 16:23   #23  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
If your images are named img_0001.tif, img_0002.tif and so on, use the expression "img_%04d.tif" on x264 command line.
nm is offline   Reply With Quote
Old 9th March 2012, 10:11   #24  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Thanks nm for the guide. You helped me a lot. I would like to compare the effectiveness of the in-built deblocking filter of x264. I have done a few readings where there are these alpha (strength) and beta (threshold) parameters. I tried encoding a set of frames with the filter turned-on (default) and turned-off (--no-deblock) and hardly notice any difference.

If I want to disable the deblocking filter (other than using the command line), can I erase them in the source code (e.g x264.c and encoder.c)?

Thank you.
skyjuice is offline   Reply With Quote
Old 9th March 2012, 13:52   #25  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
I would like to compare the effectiveness of the in-built deblocking filter of x264.
Are you going to replace H.264 in-loop deblocking with your own (in which case you need to tweak a decoder too)?

Quote:
Originally Posted by skyjuice View Post
I have done a few readings where there are these alpha (strength) and beta (threshold) parameters.
Yep, they can be set on the command line with --deblock alpha:beta

Quote:
Originally Posted by skyjuice View Post
I tried encoding a set of frames with the filter turned-on (default) and turned-off (--no-deblock) and hardly notice any difference.
Encode at low bitrates for stronger effect. Try with --crf 30

Note that in-loop deblocking is mainly supposed to reduce blocking that is produced during encoding, not blocking that is in the source video! x264 automatically lowers deblocking strength when low quantizers (high bitrate) are used for encoding.

Quote:
Originally Posted by skyjuice View Post
If I want to disable the deblocking filter (other than using the command line), can I erase them in the source code (e.g x264.c and encoder.c)?
You can remove most of the deblocking code, which is also spread around a few other files. Or you could just leave it there and add your own code paths where needed.
nm is offline   Reply With Quote
Old 11th March 2012, 12:04   #26  |  Link
asifjnajua88
Registered User
 
Join Date: Mar 2012
Posts: 6
HI
i try to compile x264 in ubuntu 10.04 and followed the steps given in this website http://ubuntuforums.org/showpost.php...postcount=1289
but in step 7 command ( ./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
--enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx \
--enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab )
gives following error
if you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.
please tell me how i can resolve this .
asifjnajua88 is offline   Reply With Quote
Old 11th March 2012, 14:52   #27  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Quote:
Originally Posted by asifjnajua88 View Post
Include the log file "config.log" produced by configure as this will help solving the problem.
ARGH! Can you not read? You didn't even tell us which of the dozen options you used caused the error.
__________________
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 12th March 2012, 16:05   #28  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
I tried encoding the input at even higher crf values (up to 50) for both with and without the deblocking filter. The video quality obviously degrades in both cases but still, I cant spot the difference between the two ouputs. Can this be due to the fact that I only encode around 65 frames (roughly around 2 seconds) which is too short to observe the difference?

I actually have to compare the usefulness of the current deblocking filter in x264 in term of coding time vs quality tradeoff. Also, I have another deblocking filter called the "Edge Adaptive Deblocking Filter" which was previously employed in MPEG-2 standard and I'm required to put this filter to x264 but the source code of x264 is very complicated. Can this be achievable actually?
skyjuice is offline   Reply With Quote
Old 12th March 2012, 17:28   #29  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
I tried encoding the input at even higher crf values (up to 50) for both with and without the deblocking filter. The video quality obviously degrades in both cases but still, I cant spot the difference between the two ouputs. Can this be due to the fact that I only encode around 65 frames (roughly around 2 seconds) which is too short to observe the difference?
Shouldn't be too short, but it depends on content and how fast you are playing it back. Here's a quick comparison of Bick Buck Bunny opening sequence with deblocking on and off:

CRF 40, default settings: bbb_crf40_deblock.mp4
CRF 40, --no-deblock: bbb_crf40_nodeblock.mp4

Quote:
Originally Posted by skyjuice View Post
Also, I have another deblocking filter called the "Edge Adaptive Deblocking Filter" which was previously employed in MPEG-2 standard and I'm required to put this filter to x264 but the source code of x264 is very complicated. Can this be achievable actually?
If your alternative filter is supposed to work in-loop, adding it to x264 is a very difficult task for someone who doesn't know x264 codebase.

If it's just a pre-/postprocessing filter, it would be pretty simple to add it to the input filtering system of x264. But comparing that to in-loop H.264 deblocking is apples to oranges. You need to put the filter to the decoding side, not x264.

Last edited by nm; 12th March 2012 at 17:41.
nm is offline   Reply With Quote
Old 18th March 2012, 15:21   #30  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
This time I tried coding using another raw video in YUV format as my input file with the following command:

x264 --crf 23 --input-res 352x288 --fps 30 -o ~/Output/out.mkv ~/Input/soccer.yuv

However the output file's quality is terrible with some objects in the video missing intermittently. Is there something wrong with my command here?

If I'm to modify the deblocking filter, does that mean I have to tweak the decoder too (VLC player in this case?). Also, which .c file is actually the main file (x264.c or encoder.c) because I'm still trying to locate the portion of code where the deblocking filter is used.
skyjuice is offline   Reply With Quote
Old 18th March 2012, 15:27   #31  |  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
This time I tried coding using another raw video in YUV format as my input file with the following command:

x264 --crf 23 --input-res 352x288 --fps 30 -o ~/Output/out.mkv ~/Input/soccer.yuv

However the output file's quality is terrible with some objects in the video missing intermittently. Is there something wrong with my command here?
Command-line looks okay. But your description is far too vague to give an advice. x264 will certainly retain pretty good quality at CRF 23.

So what you are seeing is probably a problem with reading the input file or with decoding the compressed H.264 video later.

Quote:
Originally Posted by skyjuice View Post
If I'm to modify the deblocking filter, does that mean I have to tweak the decoder too (VLC player in this case?)
Sure. The deblocking algorithm is an integral part of the H.264 standard. That applies to the encoder as well as to the decoder.

If you "modify" the standard, i.e. you make your own "non-standard" H.264 extension/modification, the decoder would have to be modified accordingly.

Quote:
Originally Posted by skyjuice View Post
Also, which .c file is actually the main file (x264.c or encoder.c) because I'm still trying to locate the portion of code where the deblocking filter is used.
x264.c is the main file of the x264 command-line encoder, i.e. the CLI front-end you can run from the console.

libx264 is the actual x264 encoder library, which is used by the CLI front-end but can also be used by other apps directly. Probably encoder.c is the "main" file of the library.

However all applications that call the x264 encoder library only use the functions declared in x264.h, the "public" API. All the rest is considered "private" (internal).

Consequently you will find that the front-end (x264.c) will call into the encoder library (encoder.c) first, from where other internal functions at various places will be called...

(For the deblocking filter, you will have to look at deblock.c and especially at deblock-a.asm. Maybe the H.264 specifications will help too!)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 19th March 2012 at 00:22.
LoRd_MuldeR is offline   Reply With Quote
Old 18th March 2012, 15:48   #32  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
This time I tried coding using another raw video in YUV format as my input file with the following command:

x264 --crf 23 --input-res 352x288 --fps 30 -o ~/Output/out.mkv ~/Input/soccer.yuv

However the output file's quality is terrible with some objects in the video missing intermittently. Is there something wrong with my command here?
No problems here with your command line and this source: ftp://ftp.tnt.uni-hannover.de/pub/sv...rig_02_yuv.zip


Quote:
Originally Posted by skyjuice View Post
Also, which .c file is actually the main file (x264.c or encoder.c) because I'm still trying to locate the portion of code where the deblocking filter is used.
I'd suggest reading a bit more about how H.264 in-loop deblocking is supposed to work before going to the code. There are some nice books about H.264 to start with, but you'll also need to read parts of the ITU-T H.264 recommendation.
nm is offline   Reply With Quote
Old 19th March 2012, 16:11   #33  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Quote:
Originally Posted by nm View Post
No problems here with your command line and this source: ftp://ftp.tnt.uni-hannover.de/pub/sv...rig_02_yuv.zip
I downloaded the file given in your link and notice that there is something wrong with the video when it is being played back on VLC player. I have experienced the same thing for some other yuv files as well.

It looks something like this

Anyone knows what is the problem?
skyjuice is offline   Reply With Quote
Old 19th March 2012, 16:49   #34  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
I downloaded the file given in your link and notice that there is something wrong with the video when it is being played back on VLC player. I have experienced the same thing for some other yuv files as well.
".yuv" is usually raw YUV video without headers of any kind, so you need to specify resolution, pixel format and framerate on the command line:

Code:
vlc --demux rawvideo --rawvid-width 352 --rawvid-height 288 --rawvid-chroma=I420 --rawvid-fps 30 SOCCER_352x288_30_orig_02.yuv
Sometimes .yuv could also be YUV4MPEG (.y4m), which has a header that VLC reads and the video should play correctly without having to specify parameters manually.
nm is offline   Reply With Quote
Old 19th March 2012, 19:37   #35  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Just a side note:

You can find a bunch of "uncompressed" sample files in YUV4MPEG (.y4m) here:
http://media.xiph.org/video/derf/

These files are more convenient to use, also with x264
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 27th March 2012, 15:20   #36  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Thanks for the recommendation. Files with .y4m saves all the hassle. Anyway, back to the case of loop filter.

I already have a sample code of an simple MPEG-2 encoder and I'm to evaluate the performance of an MPEG-4's deblocking filter by "importing" this filter to the MPEG-2 architecture. While I have done a lot of readings on the theoretical parts on how a deblocking filter works, I am still confused with x264 code as they are just too lengthy. Will the deblocking filter of JM (http://iphome.hhi.de/suehring/tml/) be much simpler in order to achieve the same objective?

Thank you.
skyjuice is offline   Reply With Quote
Old 27th March 2012, 17:25   #37  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
I already have a sample code of an simple MPEG-2 encoder and I'm to evaluate the performance of an MPEG-4's deblocking filter by "importing" this filter to the MPEG-2 architecture.
I'm still not quite sure what type of a deblocking filter you'd like to have. Do you need an in-loop filter that needs to be implemented both in the encoder and in the decoder or is a standalone postprocessing filter enough?

There's a standalone implementation of H.264's deblocking filter for AviSynth, if you don't need an in-loop filter. The source code might help understanding the in-loop version too.

Last edited by nm; 27th March 2012 at 17:28.
nm is offline   Reply With Quote
Old 5th April 2012, 04:15   #38  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Let's put the filter aside. Assume now I would like to encode a sequence of 5 images in PGM using x264 (by using img_%04d.pgm like in previously) into a video sequence. Is it possible to

1) explicitly define a higher encoding bitrate value for the first frame (I-frame) and another lower bit rate for another 4 frames?
2) separate the encoded video back into the 5 individual frames
3) compare the PSNR value between the frames in step 2 to their original frames before encoding.

Thank you
skyjuice is offline   Reply With Quote
Old 5th April 2012, 10:11   #39  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by skyjuice View Post
1) explicitly define a higher encoding bitrate value for the first frame (I-frame) and another lower bit rate for another 4 frames?
x264 has manual rate control through a qpfile, where you can set frame types and quantizers. Getting specific sizes is difficult though.

Quote:
Originally Posted by skyjuice View Post
2) separate the encoded video back into the 5 individual frames
Well, you can't separate an encoded video to encoded frames and decode them individually unless they are all I frames. But naturally you can decode the complete encoded stream and get separate decoded frames. With ffmpeg:

Code:
ffmpeg -i input.mp4 -f image2 frame-%03d.pgm
Quote:
Originally Posted by skyjuice View Post
3) compare the PSNR value between the frames in step 2 to their original frames before encoding.
There are many tools around to do this. For example:

http://qpsnr.youlink.org/
http://avisynth.org/mediawiki/Compare
http://compression.ru/video/quality_...t_tool_en.html

PSNR is also pretty trivial to calculate yourself with a couple lines of code.

Last edited by nm; 5th April 2012 at 10:22.
nm is offline   Reply With Quote
Old 17th April 2012, 05:03   #40  |  Link
skyjuice
Registered User
 
Join Date: Jan 2012
Posts: 20
Quote:
Originally Posted by nm View Post
x264 has manual rate control through a qpfile, where you can set frame types and quantizers. Getting specific sizes is difficult though.
As far as I know, qpfile requires 3 formats (frame num, frame type, quantizer value). 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?

To use qpfile, I just have to type the contents in a text file and name it qpfile and run it using --qpfile, right? I tried searching but there are very few sources teaching how to use qpfile command

Thanks
skyjuice 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 11:00.


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