Log in

View Full Version : 1280x720p MPEG2 HDTV broadcast => Xvid 1280x720-HD + AC3 Asych problem


Markbo98
14th April 2006, 17:03
I've been trying to convert captured Fox-24 & ABC-Lost HDTV episodes to Xvid 1280x720-HD + AC3.
Has anyone made progress with these types of conversions?

I've been searching forums/the net and still haven't found a solution.

The goal : Convert 1280x720p MPEG2 HDTV broadcast => Xvid 1280x720-HD + AC3
that plays nicely on my Buffalo Link Theatre.

The problem : Audio/Video gradual out-of-synch problem.

Here's the process:

1.) Capture 24, Lost w/ USB Fusion HDTV gold

2.) Edit commercials with VideoReDo Plus => Output MPEG2 file

3.) Use Nic's DVD2AVI http://nic.dnsalias.com/ to create .D2V file & demux audio AC3 file.
Use Nic's MPEG2Dec3 to frameserve MPEG2 video.

4.) Frameserve AviSynth script to VirtualDubMod. (Fast Recompress, no audio).
Output: => Xvid 1280x720-HD video file

5.) Re-mux the Avi/AC3 file with NanDubMod (DirectStreamCopy).
Output: => Asynch Xvid 1280x720-HD + AC3.

I've tried several Avisynth scripts, selectevery, fdecimate, etc.
I've tried the following script to set several fps rates,
including 23.976, 23.98, 24, 27.976, 59.94(original),
and none of these create in-synch Xvid 1280x720-HD + AC3 files.

#Convert fps to 23.976

LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\DGDecode.DLL")
LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\FDecimate.dll")
MPEG2Source("C:\24\1\24FDecimate1.d2v",idct=5,cpu=6)
FDecimate(rate=23.976,threshold=1.3)
#FDecimate(metrics=true,show=true) #Help set threshold

Note:

I've used the following script to successfully to convert 1080i streams
into perfect in-synch Xvids 1280x720-HD+AC3 files.

The quality of these 1080i=>720p Xvids is impressive on a big HDTV.
The reduction in size is 1.0gb/5.7gb (87% of the original size).

AviSynth script for 1080i broadcasts:
------------------------------------

#Keep original 29.97fps

LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\DGDecode.DLL")
MPEG2Source("C:\Unit\Unit.d2v",idct=5,cpu=6) #Pentium 4, MPEG2 postprocessing
Loadplugin("C:\Program Files\DVD2AVI_NIC\System\Undot.dll")
LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\TDeint.dll")
Lanczos4Resize(1280,height) #Limit pixels to speed up de-interlacer
tdeint(mode=0,type=2) #Keep original 29.97fps
Lanczos4Resize(1280,720) #Final Sharp re-size
UnDot() #Remove static


I'd love to hear a success story about how to convert a 1280x720p MPEG2 HDTV broadcast into
an in-synch Xvid 1280x720-HD + AC3.

