PDA

View Full Version : 720p@59.94fps to 23.976fps


WattoDaToydarian
13th September 2006, 02:13
Hey ppl, I was wondering if there is a way to convert a video from 59.94fps to 23.976fps because it seems broadcasters just take 24fps film and encode it at 60fps.
I tried going to video > frame rate and setting it to convert to fps 23.976 and it worked for a while but in the middle of the movie it started going really slow like the fps was cut in half or something.
Thanks!

Turtleggjp
25th September 2006, 21:00
I don't know how easily you can do this with VirtualDub in one pass, but I dealt with this problem myself using AVISynth and the filter "Decimate" which is part of Donald Graft's Decomb package. I used:

Decimate(cycle=2)
Decimate(cycle=5)

The first line reduces it from 59.94fps to 29.97fps, and the second takes it down to 23.976fps.

Hope that helps.

Matt

WattoDaToydarian
25th September 2006, 21:11
Thanks Turtleggjp, but I dont know how to use AVISynth. Are you saying that I need to do 2 passes with xvid for this to work? If that's the case, could I use avidemux?

Turtleggjp
26th September 2006, 16:33
If you are serious about getting into this video editing and processing stuff, you really should try to learn AVISynth. It's a little tricky at first, but once you get the hang of the basics, stuff like this that would take you several steps can be done all in one step. Think of it as an assembly line. In order to do the conversion you want to do, you first need to get rid of half the frames to bring it down to 29.97 fps. This would require one run through VirtualDub. Once there, you need to remove one frame every 5 frames to further reduce the frame rate down to 23.976. This can be done in a second run of VirtualDub. The question is, how do you store the video during the in-between step? You could use something like XviD on single pass and Quantizer=1 for maximum quality, or if you have a large enough hard drive, uncompressed video. With AVISynth though, both of these steps (and lots more if needed) can be done at once, with the "in-between video" (29.97fps) stored in memory with only enough frames at a time that are needed to complete the second step. Instead of doing only one thing at a time, the video moves down the "assembly line" and can have several operations done to it sequentially and all within memory before it is finally sent to your video compressor. If you'd like, I can post one of my scripts that I use for this so you can see what it looks like.

Matt

WattoDaToydarian
27th September 2006, 04:48
Ok, I got AVISynth and i'm ready to learn so post your script.
Can I load a DVB transport stream with this directly or do I still have to demux it first?

neuron2
27th September 2006, 05:34
Can I load a DVB transport stream with this directly or do I still have to demux it first? Get this:

http://neuron2.net/dgmpgdec/dgmpgdec.html

Read the Quick Start guide to see how to serve your video and audio through Avisynth.

Turtleggjp
27th September 2006, 15:32
The version of DGMPEGDec that I have is very sensitive to glitches in the transport stream (has this been improved in recent versions?). One glitch will cause the audio and video to lose sync. So, if your transport stream files are not perfect (like mine) you should probably also grab ProjectX. This will split your transport stream file into a .m2v file (MPEG2 video only) and whatever audio format is used (usually AC3 for me) and both will be in sync despite most glitches in the stream. Some glitches still throw off ProjectX and cause it to do weird things, like stop writing the audio or cause the audio to lose sync, but for the most part it works pretty well. If you do this step, then once you have your .m2v file you can then use DGMPEGDec to index the file just like you would have had it index the original transport stream.

I don't have my scripts with me at work, so I'll post them later tonight. In the meantime, get aquainted with DGMPEGDec and try to make a simple script that serves the frames into VirtualDub. You will also need the Decomb filter set as well, since this is where the Decimate function is. Once you get your script working, check what VirtualDub is reporting the framerate to be. If it is 59.94 fps, then just add that code I gave you in my first post and it should drop to 23.976. The only other thing my script has is Trim() functions which cut out the commercials (I get the numbers that go into the trim functions by manually editing in VirtualDub, it is not an automatic process), so you should be ready to go after adding the Decimate functions.

