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 > General > Linux, Mac OS X, & Co

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th December 2010, 08:02   #1  |  Link
mocham
Registered User
 
Join Date: Jun 2007
Posts: 48
Macroblocking problem in downconverted MPEG2, need ffmpeg help

I have a source AVC video as follows:

Code:
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : High@L4.1
Format settings, CABAC           : Yes
Format settings, ReFrames        : 8 frames
Muxing mode                      : Container profile=Unknown@4.1
Codec ID                         : V_MPEG4/ISO/AVC
Duration                         : 1h 34mn
Bit rate                         : 2 460 Kbps
Width                            : 1 280 pixels
Height                           : 688 pixels
Display aspect ratio             : 1.850
Frame rate                       : 23.976 fps
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.117
I want to convert this video to standard NTSC DVD using ffmpeg. I've done this many times before and the following is a fairly standard encoding line that I use:

Code:
ffmpeg -i INPUT.mp4 -f dvd -vcodec mpeg2video -s 720x462 -aspect 16:9 -vf "pad=720:480:0:9" -b 2800k -minrate 2800k -maxrate 3200k -bufsize 1835k -g 12 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -bf 2 -flags qprd -flags mv0 -flags2 skiprd OUTPUT.mpg
The above command produces a MPEG2 file with the following characteristics:

Code:
Format                           : MPEG Video
Format version                   : Version 2
Format profile                   : Main@Main
Format settings, BVOP            : Yes
Format settings, Matrix          : Default
Format settings, GOP             : M=3, N=12
Duration                         : 1h 34mn
Bit rate mode                    : Variable
Bit rate                         : 3 200 Kbps
Width                            : 720 pixels
Height                           : 480 pixels
Display aspect ratio             : 16:9
Frame rate                       : 23.976 fps
Standard                         : NTSC
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.386
I'm having a problem in that the output has large blocky artifacts in some of the scenes with high motion. I could be wrong, but I believe (from experience) that this is happening because the input video is a much higher resolution than the output. Most of the time I upconvert to MPEG2/DVD rather than downconvert as in this case. Can anyone give me some pointers to get a better result? Thanks.
mocham is offline   Reply With Quote
Old 16th December 2010, 08:09   #2  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
2800kbps CBR MPEG-2 is generally going to look pretty awful.
Dark Shikari is offline   Reply With Quote
Old 16th December 2010, 09:15   #3  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,993
Looks like he's doing VBR to me, but not very smart VBR.

I'd set minrate to 500k, maxrate to 9000k, and avg to at least 4000k if possible... 2800 is very low for full resolution SD MPEG-2.

1h 34m should afford you at least 6mbps even on a DVD5. Why such a low bitrate?

Derek
__________________
These are all my personal statements, not those of my employer :)

Last edited by Blue_MiSfit; 16th December 2010 at 09:17.
Blue_MiSfit is offline   Reply With Quote
Old 18th December 2010, 11:17   #4  |  Link
mocham
Registered User
 
Join Date: Jun 2007
Posts: 48
Quote:
Originally Posted by Blue_MiSfit View Post
Looks like he's doing VBR to me, but not very smart VBR.

I'd set minrate to 500k, maxrate to 9000k, and avg to at least 4000k if possible... 2800 is very low for full resolution SD MPEG-2.

1h 34m should afford you at least 6mbps even on a DVD5. Why such a low bitrate?

Derek
Thanks for the tips. I'm trying to keep the output size to around 2.1 GB to fit other movies on the disc.

I will try your suggestions above, but do you know of any options that reduce blockyness or are you saying that it could be because of the way I specified the VBR rates? I will try anyway and let you know.
mocham is offline   Reply With Quote
Old 18th December 2010, 12:20   #5  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by mocham View Post
I will try your suggestions above, but do you know of any options that reduce blockyness or are you saying that it could be because of the way I specified the VBR rates? I will try anyway and let you know.
The problem is most likely caused by your -minrate 2800k -maxrate 3200k settings that lead to CBR encoding when using -b 2800k. That's not enough for complex scenes.

Try Blue_MisFit's settings with your average bitrate of 2800 kbps. And use 2-pass encoding if you want high-quality output at a fixed size!
nm is offline   Reply With Quote
Old 18th December 2010, 20:11   #6  |  Link
mocham
Registered User
 
Join Date: Jun 2007
Posts: 48
I reencoded using Blue_MisFit's tips and it worked, no blockiness. I was misunderstanding how VBR should be setup.

Regarding 2 pass mode, I also kind of forgot about using this. Can you confirm that my understanding of it is correct per below example? Is the -fs necessary to get the target filesize, or just use the bitrate to control it?

Pass 1:
Code:
ffmpeg -i INPUT.mp4 -f dvd -fs 2200000000 -vcodec mpeg2video -s 720x462 -aspect 16:9 -vf "pad=720:480:0:9" -b 2800k -minrate 500k -maxrate 9000k -bufsize 1835k -g 12 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -bf 2 -flags qprd -flags mv0 -flags2 skiprd -an -pass 1 -y /dev/null
Pass 2:
Code:
ffmpeg -i INPUT.mp4 -f dvd -fs 2200000000 -vcodec mpeg2video -s 720x462 -aspect 16:9 -vf "pad=720:480:0:9" -b 2800k -minrate 500k -maxrate 9000k -bufsize 1835k -g 12 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -bf 2 -flags qprd -flags mv0 -flags2 skiprd -pass 2 OUTPUT.mpg
Edit: -fs appears to only truncate the output file.. So how does one specify a fixed output size?

Last edited by mocham; 18th December 2010 at 20:17.
mocham is offline   Reply With Quote
Old 19th December 2010, 01:22   #7  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by mocham View Post
Edit: -fs appears to only truncate the output file.. So how does one specify a fixed output size?
By specifying video and audio bitrates. Video bitrate needs to be calculated from the desired file size and movie length, subtracting audio bitrate.

There will also be some overhead in the MPEG-PS format that you might need to consider.

Last edited by nm; 19th December 2010 at 01:25.
nm is offline   Reply With Quote
Reply

Tags
avc, downconvert, dvd, ffmpeg, mpg

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


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