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 3rd March 2011, 16:39   #1  |  Link
ar
Registered User
 
Join Date: Feb 2009
Posts: 16
libavcodec's mpeg-2 encoder (mencoder / ffmpeg)

Part 1. Multiplexing problem
I'm trying to encode DVD-compliant sources to output them to dvdauthor. AFAIK, i need to make mpeg-ts stream with NAV-sectors and empty VOBU-sectors. For example, one of the following lines would do what i want:
Code:
mplex -f 8 -o test_mux_mplex.vob test.m2v test.ac3
Code:
mencoder -noskip -mc 0 -oac copy -ovc copy\
-of mpeg -mpegopts format=dvd:tsaf:vwidth=720:vheight=576:vaspect=4/3:vframerate=25\
-audiofile test.ac3 test.m2v -o test_mux_mencoder.vob
And i noticed that either mplex or mencoder dropped some frames during multiplexing. I meen input mpeg-es (m2v) file consists of few more frames then output VOB.

Next wrote this script:
Code:
Video_Blank = BlankClip(length=1500,\
                        width=720,\
                        height=576,\
                        pixel_type="YV12",\
                        fps=25,\
                        audio_rate=48000,\
                        stereo=true,\
                        sixteen_bit=true,\
                        color=$000000).\
                AssumeFrameBased().\
                ShowFrameNumber(x=32,\
                                y=64,\
                                font="DejaVu Sans",\
                                size=32,\
                                text_color=$E0E0E0,\
                                halo_color=$404040).\
                ColorYUV(levels="PC->TV")

return Video_Blank
Script produces progressive PAL clip with 1500 black frames with frame numbers from 0 to 1499 printed on each frame. Then i encoded video to mpeg-2 and ac3:
Code:
wine wavi test1500.avs - /R |\
ffmpeg -ar 48000 -ac 2 -acodec pcm_s16le -f s16le -i pipe:0\
-acodec ac3 -ab 192k -f ac3 test.ac3 &&\
wine avs2yuv -raw test1500.avs - | mencoder -profile mpeg2-vhq-pal-p-i420-bitrate-pass1\
-oac copy -lavcopts vbitrate=9000:aspect=4/3:threads=4\
-audiofile test.ac3 -o test.vob -
Clip in test.vob have 1500 frames and audio stream, also it can be passed to dvdautor.
Even if i tried to demux video, mpeg-es (m2v) still has 1500 frames.
Code:
mpeg2desc -v 0 -o test.m2v < test.vob
But when i multiplexing m2v and ac3 with mplex or mencoder:
Code:
mplex -f 8 -o test_out_mplex.vob test.m2v test.ac3 &&\
mencoder -oac copy -ovc copy -of mpeg\
-mpegopts format=dvd:tsaf:vwidth=720:vheight=576:vaspect=4/3:vframerate=25\
-noskip -mc 0 -audiofile test.ac3 test.vob\
-o test_mux_mencoder.vob
both clips in test_mux_mencoder.vob and test_out_mplex.vob have 1499 frames.
Then i made index for avisynth of two files. Both muxers drops frame with stamp «1498» (the last frame should have stamp «1499»).
If i run this sequence one more time then mplex drops one more frame:
Code:
mpeg2desc -v 0 -o test_again.m2v < test_out_mplex.vob &&\
mplex -f 8 -o test_again.vob test_again.m2v test.ac3
Clip in test_again.vob have only 1498 frames (without frame stamped with «1499»).

Why this occurs?

Last edited by ar; 3rd March 2011 at 18:54. Reason: to make commandline short
ar is offline   Reply With Quote
Old 21st March 2011, 18:02   #2  |  Link
ar
Registered User
 
Join Date: Feb 2009
Posts: 16
Part 2. MPEG-2 encoding quality with MEncoder (libavcodec).
By default it's trash. But if i hit with a hammer -lavcopts somewhere, quality becomes very nice. For example, SSIM test on «Elephant's Dream» with PAL sequense at averange bitrate 5Mbps (peak 8.7Mbps):
  • CCE 2.70` (QMat=CCE3-CG2, QS=NL, AQMat=AAQM, GOP=auto, KFI=AFSCD, ME=SME, RC=VMPE, RC-M=VBR-2P): 92.65093592;
  • CCE 2.70` (QMat=HC, QS=NL, AQMat=none, GOP=auto, KFI=AFSCD, ME=SME, RC=VMPE, RC-M=VBR-2P): 92.43695561;
  • mencoder (QMat=HC, QS=NL, AQMat=none, GOP=auto, KFI=auto, A-ME=RDO, ARC=RDO, ME=EPZS-UMH, RC-M=VBR-2P, RC=Xvid): 92.79327650;
  • mencoder (QMat=CCE3-CG2, QS=NL, AQMat=none, GOP=auto, KFI=auto, A-ME=RDO, ARC=RDO, ME=EPZS-UMH, RC-M=VBR-2P, RC=lavc): 92.94999231;
  • hc (QMat=HC, QS=NL, GOP=auto, KFI=auto, A-ME=HC-best, ME=HC, RC-M=VBR-2P, RC=HC): 92.54866203;
  • mpeg2enc (QMat=HC, QS=L, GOP=auto, KFI=auto, ME=EPZS, RC-M=VBR-1P, RC=M2E-1P): 89.04360011.
BTW, this is very first results.

Also, my profile from mencoder.conf:mencoder_conf.7z

Last edited by ar; 27th March 2011 at 15:16. Reason: mencoder.conf profile added
ar is offline   Reply With Quote
Old 22nd March 2011, 08:28   #3  |  Link
kieranrk
Registered User
 
Join Date: Jun 2009
Location: London, United Kingdom
Posts: 707
Are you sure the GOP lengths are the same.
kieranrk is offline   Reply With Quote
Old 22nd March 2011, 10:37   #4  |  Link
ar
Registered User
 
Join Date: Feb 2009
Posts: 16
Quote:
Originally Posted by kieranrk View Post
Are you sure the GOP lengths are the same.
What exactly do you mean? You're asking about frame drops or about CCE-SP3 vs. libavcodec?
ar is offline   Reply With Quote
Old 24th March 2011, 14:27   #5  |  Link
kieranrk
Registered User
 
Join Date: Jun 2009
Location: London, United Kingdom
Posts: 707
Quote:
Originally Posted by ar View Post
What exactly do you mean? You're asking about frame drops or about CCE-SP3 vs. libavcodec?
I'm asking if the GOP lengths are the same for each encoder...i.e the keyframe interval.
kieranrk is offline   Reply With Quote
Old 24th March 2011, 16:01   #6  |  Link
ar
Registered User
 
Join Date: Feb 2009
Posts: 16
Quote:
Originally Posted by kieranrk View Post
GOP lengths are the same for each encoder...
Both cases i set encoder's MAX_KEYINT option to 15, because i want to get DVD-compliant MPEG-2 stream. Each encoder have scene change detection feature, so GOP size never exceeds 15 frames. Also, i post configuration file.
ar is offline   Reply With Quote
Reply

Tags
dvd, ffmpeg, mencoder, mplex

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


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