One other thing. DGMPEGDec will most likely be outputting video in YV12 format (that's what it does for me). The newest versions of VirtualDub have native support for this format, but if yours doesn't, you'll need to either get a newer version that does or install some other codec that supports YV12. Most of the codecs I tried had certain issues with video that was a certain size, but the newer VirtualDubs have given me no trouble. Good luck!

Matt

WattoDaToydarian
27th September 2006, 22:44
Thanks a LOT for all your help Turtleggjp! This isn't working at all.
I recorded the movie Behind Enemy Lines in 1080i @ 29.97 fps and then I demuxed it with videoredo which gave me an MPV file and AC3 file. Then I opened the MPV file with DGMPGDec and saved the project and demuxed video which gave me a d2v.
I eventually came up with this avs script:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\Decomb.dll")
video=MPEG2Source("Behind Enemy Lines.d2v")
DirectShowSource("Behind Enemy Lines.AC3")
Decimate(cycle=5)
AudioDub(video,audio)When I load it, it says "Decimate: Input must be YV12 or YUY2."
I have neuron2's Decomb Plugin for Avisynth Version 5.2.2.
Also, I had to use DirectShowSource for the audio because it kept telling me that there's no such source as wavsource or ac3source when I tried them.

scharfis_brain
27th September 2006, 22:46
you aren't assigning the correct variables....

WattoDaToydarian
27th September 2006, 22:48
you aren't assigning the correct variables....You mean for decimate?

neuron2
27th September 2006, 22:51
Try this:

MPEG2Source("Behind Enemy Lines.d2v")
video=Decimate(2).Decimate(5)
audio=DirectShowSource("Behind Enemy Lines.AC3")
AudioDub(video,audio)

Download NicAudio.dll and use NicAC3Source() from that.

WattoDaToydarian
27th September 2006, 23:07
Alright! This is what I got so far:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\Decomb.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\NicAudio.dll")
MPEG2Source("Behind Enemy Lines.d2v")
video=Decimate(5)
audio=NicAC3Source("Behind Enemy Lines.AC3")
AudioDub(video,audio)It now loads in virtualdubmod with 23.976 fps but the audio is 6ch PCM could I just take the audio out of the avs and add the ac3 stream in vdubmod or would that make it go out of sync?
Also, what's the best deinterlacer for 1080i movies?

kilg0r3
27th September 2006, 23:17
Hi guys, neuron

I have been away for so long that I will attribute any typo to the advanced rheumatism in fingers, alos the long grey beard hanging down on my keyboard does not help. Anyway here my question.

Recently I recorded a ts at 60fps and the frames of the stream had the following pattern.

ABBCCCDDGGGFF...

That is, first and second frame were different second and third were the same. Third and fourth differed, frames four to six were the same ... Strangely enough the equal frames were not exactly equal but never ever contained any movement.

Would the decimate script above also work with such a source?

Thanks for your patience ... Now I'll go an clean my ivories.

neuron2
27th September 2006, 23:55
It now loads in virtualdubmod with 23.976 fps but the audio is 6ch PCM could I just take the audio out of the avs and add the ac3 stream in vdubmod or would that make it go out of sync? I don't understand your point. You can add a parameter to NicAC3Source() to downsample:

NicAC3Source(...,2)

Sure you can leave out the audio and re-add it in VDubMod if you prefer to do it that way.

MPEG2Source("Behind Enemy Lines.d2v")
Decimate(5)

Also, what's the best deinterlacer for 1080i movies? That question is out of order, per forum rule 12. Also, I don't know of any interlaced movies. Do you know about IVTC?

neuron2
28th September 2006, 00:00
Would the decimate script above also work with such a source? It's very easy to try. :)

If it doesn't work, please post a link to an unprocessed source clip containing a high-motion section.

kilg0r3
28th September 2006, 14:02
Ahhh yeees, rumble, coughcough wheeez - I am forgetting my manners ... thanks for reminding me.

Turtleggjp
28th September 2006, 15:49
Recently I recorded a ts at 60fps and the frames of the stream had the following pattern.

ABBCCCDDGGGFF...

That is, first and second frame were different second and third were the same. Third and fourth differed, frames four to six were the same ... Strangely enough the equal frames were not exactly equal but never ever contained any movement.

Would the decimate script above also work with such a source?

Thanks for your patience ... Now I'll go an clean my ivories.

Yes, I believe it would work. I wouldn't worry about the first frame being different, you probably just entered the pattern at an odd place. I believe that Decimate does do some "thinking" about which frames it throws out, so it should see the frames that are very close to identical and cut them out accordingly.

WattoDaToydarian, if you recorded this movie in 1080i, you will probably also need to de-interlace the video. If you used the decomb.dll that I suggested, the command for that is:

Telecide(order=1) for Top Field First
Telecide(order=0) for Bottom Field First

Put this right before Decimate(cycle=5). That's the combination I use for all my telecined content.

As far as the audio goes, I've never had much luck dealing with audio in AVISynth, so I always just add it later with VirtualDub (or VirtualDubMod if using AC3). As long as the video and audio are the same length (which they should be if you used ProjectX), VirtualDub should not have a problem keeping it in sync. Are you trying to preserve the AC3, or convert it to another format? If that AC3 source filter is giving you PCM, then you should be able to use that to convert to another format, provided the format you choose can support the number of channels. If you want to preserve the AC3 soundtrack, then that source filter either needs a pass through mode where it doesn't process the AC3, it just sends it though (not sure if it has this though), or else use VirtualDubMod to Mux in the AC3.

Matt

WattoDaToydarian
28th September 2006, 22:52
I finally got it perfect! It turns out that “video=Decimate(5)” was leaving duplicate frames still so I read the DecombTutorial.html file and it said that “Decimate()” auto detects the duplicate frames and drops them leaving me with perfectly smooth video @ 23.976 fps.
The lines:
Telecide(order=1) for Top Field First
Telecide(order=0) for Bottom Field FirstIs the wrong syntax so I went back to the Tutorial and I found the lines:
AssumeTFF()
Telecide()They cleaned up all the interlacing lines.
So now my video is perfect... For Behind Enemy Lines...
Now I have another movie that is really weard, it's 720p @ 59.94 fps but it doesn't play at that speed somehow. When I demux it, the video plays at 60fps and the audio goes out of sync instantly.
It might be kind of the same problem that kilg0r3 is having so I used videoredo to cut out a 7sec sample and put it on my http server so you can examine it.
*File deleted*
Thanks again for all the help!;)