foxyshadis
14th April 2006, 22:21
3.) Use Nic's DVD2AVI http://nic.dnsalias.com/ to create .D2V file & demux audio AC3 file.
Use Nic's MPEG2Dec3 to frameserve MPEG2 video.
That's not Nic's, you're using Donald Graft's DGMpgDec (a continuation of Nic's iirc), which is good, because Nic's is extremely outdated. :p

Decimating framerates isn't going to help sync, because the a/v offset and skew will be exactly the same. So what is the sync like? Is it always out by a half-second or so? You probably need to set an offset when you mux. Is it slowly increasing or decreasing? You need to resample your audio or change the framerate (via assumefps, not anything that changes # of frames). Once you correct that, then you can decimate as needed.

There is always the chance that decoding 720p xvid is too hard on your computer; avi always goes out of sync in these cases. You can try muxing to, say, mkv or ogm and watch it that way. (Depending on the decoder, audio will skip or video will slow down when your system's overloaded, but it stays in sync.) That won't help if it's an offset or skew problem though.

Markbo98
15th April 2006, 18:27
So what is the sync like? Is it always out by a half-second or so?

The synch starts out perfect, and gradually goes bad as the video progresses. At the end, you see their lips move, and then you hear the audio, with as much as 1 second delay.

You need to resample your audio or change the framerate (via assumefps, not anything that changes # of frames)

I could try mp3 (resample) for the audio, but I would prefer to use the original AC3 5.1 soundtrack. The original AC3 audio works perfectly for 1080i conversions.

I haven't tried assumefps, but I have tried to leave the original 59.94fps, and it is still out of synch. How is assumefps different from not changing the framerate at all?

I tried this script, and it didn't help...

LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\DGDecode.DLL")
MPEG2Source("C:\24\1\24FDecimate1.d2v",idct=5,cpu=6)

There is always the chance that decoding 720p xvid is too hard on your computer;

I don't think this is true, because my 1080i conversions to Xvid are perfect. My system is a P4 2.6Ghz, with 1024GB ram.


You can try muxing to, say, mkv or ogm and watch it that way. (Depending on the decoder, audio will skip or video will slow down when your system's overloaded, but it stays in sync.)
Can I do this and still have a compatible Xvid/Avi that will play on my Buffalo Link Theatre? I don't think it supports mkv or ogm.

Doesn't VirtualDubMod slow down to keep things in synch? Especially considering that I use it as a frameserver, and then mux the AC3 track into it?

I've also tried AVImux_GUI with no success.

Thanks for helping, and thanks to Donald Graft for updating things for HDTV.

:thanks:

foxyshadis
16th April 2006, 02:52
I mostly suggested muxing to mkv to quickly check whether it's a cpu thing, not a permanent solution. Since a 2.6 should easily be powerful enough, I assume it must be some issue with dropped frames, which is still kind of weird for .ts capture. (I'm assuming the TS is perfectly in sync and never stutters.) Something odd is going on with this capture, at least, and if you want to use a standalone you cant really screw with the framerates, so resampling the audio is probably the only way to fix it, unless you can find some other problem on the capture side.

shpitz
16th April 2006, 05:06
The synch starts out perfect, and gradually goes bad as the video progresses. At the end, you see their lips move, and then you hear the audio, with as much as 1 second delay.


in nandub when you're about to mux, press ctrl-r and select 3rd radio-button from top, 'change so video and audio duration match'.

report back.

Markbo98
18th April 2006, 18:49
in nandub when you're about to mux, press ctrl-r and select 3rd radio-button from top, 'change so video and audio duration match'.
report back.

Ok,

Here is the recipe I used for last nights episode of 24.

1.) Capture 24, Lost w/ USB Fusion HDTV gold

2.) Edit commercials with VideoReDo Plus => Output MPEG2 file

3.) Use DVD2AVI http://nic.dnsalias.com/ to create .D2V file & demux audio AC3 file

4.) Frameserve AviSynth script to VirtualDubMod. (Fast Recompress, no audio)

LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\DGDecode.DLL")
LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\FDecimate.dll")
MPEG2Source("C:\24\24.d2v",idct=5,cpu=6)
FDecimate(rate=24.00,threshold=1.3)

Output: => Xvid 1280x720-HD video file

5.) Re-mux the Avi/AC3 file with NanDubMod (DirectStreamCopy).

New Step!:

*** press ctrl-r and select 3rd radio-button from top, 'change so video and audio duration match'.

- Video frame rate control
(current: 24.000 fps)

- Select the following:
Change so video and audio durations match (24.008)

(The fps values were very close. Does anyone know if 24 is indeed filmed @ 24.00fps?)

Output: => Xvid 1280x720-HD + AC3

The Good:
- An Xvid file with the audio in synch.

The Bad:
- At times it was a bit choppy, maybe because of the .008 difference?

Conclusion:
- Overall the most watchable Xvid conversion of 720p broadcast I've done so far.

Thanks for the ctrl-r thing.

Lil' Jer
18th April 2006, 19:57
- Video frame rate control
(current: 24.000 fps)

