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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd March 2016, 15:45   #1  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Create DVD compatible MPEG2 using FFMpeg

Any FFMpeg specialists out there?

After spending a couple of hours reading docs and googling for advice I figured that I might get some better answers here...

My questions are about FFMpeg default values if I specify "-c:v mpeg2video" AND "-f mpeg2video" in my command line.

First question:
Is specifying "-f mpeg2video" in addidtion to the codec redundant? Or does this parameter force some additional settings?

Next question:
If I explicitly specify values for GOP size, number of B-Frames and for DC precision (like "-dc 10 -g 12 -bf 2") then my encode will be significantly slower than if I just omit these parameters. For DC precision I found that the default is 0 which makes no sense for DVD. But the resulting MPEG2 file still seems to be 100% DVD compliant.

Does FFMpeg have some kind of "Auto Mode" if the "mpeg2video" parameter is used for the codec and/or for the format? And if so, which values will get used?


Cheers
manolito

Last edited by manolito; 22nd March 2016 at 15:49.
manolito is offline   Reply With Quote
Old 25th March 2016, 15:20   #2  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Use HCenc. FFmpeg MPEG2 encoder is "strange".
kolak is offline   Reply With Quote
Old 25th March 2016, 17:25   #3  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Quote:
Originally Posted by kolak View Post
Use HCenc. FFmpeg MPEG2 encoder is "strange".
Sorry, this is not an option...

The FFMpeg MPEG2 encoder may be strange, but it sure spits out excellent quality when using the right parameters.

I mainly need this information for my DVDStyler plugin (allows VBR and HQ encodes while DVDStyler by itself only does CBR).


Cheers
manolito
manolito is offline   Reply With Quote
Old 25th March 2016, 18:30   #4  |  Link
hank315
HCenc author
 
Join Date: Nov 2003
Location: Netherlands
Posts: 570
AFAIK "-f mpeg2video" is redundant if "-c:v mpeg2video" is already specified.

Quote:
If I explicitly specify values for GOP size, number of B-Frames and for DC precision (like "-dc 10 -g 12 -bf 2") then my encode will be significantly slower than if I just omit these parameters.
If "-bf 2" is omitted you wil have a IPPPPPPPPPPPIPPPP... scheme, so no B-frames, it takes more time to generate the B-frames with "-bf 2" (IBBPBBPBBPBBIBBPBB... scheme)
Settings for dc and gop length will not have a large impact on encoding speed.

Quote:
For DC precision I found that the default is 0 which makes no sense for DVD. But the resulting MPEG2 file still seems to be 100% DVD compliant.
The Intra DC coefficient is referred to as intra_dc_precision 0 - 3 which is 8 - 11 bits of precision respectively, tabel 7-4, H.262 standard 02-2000.
Default in FFMPEG is "-dc 8" which is intra_dc_precision 0.
__________________
HCenc at: http://hank315.nl
hank315 is offline   Reply With Quote
Old 25th March 2016, 20:56   #5  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by manolito View Post
The FFMpeg MPEG2 encoder may be strange, but it sure spits out excellent quality when using the right parameters.
Really ? What parameters are you referring to ?

Did something change recently ? Used to produce terrible quality with any settings. No soft pulldown either for "24p" scenarios.
poisondeathray is offline   Reply With Quote
Old 25th March 2016, 23:35   #6  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Thanks very much Hank for the explanations...

Makes things a lot clearer for me.
I did not know that FFMpeg by default does not create any B-Frames at all. All MPG2 encoders I have used so far do create B-Frames by default, so I thought that this is an agreed standard for MPEG2. While B-Frames might not be that useful for very high bitrates, they certainly make sense for medium and lower bitrates.


@ poisondeathray

The followqing two-pass parameters (courtesy of Fishman0919) do produce excellent results, at least for bitrates of 3500 and below. According to Fishman the results are superior to HCenc.

Quote:
ffmpeg.exe -i # -aspect # -dc 10 -g 12 -maxrate 8000k -q:v 2 -b_strategy 2 -brd_scale 2 -bf 2 -profile:v 4 -intra_matrix "8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83" -inter_matrix "16,17,18,19,20,21,22,23,17,18,19,20,21,22,23,24,18,19,20,21,22,23,24,25,19,20,21,22,23,24,26,27,20,21,22,23,25,26,27,28,21,22,23,24,26,27,28,30,22,23,24,26,27,28,30,31,23,24,25,27,28,30,31,33" -pass 1 -passlogfile "ffmpeg" -an -c:v mpeg2video pass1.m2v"

ffmpeg.exe -i # -aspect # -dc 10 -g 12 -lmin 0.75 -mblmin 50 -qmin 1 -qmax 31 -maxrate 8000k -b:v 3500k -bf 2 -pre_dia_size 5 -dia_size 5 -qcomp 0.7 -qblur 0 -preme 2 -me_method dia -sc_threshold 0 -sc_factor 4 -bidir_refine 4 -profile:v 4 -mbd rd -mbcmp satd -precmp satd -cmp satd -subcmp satd -skipcmp satd -intra_matrix "8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83" -inter_matrix "16,17,18,19,20,21,22,23,17,18,19,20,21,22,23,24,18,19,20,21,22,23,24,25,19,20,21,22,23,24,26,27,20,21,22,23,25,26,27,28,21,22,23,24,26,27,28,30,22,23,24,26,27,28,30,31,23,24,25,27,28,30,31,33" -pass 2 -passlogfile "ffmpeg" -an -c:v mpeg2video out.m2v
Just replace the # characters with your own values, maybe play with the bitrate...

For soft pulldown you can use DGPulldown.


Cheers
manolito

Last edited by manolito; 26th March 2016 at 00:39.
manolito is offline   Reply With Quote
Old 26th March 2016, 13:34   #7  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Quote:
Originally Posted by hank315 View Post
The Intra DC coefficient is referred to as intra_dc_precision 0 - 3 which is 8 - 11 bits of precision respectively, tabel 7-4, H.262 standard 02-2000.
Default in FFMPEG is "-dc 8" which is intra_dc_precision 0.
The table you linked to did confuse me a little. This looks like I will have to adjust all "-dc" commands for FFMpeg by subtracting 8 from the existing value.

Luckily this is not the case. I did a few test encodes using either "-dc 10" or "-dc 2", and in both cases a DC Precision value of 10 was reported (by MediaInfo and Restream). Seems like FFMpeg internally maps these values for MPEG2 encoding.

BTW the default for -dc is not 8, but 0...
Quote:
-dc <int> E..V.... intra_dc_precision (from -8 to 16) (default 0)
(from the FFMpeg 3.0 help)


Cheers and thanks again
manolito
manolito is offline   Reply With Quote
Reply


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 00:21.


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