neuron2
28th September 2006, 23:02
It turns out that “video=Decimate(5)” was leaving duplicate frames still so I read the DecombTutorial.html file and it said that “Decimate()” auto detects the duplicate frames and drops them leaving me with perfectly smooth video @ 23.976 fps. Decimate(5) is exactly the same as Decimate(), because the default cycle is 5.

WattoDaToydarian
28th September 2006, 23:12
Decimate(5) is exactly the same as Decimate(), because the default cycle is 5.Well then I dont know why I was still seeing dupliacte frames but there gone now.

WattoDaToydarian
9th October 2006, 05:33
Has anyone had a chance to look at my recording example?
I just found another recording that also goes out of sync.

WattoDaToydarian
16th January 2007, 04:10
If the CastAwayExample isn't enough to make out he problem I have uploaded another example.
http://watto.gotdns.org/Harry Potter and the Prisoner of Azkaban - 2006-10-28, 7-00 PM.TS

neuron2
16th January 2007, 04:43
I looked at CastAwayExample.ts and found that it has frame repeats, which are not currently supported by DGMPGDec. Read this entire thread:

http://forum.doom9.org/showthread.php?p=914700

Also contained in the thread is a way to handle this material using VirtualDub MPEG2, which does handle frame repeats. You'll have to demux the video because VirtualDub MPEG2 cannot read transport files. One way to demux these streams is to use Elecard XMuxer Pro.

Note that the most recent beta (1.4.9b9) of DGMPGDec now pops up an error message box when you load a video with frame repeats.

neuron2
17th January 2007, 07:17
You'll be happy to hear that I now have frame repeats working in my latest build of DGMPGDec. It will be included in the next beta release.

WattoDaToydarian
17th January 2007, 20:17
Woah that's awesome neuron2! :thanks:
That was fast, I thought you said it would take longer in the other thread but ok!:D

