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-4 AVC / H.264
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th December 2011, 01:39   #1  |  Link
Chumbo
Registered User
 
Chumbo's Avatar
 
Join Date: Feb 2005
Posts: 585
x264 encoding without using AviSynth

I'm hoping someone can help me out here as I'm not an expert with x264 encoding other than using the basic parameters. I use AviSynth so I can apply different deinterlacing to different sources. I was able to encode 2 of 3 successfully, by directly feeding the TS file to x264, but one comes out not in sync with the audio so I must be missing some switch in x264 you think? Here are my three sources (I get the info from MediaInfo CLI) of which the last one is the problem child:
Code:
PROCESSING Test1.ts 
Format: MPEG Video, Scan Type: Progressive, Scan Order: 2:3 Pulldown, FPS: 23.976 
PROCESSING Test2.ts 
Format: MPEG Video, Scan Type: , Scan Order: , FPS: 29.970 
PROCESSING Test3.ts 
Format: MPEG Video, Scan Type: Interlaced, Scan Order: TFF, FPS: 29.970
When I use AviSynth with dgindex, my script looks like this for example:
Code:
LoadPlugin("E:\megui64\tools\dgindex\DGDecode.dll")
LoadPlugin("E:\megui64\tools\avisynth_plugin\ColorMatrix.dll")
LoadPlugin("E:\megui64\tools\avisynth_plugin\TIVTC.dll")
Load_Stdcall_Plugin("E:\megui64\tools\yadif\yadif.dll")
DGDecode_mpeg2source("Test3.d2v")
ColorMatrix(d2v="Test3.d2v", interlaced=true, threads=0)
tfm(order=1).tdecimate()
changefps(23.976)
converttoyv12()
I tried encoding with --tff and --fake-interlaced and both still came out not in sync with the audio, e.g.,
Code:
--pass 1 --bitrate 233 --fps 24000/1001 --open-gop --sar 10:11 --fake-interlaced
   --vbv-maxrate 8000 --vbv-bufsize 8000 --index "D:\test\Test3.ts.ffindex"
   --stats "D:\test\output\Test3.stats" --output NUL "D:\test\Test3.ts"
What's interesting is that the fake interlace switch is supposed to produce progressive output right? However, the output ScanType, according to MediaInfo is MBAFF. Am I misunderstanding how this switch is supposed to work?

I guess my question is, can I accomplish the same thing with x264 when I feed it the TS file directly and bypassing AviSynth/DGIndex? In this case I want to produce a progressive stream @ 23.976 for the media type like test3.ts.

Thanks.
__________________
Chumbo
Chumbo is offline   Reply With Quote
Old 15th December 2011, 06:11   #2  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
If the content of your test3.ts file is in fact 24p content with hard 3:2 pulldown applied (i.e. you see a consistent pattern of 3 progressive frames followed by 2 interlaced frames), then you probably can use x264 by itself to process it, but only with a patched build that includes the inverse telecine filter. This is (basically) the x264 equivalent of the tfm(order=1).tdecimate() line in your avisynth script. Unfortunately, the inverse telecine patch isn't yet in the GIT, so the official builds don't include it. I'm not sure who's making builds with this patch, but hopefully some helpful soul will chime in...

So, as far as I'm aware, if you need to do inverse telecine you're best off sticking with AviSynth. Also, why the ChangeFPS(23.976) line in your AviSynth script? It shouldn't be necessary.

Finally, a word on --tff vs --fake-interlaced.
1) Setting --tff tells x264 to encode in real interlaced mode, and assume that the top field comes first. I believe this uses MBAFF, which is theoretically always more efficient (especially for encoding hard pulldown). This is the appropriate mode for real interlaced content.

2) Setting --fake-interlaced is for the annoying case where you have (for example) 29.97p content, and you need to encode it for a format that doesn't support 29.97p but does support 29.97i. Encoding progressive content as interlaced is sub-optimal, so thankfully x264 has the ability to sneakily encode in progressive mode, but pretend it's encoding in interlaced mode. This is a very good thing for people who are encoding BluRay content and have 29.97p sources.