- Select the following:
Change so video and audio durations match (24.008)

(The fps values were very close. Does anyone know if 24 is indeed filmed @ 24.00fps?)

Film rate is 23.976 not 24.00.

Lil' Jer
18th April 2006, 20:05
4.) Frameserve AviSynth script to VirtualDubMod. (Fast Recompress, no audio)

LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\DGDecode.DLL")
LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\FDecimate.dll")
MPEG2Source("C:\24\24.d2v",idct=5,cpu=6)
FDecimate(rate=24.00,threshold=1.3)

Output: => Xvid 1280x720-HD video file

Don't you need a frame matcher before you have the decimate?

Markbo98
19th April 2006, 17:11
Film rate is 23.976 not 24.00.
I absolutely agree the standard for film is 23.976 fps.

If you read the thread, you'll see that my first attempt was 23.976 fps.

LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\DGDecode.DLL")
LoadPlugin("C:\Program Files\DVD2AVI_NIC\System\FDecimate.dll")
MPEG2Source("C:\24\1\24FDecimate1.d2v",idct=5,cpu=6)
FDecimate(rate=23.976,threshold=1.3)
The problem was that 23.976fps wasn't fast enough. As the video progressed, it gradually lagged behind the audio.
I tried 23.98fps, and 24fps and it brought things into better synch.

Question: what cameras do they use to create 24 Season 5?
Do they use standard film, or new HDV cameras?
What is the original framerate?

These articles state they were shopping for new digital cameras.

http://www.showreel.org/memberarea/article.php?172
http://www.showreel.org/memberarea/article.php?141

Did they switch to HDV cameras for the 24 Season 5 and go to 24fps?

Is that why "FDecimate(rate=24.00,threshold=1.3)" gives better synch than "FDecimate(rate=23.976,threshold=1.3)" ?

Here is a quote from the article:

In part three, Rodney and Taylor will report on how the various flavours of HD/HDV hold up to post processing – the final major hurdle to overcome to assess their suitability for high-end drama. Of course, with these tests you have to bear in mind that these cameras represent the first wave of hi-res 1/3in chip cameras. The second generation will be with us imminently: NAB is in April, so expect some pretty interesting announcements.

Markbo98
26th April 2006, 22:06
Why does 24fps keep things in synch?

I tried this script on ABC - Lost, and Fox - 24.
Both maintain pretty good synch when 24fps is specified.

Perhaps they are using the following standard:

http://www.atsc.org/standards/a_53e.pdf

Table A3 - Compression Format Constraints

"Frame_Rate_Code", where 8 = 60Hz.

60.00 Hz / 2.5 = 24fps.

But, I could be wrong....

:stupid:

MrTroy
26th April 2006, 22:31
I absolutely agree the standard for film is 23.976 fps.
Poor film-making factories and camera manufacterers. They would have to make very precise timing machines to accomodate the 0.024 skew from 24fps.

No, film standard is actually 24.0fps. 23.976 is only used for telecining. So if your material is film-sourced, 24.0 is the correct framerate

Some HD cameras, however, record in 23.976fps native. I don't understand why, 'cause with HD you don't need telecining (24fps is part of the HD standard). Maybe the camera manufacterers thought that 23.976 was the film standard, too? :o

foxyshadis
27th April 2006, 00:56
24 was chosen because it offers a good compromise between fluidity and reel size (movies use much larger film frames, so they eat film much faster than tv shows - although many tv shows are now adopting movie production standards), and it was fairly arbitrary. (Probably chosen because it sounded nice, but the engineers who did are long dead now.) But precision requirements of the shutter are no different between 24 and 23.976; quantz crystals (and other timing devices before them) are millions of times more precise, and back when films were hand-cranked and the early days of mechanical cranking, wavering sync was common anyway.

24 is the native framerate of film, but since the audio is resampled when telecining anyway, you may as well leave it that way unless you need to show it on a theater projector, so you'll have to resample the audio again.

