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 23rd April 2014, 09:31   #1  |  Link
jerry30121
Registered User
 
Join Date: Apr 2014
Posts: 5
How to implement ROI(region of interest) encoding through ffmpeg/x264

Hi, I was doing a project that needs to encode video with ROI method.
And as I checked the information on Internet, still can't find how to write the command to do that.

1. Should I check "Flexible Macroblock Ordering"? and how to implement this in ffmpeg/x264?

many thanks!
jerry30121 is offline   Reply With Quote
Old 23rd April 2014, 12:56   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
x264 does not support ROI encoding "out of the box", in the sense that it detects the ROI (whatever that may be) for you and then adjusts the quantizers accordingly. In other words: You can not enable ROI encoding with a simple commannd! But there is an API provided by x264 that allows for implementing ROI encoding yourself, i.e. in the calling application.

See here:
http://git.videolan.org/gitweb.cgi/x...e681dc21d43ade
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 23rd April 2014 at 13:01.
LoRd_MuldeR is offline   Reply With Quote
Old 24th April 2014, 16:42   #3  |  Link
jerry30121
Registered User
 
Join Date: Apr 2014
Posts: 5
so... in that case, I should try compile these files over original x264 and make it to my version?
Can I have more detail about ho do turn it on? sorry if this bothers you, cuz I've been stuck on this issue for a while.

this API offers me to control quant_offsets by giving what parameter? or can you bring me any example?

many many thanks!
jerry30121 is offline   Reply With Quote
Old 24th April 2014, 20:12   #4  |  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 jerry30121 View Post
so... in that case, I should try compile these files over original x264 and make it to my version?
Can I have more detail about ho do turn it on? sorry if this bothers you, cuz I've been stuck on this issue for a while.
As explained before, you can not simply "turn it on", because there is no such thing as region of interest encoding in x264. But there is an API that allows you, optionally, to set a quantizer offset for each individual block in the frame. This way, the calling application might implement a form of "region of interest encoding" when using x264. In other words, you will have to write your own program that uses x264, as a library, and that adjusts the quantizer offsets as desired.

Quote:
Originally Posted by jerry30121 View Post
this API offers me to control quant_offsets...?
Yes.

Quote:
Originally Posted by jerry30121 View Post
can you bring me any example?
I have no complete example, but see "x264.h" for details.

The interesting part is highlighted in the commit that I already linked above:
http://git.videolan.org/gitweb.cgi/x...088a3b5#patch5
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 24th April 2014 at 22:10.
LoRd_MuldeR is offline   Reply With Quote
Old 7th May 2014, 07:00   #5  |  Link
jerry30121
Registered User
 
Join Date: Apr 2014
Posts: 5
it seems that the latest version of x264 has already included this API. What I should do is writing my program directly call such function and pass related data, am I on the right direction?

thanks again
jerry30121 is offline   Reply With Quote
Old 7th May 2014, 08:04   #6  |  Link
jerry30121
Registered User
 
Join Date: Apr 2014
Posts: 5
What I am trying to do is: encoding a video file by x264, and the outcome video should content a part of area that has higher quality than the other area.

let's say a 1280x720 mp4 format file for input.
and output should hold the same resolution and left part area (640*720) has the better quality than the right one.

Is it possible to encode that way by x264?
Can you give me some suggestion?

thanks!
jerry30121 is offline   Reply With Quote
Old 7th May 2014, 11:56   #7  |  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 jerry30121 View Post
it seems that the latest version of x264 has already included this API.
It does so since Fri, 28 May 2010, as you can see in the commit log (see link above).

Quote:
Originally Posted by jerry30121 View Post
What I should do is writing my program directly call such function and pass related data, am I on the right direction?
Exactly.

Quote:
Originally Posted by jerry30121 View Post
Is it possible to encode that way by x264?
Yes. By setting the quantizer offsets accordingly.

Quote:
Originally Posted by jerry30121 View Post
Can you give me some suggestion?
See here:
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 7th May 2014 at 11:59.
LoRd_MuldeR is offline   Reply With Quote
Old 7th May 2014, 17:19   #8  |  Link
jerry30121
Registered User
 
Join Date: Apr 2014
Posts: 5
Quote:
Originally Posted by jerry30121 View Post
What I am trying to do is: encoding a video file by x264, and the outcome video should content a part of area that has higher quality than the other area.

let's say a 1280x720 mp4 format file for input.
and output should hold the same resolution and left part area (640*720) has the better quality than the right one.

Is it possible to encode that way by x264?
Can you give me some suggestion?

thanks!
and...what about this one?
can this be done by the API you mentioned?
jerry30121 is offline   Reply With Quote
Old 7th May 2014, 18:20   #9  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
YES. How many times do you want to hear that it is possible? You just have to code it

(If you can control the quantizers on a per-marcoblock basis, why it shouldn't be possible to increase/decrease compression for one half of the frame?)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 7th May 2014 at 18:42.
LoRd_MuldeR is offline   Reply With Quote
Reply

Tags
ffmpeg, fmo, roi, x264

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 23:27.


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