eb
17th January 2007, 22:10
Your sample No 2, after demuxing in GraphEdit, and rewriting ac3 in HeadAc3 and muxing_and/or processing in VDM I have got Download HarPot.avi (http://www.filecrunch.com/file/~7ed6hg) 12MB.
Trick is in frame rate in VDM, set to audio time equal to video and rewrite at the same process to 24 fps. Time stamps in this case are taken from ac3 audio.

neuron2
17th January 2007, 22:36
@eb

That method will fail when the RFF flags are irregularly distributed as they were in a file uploaded by harissa in a related thread.

eb
17th January 2007, 22:42
Neuron2 you are right, in some cases only surgeon cutting should be used to cure audio/video synchro.

neuron2
17th January 2007, 22:45
Well, I want to point out that the new support in DGMPGDec will handle any distribution of RFF flags, so your method, though interesting, is not really needed.

WattoDaToydarian
18th January 2007, 00:39
Yeah sorry eb, but thanks for the effort.
neuron2, I just made a 2 1/2 minute cast away test and it worked perfectly!
I used your DGMPGDec Version 1.4.9 beta 10 and it's Avisynth plug in.
Great work keep it up!

neuron2
18th January 2007, 03:49
neuron2, I just made a 2 1/2 minute cast away test and it worked perfectly! Thanks for the test results. It's not perfect yet because I still have to fix the rendering within DGIndex, but it's mature enough to make correct encodes via DGDecode. I've avoided analyzing the rendering code in DGIndex up until now because it is so complex (inherited from DVD2AVI). No way to avoid it now. :(

eb
18th January 2007, 03:55
WattoDaToydarian

Have you had success with DGMPGDec Version 1.4.9 beta 10 with your sample above
http://watto.gotdns.org/Harry%20Potter%20and%20the%20Prisoner%20of%20Azkaban%20-%202006-10-28,%207-00%20PM.TS ?

neuron2
18th January 2007, 04:06
Have you had success with DGMPGDec Version 1.4.9 beta 10 with your sample above This works fine for me:

vid=MPEG2Source("F:\Streams\New Test Files\Frame Repeats\Harry Potter.d2v").decimate(2).decimate(5)
aud=nicac3source("Harry Potter PID 034 T01 3_2ch 384Kbps DELAY -441ms.ac3",2).delayaudio(-0.441)
audiodub(vid,aud)

Are you having a problem with it?

WattoDaToydarian
19th January 2007, 20:44
Hey neuron2, I just discovered two problems with DGMPGDec.

1. With the new fix for the RFF flags, I see a slight jitter every so often in the video after I encode it to xvid in virtualdub mod.

2. I just used it to demux another movie with the RFF flags and encoded it. Afterwards I played it to check it and noticed that every time there's an error in the stream the audio goes farther out of sync.

WattoDaToydarian
19th January 2007, 21:53
I uploaded two more sample videos to show you this.
#1 Is a short transport stream sample with errors.
*Removed video*

#2 Is my xvid/ac3 sample of that section that's a little longer. You will instantly notice the A/V sync problem and if you look closely you should notice the slight jitter every once in a while.
*Removed video*

I used DGMPGDec to demux it, put it into an AVIsynth script, opened it in virtualdub mod, then encoded it using xvid.
Here is the script I used.
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\Decomb.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\NicAudio.dll")
MPEG2Source("Remember the Titans.d2v")
Decimate(2)
video=Decimate()
audio=NicAC3Source("Remember the Titans PID 080 T01 3_2ch 384Kbps DELAY -295ms.ac3")
AudioDub(video,audio)

neuron2
19th January 2007, 23:51
This is now off-topic for this forum. Post your issue in the DGIndex forum. But I can tell you right now, if it's due to errors in your stream, you'll have to clean those up first with (for example, ProjectX). DGMPGDec was designed originally for DVDs and so it expects clean streams.

WattoDaToydarian
19th February 2007, 02:27
I just processed a bunch of episodes of "The Office" that are at 29.97fps and realized that there are duplicate frames causing jumpy video (I used to think the camera man didn't have a steady hand).
Is it possible to make a script that performs a Decimate process on the frame rate of an AVI file and somehow out put to a new file with out recompressing the video? (Like "Direct stream copy" in virtualdub).

Pookie
19th February 2007, 07:25
WattoDaToydarian - I just processed an episode of "The Office" with the new Dgindex and it worked just fine. I add Tfm() and Tdecimate() and resize. Little else needed.

foxyshadis
19th February 2007, 07:37
I just processed a bunch of episodes of "The Office" that are at 29.97fps and realized that there are duplicate frames causing jumpy video (I used to think the camera man didn't have a steady hand).
Is it possible to make a script that performs a Decimate process on the frame rate of an AVI file and somehow out put to a new file with out recompressing the video? (Like "Direct stream copy" in virtualdub).

If they're already in xvid/divx, no, you'll just have to re-rip or re-encode. :(

If you dig pretty deep into the technical side of things, you can do it pretty simply for any B frame dups, you might be able to get away with it for P frames that are close enough dups, but you can't do it in vdub and if you wanted to be really safe you'd have to use a container that could do VFR, for those cycles that don't neatly work. And since there are no tools for it, you'd have to bend an existing one to your will. =p