3) Neither setting is appropriate if you're encoding progressive content without an annoying restriction as described in 2). You could use --tff to encode your test3.ts as-is without applying inverse telecine. It sounds like you tried this and got an audio desync, which is interesting. MPEG TS support is not great in ffms2, last I checked. Broadcast transport streams in general have a lot of variation, and I've only ever gotten good results with DGIndex / DGIndexNV, or some of the payware DirectShow filters from MainConcept or Elecard.

TL;DR, index that shizz...

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

Last edited by Blue_MiSfit; 15th December 2011 at 06:20.
Blue_MiSfit is offline   Reply With Quote
Old 15th December 2011, 16:25   #3  |  Link
Chumbo
Registered User
 
Chumbo's Avatar
 
Join Date: Feb 2005
Posts: 585
Thanks Derek. Your response is very enlightening and helpful. The file does seem to have hard pulldown since the MediaInfo info doesn't show anything but I could be wrong.

I didn't have "changefps(23.976)" in my script initially. I put it in because what was coming back for fps is 19.181 which now I'm wondering if the file is a hard pulldown. I changed my script to the following and I got what I needed correctly with the appropriate frame rate:
Code:
LoadPlugin("E:\megui64\tools\dgindex\DGDecode.dll") 
LoadPlugin("E:\megui64\tools\avisynth_plugin\ColorMatrix.dll") 
LoadPlugin("E:\megui64\tools\avisynth_plugin\TIVTC.dll") 
LoadPlugin("E:\megui64\tools\avisynth_plugin\TDeint.dll") 
DGDecode_mpeg2source("Test3.d2v") 
ColorMatrix(d2v="Test3.d2v", interlaced=true, threads=0) 
orig = last
telecide(guide=1, order=1, hints=true, post=1)
tdeint(order=1, clip2=orig)
converttoyv12()
The previous script had produced jerky motion, probably due to the changefps.

You're right about MPEG TS support in ffms2, so I think I'll stick to AviSynth right now. I was just hoping to cut out the "middle man."

All the sources are from DVD with the 3 types shown in my first post. I'm basically reencoding a large DVD collection so I can dump my reencoded MKV files onto one 50GB BD. That way I can just pop that into my BD player and have access to the entire collection on one disc since my player can play MKV files with the codecs I'm using. More convenient than always swapping out DVDs and putting up with menus.
__________________
Chumbo
Chumbo is offline   Reply With Quote
Old 16th December 2011, 00:09   #4  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
That's odd.. if your sources are DVD, how could your files be transport streams? DVD uses VOBs, which are program streams with some extensions...
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 16th December 2011, 03:33   #5  |  Link
Chumbo
Registered User
 
Chumbo's Avatar
 
Join Date: Feb 2005
Posts: 585
Quote:
Originally Posted by Blue_MiSfit View Post
That's odd.. if your sources are DVD, how could your files be transport streams? DVD uses VOBs, which are program streams with some extensions...
I should have mentioned that I converted them to MKVs first. However, that proved to be another pain as MediaInfo provided info (at least at that time) that did not work for all episodes. I noticed the 3 patterns so I used tsmuxer to convert them to transport streams just to see if the info reported by MediaInfo would be different and it was. I use a complex batch file to automate my encodings as I tend to do a large set at one time, so the batch file uses the MediaInfo CLI to get the info it needs to create the proper files/commands/switches/etc. for encoding. In this particular case, I'm converting 190 episodes.
__________________
Chumbo
Chumbo is offline   Reply With Quote
Old 16th December 2011, 06:44   #6  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
That's not large scale by my definitions

In any case, it sounds like you're probably best off going back to your original DVDs. That way you wouldn't be forced to work with the annoyances of transport streams.

Derek
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 16th December 2011, 14:50   #7  |  Link
Chumbo
Registered User
 
Chumbo's Avatar
 
Join Date: Feb 2005
Posts: 585
Quote:
Originally Posted by Blue_MiSfit View Post
That's not large scale by my definitions

In any case, it sounds like you're probably best off going back to your original DVDs. That way you wouldn't be forced to work with the annoyances of transport streams.

Derek
Oh, I'm done already. It wasn't bad at all since I have everything automated. It was just these last 15 titles that I needed to figure out how to deinterlace and I was curious if the same thing can be accomplished directly via x264. All is good in the end. I just used the TS as input. My output is MKV.
__________________
Chumbo
Chumbo 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 04:21.


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