woah!
27th April 2006, 07:48
what version of videoredo are you using?

i had an issue with a newer version and had to remove all reg info etc and uninstall completely videoredo and then reinstall my old version which then worked perfect on the ac3 audio.

i think you might be looking in the wrong place for the problem.

i only found this out because i have an old computer i use for overnight encoding and that one still had the old redo version installed and using that to edit the same source of adverts etc.. i had no sync issues when encoded on the computer i had the newer version installed on.

also i use this script for my 24 series encodes and get a nice result:

SelectEven().Decimate(5)

instead of your:

FDecimate(rate=24.00,threshold=1.3)

IanB
27th April 2006, 08:35
You are probably losing sync when you edit the adds out. When editing raw TS streams you can only chop at GOP boundaries and similarly for audio only at block boundaries. If the station does some fancy fade into the add break there is a very good chance the end of the video GOP won't align with the end of the audio block so you creep a few frames each time, 6 frames is 200ms which is noticable.

To test for this try an encode with the adds still in place, i.e. so you have 56 minutes of original video to mux with 56 mins of original audio.

If it works you will need to revise the way you do your add chopping. Fortunatly in 99% of cases after an add break the audio and video streams for the show restart aligned, so you most likely will only need to pad the video at the end of each segment. Effectivly you need to do what is called an aligned splice in Avisynth, but as you want to keep the raw audio stream you will need to manually emulate the effect.

nicksteel
27th April 2006, 16:00
Having similar problem.

Synch Problem with HDTV OTA Capture

--------------------------------------------------------------------------------

Having sound synch difficulties with conversion of ATI HDTV Wonder OTA captures of "24" to DVD.

I edit commercials with VideoReDo (saved MPG is in synch)
Create D2V with DGIndex 1.4.6
Create Wav with DGIndex 1.4.6

Process with TMPGEnc as 29.97 704x480 non-interlaced

Process Audio with Headac3he to 192 mp2

Use DVDLab to process m2v and mp2.

The sound starts out in synch, but gradually becomes out of synch.
AVS Script used by TMPGEnc

LoadPlugin("C:\video\DGDecode.dll")
LoadPlugin("C:\video\RemoveGrainsse3.dll")
LoadPlugin("C:\video\Repairsse3.dll")
LoadPlugin("C:\video\SSe3Tools.dll")

Mpeg2Source("C:\MyTv\24\24.d2v",idct=7)
selecteven()

LanczosResize(720,368,0,1,1280,718)
LRemoveDust_YV12(17,1)
ConverttoRGB24()
AddBorders(0,56,0,56)

