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-2 Encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th January 2016, 14:32   #1  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Convert an h264/mp3 video for DVD playback

Hello,
My wife has a private concert(h264/mp3 3.5 gb 1080p) she would like to convert to make it readable by dvd player.
Since I had to do some authoriting for the menu, I have used Nero Video.
This one allow me to add chapter, menu,... but has very few option for encoding. I found I could choose a VBR wich adapt to the target size but that was nearly all. Can't choose bitrate for audio encoding.
For this reason, I have used ffmpeg to encode manually video part with the following parameter:
Code:
ffmpeg -i input.avi -target pal-dvd -bf 2 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -me_method epzs -threads 4 -vf zscale=w=720:h=576 -qscale:v 1 -aspect 16:9 output.mpg
I tought that with ffmpeg and qscale:v 1 I was doing kind of lossless encoding but to my surprised final size was only 2.7 gb while with nero I have filled the whole dvd. Is qscale:v 1 is well lossless ?
My oritginal file was in 1080p so I guess that the downscaling to 720x576 explain a part of the shrink(original was 3.5 gb in h264/mp3) but still I think it's a lot compare to the nero encoding which propose me around 6gb with Highest quality(8000kb/s).
here is the ouptut of ffmpeg
Code:
frame=146679 fps= 27 q=1.0 Lsize= 2783430kB time=01:37:47.12 bitrate=3886.4kbits/s speed=1.07x    
video:2398535kB audio:320857kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.354862%
I think that ffmpeg average bitrate is far under the nero encoder.
Is it a problem for dvd playback(does it need constant bitrate ??)
I wanted to use this file but nero seems to reencode it(didn't find a way to just copy it) but with a far less size than with direct nero encoding...
Is it possible to create the whole dvd structure with nero(including menu) and after replace video/audio file by the ffmeg encode ?
thetrueavatar is offline   Reply With Quote
Old 14th January 2016, 17:30   #2  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
The problem I have is you're trying to encode a DVD and does not meet their standards, or are not doing only one DVD authoring with Nero. When you only authorship should not recode the program but only verify compliance with the DVD standard.

There should be no problem to put -target pal-dvd but in the particular rather I put each option separately to comply with standard DVD.
Add -vcodec mpeg2video -b:v 8000000 -bufsize 1835000.
__________________
By law and justice!

GMJCZP's Arsenal
GMJCZP is offline   Reply With Quote
Old 14th January 2016, 17:51   #3  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Ok will see if with that settings Nero will encode it. However I must say that Nero does it a lot faster(15min vs 2h) with already compressed mpeg2
thetrueavatar is offline   Reply With Quote
Old 17th January 2016, 03:04   #4  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Hi thetrueavatar,

your FFMpeg command line encodes the source at constant quality (VBR), a value of 1 will give you the highest quality (but it will not be lossless). You did not say how long your source file is, but if it is quite short then the result will not fill the DVD because the DVD bitrate has an upper limit (~9000 kbps).

Here is an FFMpeg command line which will encode a source to a DVD compliant MPEG file and fill up the DVD as much as possible. It uses the FOX Home Theater matrix (suitable for very high bitrates). Audio is converted to AC3at 224 kbps. You need to edit the command line for your input and output, and also set the desired video bitrate (it is set to 8000 kbps).

Quote:
ffmpeg.exe "MY_SOURCE_FILE" -f dvd -c:v:0 mpeg2video -bf 2 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -intra_matrix "8,8,9,9,10,10,11,11,8,9,9,10,10,11,11,12,9,9,10,10,11,11,12,12,9,10,10,11,11,12,13,13,10,10,11,11,12,13,13,14,10,11,11,12,13,13,14,15,11,11,12,13,13,14,15,15,11,12,12,13,14,15,15,16" -inter_matrix "8,8,9,9,10,10,11,11,8,9,9,10,10,11,11,12,9,9,10,10,11,11,12,12,9,10,10,11,11,12,13,13,10,10,11,11,12,13,13,14,10,11,11,12,13,13,14,15,11,11,12,13,13,14,15,15,11,12,12,13,14,15,15,16" -aspect 16:9 -s 720x576 -r 25 -g 15 -b:v:0 8000000 -maxrate:v:0 8500000 -qmin 1 -lmin 175 -bufsize:v:0 1835008 -packetsize 2048 -muxrate 10080000 -b:a 224000 -ar 48000 -c:a:0 ac3 -map 0:v -map 0:a -map -0:s "MY_OUTPUT.mpg"

The other problem is that Nero has the tendency to always reencode the source even if it is already DVD compliant. This is an old Nero issue, not much you can do about it.

But there is a way to use the Nero menu which you already made with an already authored menuless VIDEO_TS structure. This method uses PGCEdit. You would need to author your FFMpeg encoding result to a DVD structure first (demux the .mpg file, then use MuxMan for authoring).

I uploaded a short tutorial about this method here:
http://www61.zippyshare.com/v/FQm48QTQ/file.html



If the menu you already made with Nero is not too elaborate and you wouldn't mind starting over, then my recommendation would be to forget Nero altogether. Use AVStoDVD instead, it can create nice menus, it encodes at very high quality (HCenc), and it is easy to use (much easier than Nero IMO).



Good luck
manolito
manolito is offline   Reply With Quote
Old 18th January 2016, 20:40   #5  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Well my source is 97 min longth so quite reasonable but not enough to encode @9000kbps. My encoding with ffmpeg gave me a 3 361 Kbps average bitrate. Is the encoder that powerfull to compress it like that ??? I have tried with avstoDVD and had some trouble with menu editing but may try once again. Basically I just want a home with play and chapter link. Each page of chapter has a 4 link each to a given song(chapter). So not complex at all but can't found how to create multiple page...
Btw is HCenc better than the one provided with ffmpeg ?

Last edited by thetrueavatar; 18th January 2016 at 21:04.
thetrueavatar is offline   Reply With Quote
Old 19th January 2016, 04:07   #6  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
My bitrate calculator says that (with an audio bitrate of 224) your video bitrate should be 6081 kbps. If you include a menu you should lower this bitrate a little bit.

From my own experience with 1-pass VBR FFMpeg encodes I learned that it has a tendency to undersize using default parameters. You can overcome the undersizing by adding this: -qmin 1 -lmin 175 to the command line.


AVStoDVD at its current state cannot create chapter selection menus. This will probably change in the near future, but not right now...
You could try DVDStyler for this, it can create powerful menus and is still easy to use. Out of the box it can only encode with FFMpeg in CBR mode, but for higher quality there is a plugin which can use 1-pass and 2-pass VBR modes, can use High Quality parameters and supports Custom Quant Matrices (incidentally written by me...)

I won't get into a dispute about if FFMpeg or HCenc is the better encoder. To beat a HCenc encode in 2-pass VBR mode using the BEST profile and a suitable matrix is not so easy IMO (maybe CCE SP3, but you pay $$$). At least for lower bitrates (below 3500) FFMpeg can be just as good or even better in HQ 2-pass VBR mode. Got to try it for yourself...


Cheers
manolito
manolito is offline   Reply With Quote
Old 19th January 2016, 10:16   #7  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Ok will give a try to dvdstyler. I have tried to use it under linux but it was a complete nightmaire to get all dependencies working and had core dump. I will test it under windows then.
Btw that's a pity that avstodvd doesn't yet support multi page since there is a next page arrow(in grey) in their tools...i6 3h63 Kbpst
EDIT: with your parameter and a v:qscale:1 I have indeed a bigger file with an overal of 6 363 Kbps which is a little bit to big for my DVD.
BTW do we agree that 2 pass VBR is not better for quality but just to fit the bitrate/size asked ?

Last edited by thetrueavatar; 19th January 2016 at 13:38.
thetrueavatar is offline   Reply With Quote
Old 19th January 2016, 16:32   #8  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by thetrueavatar View Post
Btw that's a pity that avstodvd doesn't yet support multi page since there is a next page arrow(in grey) in their tools...
Where did you see this next page arrow?
The menu capabilities of AVStoDVD rely on BatchMux. The latest version just came out a few weeks ago, and this version does support chapter menus. But it will take some time until MrC will incorporate these new features into AVStoDVD,

Quote:
EDIT: with your parameter and a v:qscale:1 I have indeed a bigger file with an overal of 6 363 Kbps which is a little bit to big for my DVD.
If you use qscale 1 your encode will be purely quality based, you have absolutely no control over the output size. To fill a DVD you must first calculate your desired video bitrate and then use the bitrate and maxbitrate parameters like this:
-b:v 6050000 -maxrate:v 8500000

Quote:
BTW do we agree that 2 pass VBR is not better for quality but just to fit the bitrate/size asked ?
This depends on the kind of 1-pass VBR...
There is a 1-pass VBR method which first does a couple of sample encodes (typically 5% to 10% of the source) to determine the compressibility. Then a CQ (Constant Quality) encode is performed using the quantizer which has been determined by the sample passes. The method was known under the name "Robshot Bach". If you succeed to fill the DVD using this method, then yes, the quality will be very close to a 2-pass VBR encode.

The 1-pass VBR method used by FFMpeg is more like an Average Bitrate method. There are no sample passes. The encode starts with a certain quantizer, and then the quantizer is dynamically adjusted during the encode to achieve the desired bitrate. With this method the bitrate distribution will not be as good, but the method is much faster.

HCenc uses a different 1-pass VBR method. Basically it works like a 2-pass method, but the first pass only encodes a percentage of the source, and the the compression curve which results from this first pass gets smoothed. Bitrate distribution will be less precise than a real 2-pass VBR.



Cheers
manolito

Last edited by manolito; 19th January 2016 at 16:39.
manolito is offline   Reply With Quote
Old 19th January 2016, 17:04   #9  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Thanks for the explanation about VBR. I have been a bit confused by ffmpeg irc chan which were speaking of ABR(adaptive bitrate) and told me that VBR only mean that frame can have different bitrate. With your explanation I guess that a pure 2 pass VBR does a better balance with bitrate than the 1pass abr like the one defined with the CRF in X264 ?
Quote:
Where did you see this next page arrow?
The menu capabilities of AVStoDVD rely on BatchMux. The latest version just came out a few weeks ago, and this version does support chapter menus. But it will take some time until MrC will incorporate these new features into AVStoDVD,
Here is the page where you can found the "Next page":
Attached Images
 

Last edited by thetrueavatar; 19th January 2016 at 17:28.
thetrueavatar is offline   Reply With Quote
Old 19th January 2016, 19:48   #10  |  Link
Sir Didymus
Registered User
 
Join Date: Mar 2004
Location: Italy
Posts: 953
Not sure if I properly understand your needs, but AFAIK AVStoDVD should be already able to produce a multipage menu for your case, with a little trick... If you cut your video asset (the movie, with well defined chapters) into individual chunks, then you may achieve the job, maybe. The production of the different "Titles" (whell, they are actually the original chapters, but let's call these pieces in this way) is easily feasible with Cuttermaran, for instance, or other video editing applications...

Once you have prepared the individual titles (audio+video), the current menuing features of AVStoDVD should allow you to create a first page menu containing the "PlayAll" button + the arrow button leading to the second page with 4 more titles + the arrow, and so on...

Maybe...

Last edited by Sir Didymus; 19th January 2016 at 19:53.
Sir Didymus is offline   Reply With Quote
Old 19th January 2016, 23:02   #11  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Ok I have tried dvdstyler on windows and it rocks. Just what I need and it doesn't seem to reencode mpeg encoded with avstoDVD!!
thetrueavatar is offline   Reply With Quote
Old 20th January 2016, 07:18   #12  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by thetrueavatar View Post
With your explanation I guess that a pure 2 pass VBR does a better balance with bitrate than the 1pass abr like the one defined with the CRF in X264 ?
A CRF encode (Constant Rate Factor) in X264 does a pure quality based encode. Which again means that you cannot control the bitrate and the output size. But since most folks who convert to H264 do not intend to burn the result to a BluRay disk the output size is usually not important. Qualitywise you will get the best quality possible from a CRF encode depending on the CRF value.


Glad you like DVDStyler, it does have a few rough edges, but for menu creation I think that it has just the right balance between power and ease of use.


Cheers
manolito
manolito is offline   Reply With Quote
Old 20th January 2016, 13:01   #13  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
About your quantization matri I was wondering were does it comes from ? When we specify quantizer =2 does it mean that the while matrix is fille with 2 or is it a reference to a kind of matrix. Maybe silly question but I'm digging into the jpeg compression theory and I wasn't clear for me.
thetrueavatar is offline   Reply With Quote
Old 20th January 2016, 14:28   #14  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
You really need to do some reading to understand the basic concepts of video encoding. Some buzzwords are Discrete Cosine Transformation (DCT), Quantization and of course Quantization Matrices.

I found this old thread very helpful:
http://forum.doom9.org/showthread.ph...91#post1465291

Specifying a quantizer value influences all frequencies the same way. With a Quantization Matrix the quantizer is modified depending on the frequency. This way it is possible for example to use a higher quantization for high frequencies (high detail, lots of movement) and a lower quantization for dark and static scenes. In such a matrix the lower frequencies are represented by the values on top and to the left, while the values at the bottom and to the right represent the higher frequencies.


The HCenc PDF manual has a matrix section where you can see a lot of the popular MPEG2 matrices. If you do not specify a matrix for the encode, every encoder will use a default matrix, but this can be different for different encoders.

FFMpeg uses the MPEG Standard matrix by default (the one where all non-intra coefficients are 16). This is a bad idea for DVD compliant encodes, the normal MPEG matrix (sometimes called MPEG Adapted) is a much better choice.


Modern encoders like CCE or HCenc can adapt the matrix they use on the fly during the encode (in HCenc the parameter is called AQM). Some experts say that (at least for encoders which use an exponential quantizer scale like CCE or HC) the influence of custom quant matrices on the encoding quality is overrated. Please read the dispute between Dark Shikari and Manono in the old thread I linked to.


Cheers
manolito

Last edited by manolito; 20th January 2016 at 14:30.
manolito is offline   Reply With Quote
Old 20th January 2016, 15:21   #15  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Quote:
You really need to do some reading to understand the basic concepts of video encoding
. That's exactly what I'm currently trying to do^^. But I found hard to have a complete information so I have some gap in my knowledge. Already know about jpeg compression for intra-frame( Colorspace conversion, DCT, quantization, huffman encoding,... ) and some notion about temporal compression(i/p/b-frame, motion search vector). Here I was just wondering if q=2 in encoder meant constant matrix whith 2 or some kind of specific matrix with variable content.
I'm must admit however that I have trouble to figure out what frequencies mean for a video while it was pretty obvious for me for an audio signal(high frequency=highpitched, low frequency=low pitched). I know the Shannon theorem which allow the decomposition of a signal in a linear sum of sinus but does represent the signal for a picture.
Anyway I will try to read more to figure out. I'm interested in any pointer to documentation even with a lot of maths.
Thanks a lot for the given information.
Best Regards,

Last edited by thetrueavatar; 20th January 2016 at 16:38.
thetrueavatar is offline   Reply With Quote
Old 21st January 2016, 05:37   #16  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
I'm must admit however that I have trouble to figure out what frequencies mean for a video
The DCT process converts values from the spatial and temporal domain into the frequency domain. Here is a comprehensive article about it:
http://www.cs.cf.ac.uk/Dave/Multimed..._Transform.pdf

After the conversion into the frequency domain the next step is the data reduction by quantization. First of all you specify an average quantizer value like 2, but the quantizer which is actually used is not the same for each frequency, it is calculated by using the matrix coefficients. If you use a matrix where all coefficients have the same value (like 8 or 16) then your given quantizer value of 2 would indeed influence all frequencies the same.

Quote from Dark Shikari from the old thread I linked to above:
Quote:
If you halve all the values in a quantization matrix, it is mathematically EXACTLY THE SAME as if you halved the average quantizer.

Have fun studying all that stuff...
manolito

Last edited by manolito; 21st January 2016 at 07:04.
manolito is offline   Reply With Quote
Old 7th February 2016, 11:42   #17  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Hello there,
I'm coming back to you for a little problem with dvdstyler. I don't know why but the menu encoding is quite crappy. I have used a custom image in 1080p as background but after menu creation we can barely read the text written on it... I have set the menu bitrate to the max 9K but it's still unreadable while I don't have the problem with nero...
Any tought ?
thetrueavatar is offline   Reply With Quote
Old 7th February 2016, 12:16   #18  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
In the DVDStyler forum I found several complaints about blurred background images. Have a look here:

https://sourceforge.net/p/dvdstyler/...read/8fee0457/

https://sourceforge.net/p/dvdstyler/...read/3f3e13d8/


Keep in mind that your HiRes image must be converted to the DVD supported SD size (720 x 480/576). When you compose your menu on a HiRes monitor using a HiRes background image, of course it will look much better than the final DVD.

You probably should prepare your background image in the final SD resolution. Then you can play with different (larger) fonts and make it look as good as possible in this resolution.


Cheers
manolito
manolito is offline   Reply With Quote
Old 7th February 2016, 15:49   #19  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Indeed, it seems that internal image resizer isn't optimal at all. I have resized manually my image before using it and it looks far better ! Thanks for the hint !
thetrueavatar is offline   Reply With Quote
Old 21st February 2016, 19:38   #20  |  Link
thetrueavatar
Registered User
 
Join Date: Sep 2004
Posts: 29
Still me I was ready to deliver my dvd iso when I suddenly realized there was an audio delay after encoding with hcenc. Orignal video is ok but don't know why is there a delay after encoding. Any idea ?
thetrueavatar 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:48.


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