Hi, I've got a question on how to get the best possible MPG encoding of a movie source, "at any price" so to speak -- i.e., as many bits as the encoder needs to get the highest possible video quality. It appears to me that the MPG encoding process is introducing artifacts that are present regardless of the amount of "free reign" I give to the encoder with respect to quantization, bitrate, and the like. My bottom line question is thus: "Are these artifacts inherent in MPG encoding, or am I just not twiddling the knobs and dials on the encoder correctly?" Here's all the details ... My source is a mixed hard- and soft-telecined "movie" at 1080/60i that I'm trying to tanscode to 480/24p, soft telecined to 480/60i, for ultimate burning to an NTSC DVD-Video. When I use mencoder to inverse telecine, crop out the crud, expand back to the original letterbox ratio (it's 2.35:1, not 16/9), and 'encode' the video with HUFFYUV (422P), the resulting video looks stunning, with no 'blocking' artifacts to speak of. This, of course, is as expected. But when I encode the video in MPG2 or MPG4, even with vqscale=1 or vqscale=2, I see sometimes severe blocking in the resulting video. Is this because the chroma is being subsampled vertically and horizontally (4:2:0), or is it because 'vqscale' is (perhaps necessary but) not sufficient to get "maximum quality at any price" encoding? Thanks, WB ____________________________________________________________________________________ Be a PS3 game guru. Get your game face on with the latest PS3 news and previews at Yahoo! Games. http://videogames.yahoo.com/platform?platform=120121
On Mon, 12 Mar 2007 13:26:38 -0700 (PDT) Walter Belhaven <wbelhaven@yahoo.com> wrote:
But when I encode the video in MPG2 or MPG4, even with vqscale=1 or vqscale=2, I see sometimes severe blocking in the resulting video. Is this because the chroma is being subsampled vertically and horizontally (4:2:0), or is it because 'vqscale' is (perhaps necessary but) not sufficient to get "maximum quality at any price" encoding?
There's no reason MPEG-2/4 would be inherently blocky. Far more info is needed to even guess where your problem might lie. Command-lines and output would be a start. A short sample of the source may help as well.
RC <xxxxxxx@xxxxxxx.xxx> wrote:
There's no reason MPEG-2/4 would be inherently blocky.
Far more info is needed to even guess where your problem might lie. Command-lines and output would be a start. A short sample of the source may help as well.
Thanks RC. Here's the command line I'm using for huffyuv (lossless): mencoder -noautoexpand -forceidx -oac copy -ovc lavc -of avi \ -vf pullup=1:1:75:75,softskip,crop=1280:800:0:140, \ expand=1280:1080,scale=720:480,harddup \ -lavcopts vcodec=huffyuv:format=422P:aspect=16/9 \ -fps 30000/1001 -ofps 24000/1001 \ -o wbelhaven-huffyuv-480p.avi wbelhaven-original-1080i.mpg and the one for MPG4: mencoder -noautoexpand -forceidx -oac copy -ovc lavc -of avi \ -vf pullup=1:1:75:75,softskip,crop=1280:800:0:140, \ expand=1280:1080,scale=720:480,harddup \ -lavcopts vcodec=mpeg4:vqscale=0.01:aspect=16/9 \ -fps 30000/1001 -ofps 24000/1001 \ -o wbelhaven-mpg4-480p.avi wbelhaven-original-1080i.mpg I'll start with a sample of the MGP4 output file, since it's nice and small. If you need more info I'll upload the original and/or the lossless version. Here's where I copied it, though I don't see it when I look for it: ftp://upload.mplayerhq.hu/MPlayer/incoming/wbelhaven-mpg4-480p.avi Notice the blockiness in the background just to the right of Leon. :) There's an ever-so-tiny bit of that blockiness visible in the HD original (telecined 1080i). The lossless, inverse telecined, shrunken version (480p) faithfully reproduces that very slight blockiness in the original. The MPG4 sample I uploaded is FAR more blocky in that region. Thanks, WB ____________________________________________________________________________________ Don't get soaked. Take a quick peek at the forecast with the Yahoo! Search weather shortcut. http://tools.search.yahoo.com/shortcuts/#loc_weather
On Tue, 13 Mar 2007 10:36:17 -0700 (PDT) Walter Belhaven <wbelhaven@yahoo.com> wrote:
-lavcopts vcodec=mpeg4:vqscale=0.01:aspect=16/9 \
Mystery solved. vqscale is integer, NOT a float value. IIRC, only snow accepts 0, and to select vqscale=1, you also need to set vqmin=1. As I can see from the sample, the video is encoding at 800kbps, which is lavc's default if no vbitrate/vqscale is specified. Try again with vqscale=2
--- RC <rcooley@spamcop.net> wrote:
-lavcopts vcodec=mpeg4:vqscale=0.01:aspect=16/9 \
Mystery solved.
vqscale is integer, NOT a float value. IIRC, only snow accepts 0, and to select vqscale=1, you also need to set vqmin=1.
As I can see from the sample, the video is encoding at 800kbps, which is lavc's default if no vbitrate/vqscale is specified. Try again with vqscale=2
Interesting. When I try with {vqscale,vqmin}={2,1} or {2,2}, the resulting file size is even smaller than that original example I uploaded, and every bit as blocky. When I try {1,1} or {0.01,1}, the file gets much larger and much less blocky, which is definitely what I want. Looks like vqscale=1,vqmin=1 is the ticket. I uploaded the {1,1} version here: ftp://upload.mplayerhq.hu/MPlayer/incoming/wbelhaven-mpg4-480p-qscale1-qmin1.avi Looks much better to me. Is there anything else that can be done to make it even less blocky, or is that pretty much it? Thanks much for your help! WB ____________________________________________________________________________________ We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list. http://tv.yahoo.com/collections/265
On Tue, 13 Mar 2007 18:14:23 -0700 (PDT) Walter Belhaven <wbelhaven@yahoo.com> wrote:
When I try with {vqscale,vqmin}={2,1} or {2,2}, the resulting file size is even smaller than that original example I uploaded,
That really doesn't add-up at all. There may be some other error in your command-line, or perhaps you're using a buggy binary of MPlayer.
When I try {1,1} or {0.01,1}, the file gets much larger and much less blocky,
Your video still only seems to be using a bitrate of ~3000k, which is surprisingly low for vqscale=1/2. I would expect at least 6000k.
Looks much better to me. Is there anything else that can be done to make it even less blocky, or is that pretty much it?
You might try different *cmp= options, particularly 3 (DCT). Many people seem much happier with noise in their videos, covering up blockiness. In that case, look for the NSSEW option, or you can try encoding with Xvid. You can try denoising, deblocking, etc. while encoding the video to cover up artifacts. If you're interested in reducing the bitrate, there's lots of good info in the docs.
--- RC <rcooley@spamcop.net> wrote:
That really doesn't add-up at all. There may be some other error in your command-line, or perhaps you're using a buggy binary of MPlayer.
Hmmm, interesting thought. I downloaded and ran the latest windows "release" (mingw32-1.0rc1) and got the exact same result.
You might try different *cmp= options, particularly 3 (DCT).
Thanks, I'll look into that. Very much appreciate your help. One more question about MPG2, if you don't mind. Is mencoder now producing truly "DVD legal" MPG2 that won't cause the older standalone players to freeze? I had much frustration many moons ago trying to get mencoder to create DVD-legal output that wouldn't cause my old player to freeze. If this is no longer an issue, what's the magic elixer? Is it "-mpegopts format=dvd:tsaf" (thanks Nico!) along with using Xvid rate control ("-lavcopts ...vrc_strategy=1...") along with the rest of the prescription in the user guide (i.e., appropriate bitrates, vrc_buf_size, etc.)? Or is there some other often overlooked option or options that one needs (e.g., vstrict=1, etc.)? Thanks, WB ____________________________________________________________________________________ The fish are biting. Get more visitors on your site using Yahoo! Search Marketing. http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php
On Wed, 14 Mar 2007 10:32:21 -0700 (PDT) Walter Belhaven <wbelhaven@yahoo.com> wrote:
Is mencoder now producing truly "DVD legal" MPG2 that won't cause the older standalone players to freeze?
Many people are creating DVDs with no problems.
Hi, I recorded a video on my Android device using the "DVD" preset and am trying to slice and dice it and/or transcode it with mencoder, and am having a/v sync issues. Here's what mplayer tells me I'm starting with: c:\Users\Jim\Desktop\mplayer>mplayer -identify -frames 0 droid.mp4 mplayer -identify -frames 0 droid.mp4 MPlayer Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team getch2: 6 can't get number of input events [disabling console input] Playing droid.mp4. libavformat file format detected. ID_AUDIO_ID=0 ID_AID_0_LANG=eng [lavf] stream 0: audio (aac), -aid 0, -alang eng ID_VIDEO_ID=0 [lavf] stream 1: video (h264), -vid 0 VIDEO: [H264] 720x480 24bpp 30.000 fps 6070.9 kbps (741.1 kbyte/s) Clip info: major_brand: isom ID_CLIP_INFO_NAME0=major_brand ID_CLIP_INFO_VALUE0=isom minor_version: 0 ID_CLIP_INFO_NAME1=minor_version ID_CLIP_INFO_VALUE1=0 compatible_brands: isom3gp4 ID_CLIP_INFO_NAME2=compatible_brands ID_CLIP_INFO_VALUE2=isom3gp4 ID_CLIP_INFO_N=3 Load subtitles in ./ ID_FILENAME=droid.mp4 ID_DEMUXER=lavfpref ID_VIDEO_FORMAT=H264 ID_VIDEO_BITRATE=6070912 ID_VIDEO_WIDTH=720 ID_VIDEO_HEIGHT=480 ID_VIDEO_FPS=30.000 ID_VIDEO_ASPECT=1.5000 ID_AUDIO_FORMAT=MP4A ID_AUDIO_BITRATE=127992 ID_AUDIO_RATE=44100 ID_AUDIO_NCH=2 ID_START_TIME=0.00 ID_LENGTH=1093.74 ID_SEEKABLE=1 ID_CHAPTERS=0 ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264) ========================================================================== ID_VIDEO_CODEC=ffh264 ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 15999->176400) ID_AUDIO_BITRATE=127992 ID_AUDIO_RATE=44100 ID_AUDIO_NCH=2 Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio)) ========================================================================== AO: [dsound] 44100Hz 2ch s16le (2 bytes per sample) ID_AUDIO_CODEC=ffaac Starting playback... Exiting... (End of file) ID_EXIT=EOF When I try to cut a clip out of that with mencoder, I get this: c:\Users\Jim\Desktop\mplayer>mencoder -oac copy -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi mencoder -oac copy -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi MEncoder Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team success: format: 0 data: 0x0 - 0x328fffab libavformat file format detected. [lavf] stream 0: audio (aac), -aid 0, -alang eng [lavf] stream 1: video (h264), -vid 0 VIDEO: [H264] 720x480 24bpp 30.000 fps 6070.9 kbps (741.1 kbyte/s) [V] filefmt:44 fourcc:0x34363248 size:720x480 fps:30.000 ftime:=0.0333 videocodec: framecopy (720x480 24bpp fourcc=34363248) Audio format 0x4134504d is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it. Exiting... So I dutifully comply and get this: c:\Users\Jim\Desktop\mplayer>mencoder -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi mencoder -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi MEncoder Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team success: format: 0 data: 0x0 - 0x328fffab libavformat file format detected. [lavf] stream 0: audio (aac), -aid 0, -alang eng [lavf] stream 1: video (h264), -vid 0 VIDEO: [H264] 720x480 24bpp 30.000 fps 6070.9 kbps (741.1 kbyte/s) [V] filefmt:44 fourcc:0x34363248 size:720x480 fps:30.000 ftime:=0.0333 videocodec: framecopy (720x480 24bpp fourcc=34363248) Forcing output audio format tag to 0x706d. audiocodec: framecopy (format=706d chans=2 rate=44100 bits=16 B/s=15999 sample-0) Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Pos: 11.1s 334f ( 1%) 0.00fps Trem: 1min 729mb A-V:-0.069 [5939:128] 1 duplicate frame(s)! Pos: 11.5s 344f ( 1%) 0.00fps Trem: 1min 739mb A-V:-0.069 [5908:128] 1 duplicate frame(s)! Pos: 11.8s 354f ( 1%) 0.00fps Trem: 1min 725mb A-V:-0.069 [5871:128] ----8<----- (540 more of these) ----8<----- 1 duplicate frame(s)! Pos: 210.0s 5758f (20%) 350.90fps Trem: 1min 804mb A-V:-0.049 [6617:128] Writing index... Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Video stream: 6616.601 kbit/s (827075 B/s) size: 173713346 bytes 210.033 secs 5758 frames Audio stream: 128.016 kbit/s (16001 B/s) size: 3360432 bytes 210.001 secs As you can see, tons of "duplicate frame(s)" warnings, and the result is a file with extreme a/v sync issues when I play it with mplayer. (The audio lags the video by progressively more time as it plays.) Just for kicks I pretended the video was 24fps, and tried this: c:\Users\Jim\Desktop\mplayer>mencoder -fps 24 -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi mencoder -fps 24 -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi MEncoder Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team success: format: 0 data: 0x0 - 0x328fffab libavformat file format detected. [lavf] stream 0: audio (aac), -aid 0, -alang eng [lavf] stream 1: video (h264), -vid 0 VIDEO: [H264] 720x480 24bpp 30.000 fps 6070.9 kbps (741.1 kbyte/s) [V] filefmt:44 fourcc:0x34363248 size:720x480 fps:30.000 ftime:=0.0333 Input fps will be interpreted as 24.000 instead. videocodec: framecopy (720x480 24bpp fourcc=34363248) Forcing output audio format tag to 0x706d. audiocodec: framecopy (format=706d chans=2 rate=44100 bits=16 B/s=15999 sample-0) Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Pos: 1.0s 25f ( 0%) 0.00fps Trem: 0min 300mb A-V:0.085 [0:130] Skipping frame! Pos: 1.4s 35f ( 0%) 0.00fps Trem: 0min 407mb A-V:0.085 [5685:130] Skipping frame! Pos: 1.8s 45f ( 0%) 0.00fps Trem: 0min 380mb A-V:0.085 [5397:129] ------8<------- (248 more of these) ---------8<---------- Skipping frame! Pos: 210.0s 5293f (19%) 554.82fps Trem: 0min 767mb A-V:0.064 [5892:128] Writing index... Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Video stream: 5891.746 kbit/s (736468 B/s) size: 154689022 bytes 210.042 secs 5293 frames Audio stream: 128.016 kbit/s (16001 B/s) size: 3360432 bytes 210.001 secs Tons of "Skipping frame!" warnings, as you can see. This file has various video artifacts but at least it maintains sync between the audio and video. I've also tried some "real" transcoding, instead of -oac copy and instead of -ovc copy (and both). I've also tried using different output containers, but every time I omit -fps 24 the a/v sync is horrible. So, what am I doing wrong? Any help is very much appreciated. Cheers, WB
Walter Belhaven <wbelhaven <at> yahoo.com> writes:
$ mencoder -oac copy -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi
Since you apparently don't know: MEncoder is not an actively maintained application for several years, FFmpeg can be used for (nearly!) all tasks (including the one above), see http://ffmpeg.org/download.html for current versions (including binaries), current git head is recommended if you are not a distributor.
MEncoder Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team
And this is severely outdated. Unrelated to the above: When posting a new question on a mailing list, please do never hit on "reply" but compose a new mail that is not a reply to an old one: http://thread.gmane.org/gmane.comp.video.mencoder.user/5316 (What you did is commonly known as "thread- hijacking" even if it was your own thread.) Carl Eugen
participants (3)
-
Carl Eugen Hoyos -
RC -
Walter Belhaven