function LRemoveDust_YV12(clip input, int clmode, int "limit")
{
limit=default(limit,2)
clmode=default(clmode,17)
repmode = 2
clensed = Clense(input)
rep = Repair(clensed, input, mode=repmode)
rg = RemoveGrain(rep, mode=clmode)
return LimitChange(rg, input, limit, limitU=255)

shpitz
27th April 2006, 16:32
many times an encode will be out of sync because the capture file is messed up. the original cap-file will play fine but as soon as you demux and start processing it it will result in a totally messed up encode.

in a case like this i just delete the cap since from my experience it is just a waste of time to try to fix it...

nicksteel
27th April 2006, 18:27
I do sometimes end up with bad captures, but every capture of "24", and only captures of "24", cause this problem for me.

Markbo98
27th April 2006, 21:35
also i use this script for my 24 series encodes and get a nice result:

SelectEven().Decimate(5)
Correct me if I'm wrong, but here is how I believe this statement functions:

SelectEven().Decimate(5)

720p has a 3 2 3 2 frame duplication pattern like this:

A A A B B C C C D D E E E F F ...

We would like to get the original A B C D E F......

We specify Decimate(5) as the cycle, which gives us....

1 2 3 4 5
A A A B B

SelectEven() will select even frames 2 and frame 4, returning frames A and B....

6 7 8 9 10
C C C D D

SelectEven() will select even frames 6, 8, 10 returning frames C, C and D and so on....

So we will have A,B,C,C,D.

Is this correct?

Wilbert
27th April 2006, 21:43
clip.SelectEven().Decimate(5) is the same as Decimate(SelectEven(clip),5). Thus SelectEven is done first:

A1 A2 A3 B4 B5 C6 C7 C8 D9 D10 E11 E12 E13 F14 F15 ...

SelectEven: A1 A3 B5 C7 D9 E11 E13 F15 ...

Decimate(5): A1 B5 C7 D9 E11 F15 ...

woah!
28th April 2006, 00:22
Having similar problem.

Synch Problem with HDTV OTA Capture

--------------------------------------------------------------------------------

Having sound synch difficulties with conversion of ATI HDTV Wonder OTA captures of "24" to DVD.

I edit commercials with VideoReDo (saved MPG is in synch)
Create D2V with DGIndex 1.4.6
Create Wav with DGIndex 1.4.6

Process with TMPGEnc as 29.97 704x480 non-interlaced

Process Audio with Headac3he to 192 mp2

Use DVDLab to process m2v and mp2.

The sound starts out in synch, but gradually becomes out of synch.
AVS Script used by TMPGEnc

LoadPlugin("C:\video\DGDecode.dll")
LoadPlugin("C:\video\RemoveGrainsse3.dll")
LoadPlugin("C:\video\Repairsse3.dll")
LoadPlugin("C:\video\SSe3Tools.dll")

Mpeg2Source("C:\MyTv\24\24.d2v",idct=7)
selecteven()

LanczosResize(720,368,0,1,1280,718)
LRemoveDust_YV12(17,1)
ConverttoRGB24()
AddBorders(0,56,0,56)

function LRemoveDust_YV12(clip input, int clmode, int "limit")
{
limit=default(limit,2)
clmode=default(clmode,17)
repmode = 2
clensed = Clense(input)
rep = Repair(clensed, input, mode=repmode)
rg = RemoveGrain(rep, mode=clmode)
return LimitChange(rg, input, limit, limitU=255)


i should have said that my finished edited mpeg files were also in sync after using the newer video-redo but afterwards the ac3 was out of sync with the encode. but using my old version of redo on the same ts source gave me a in sync mpeg and afterwards a in sync avi/ac3 file. i never investigated further as i am lazy at times and thought it might be a system thing only happening to me.

nicksteel
21st July 2006, 16:15
Also had problems with sych. Finally solved by adjusting the audio duration to match the m2v duration with Goldwave.

Only way I could solve the problem of starting in sync, then drifting. I consistantly get about 1 1/2 seconds audio delay after processing VideoReDo output with avs script in TMPGEnc. The VideoReDo MPEG is in sync.

Don't have the sync problem with HDTV 720 movie captures, but with 720 tv series captures that I have to process into DVD's.

Revgen
21st July 2006, 18:16
The problem : Audio/Video gradual out-of-synch problem.

I've had the same problems.

HERE IS HOW I FIXED IT:

1) Download (http://rapidshare.de/files/17149845/ProjectX_090.4.00.zip.html) the latest version of Project X.

2) Open your .TS file.

3) Press "Prepare>>" button on the left hand side of the GUI in the "Process" box.

4) Go to Presettings>Special then check the "Audio:limit points of PTS for sync" option in the "Special 2" box to the right of the menu.

5) Exit presettings then select the ".ts" option in the Process Window and press the icon with the green arrow. Project X will create a new TS file and hopefully the audio is in sync.

nicksteel
23rd July 2006, 00:22
I've had the same problems.

HERE IS HOW I FIXED IT:




Downloaded and created new TS. Same audio sync problem as original.

Revgen
23rd July 2006, 03:57
Downloaded and created new TS. Same audio sync problem as original.
I may have had a different problem.

McoreD
23rd July 2006, 08:07
Off the topic, have you tried recording with Web Scheduler? All of my audio sync problems after encoding TP/MPG files recorded using FusionHDTV, went away with TS files recorded using Web Scheduler.