Log in

View Full Version : Pulldown of 25 fps to NTSC


Pages : [1] 2 3 4 5 6 7 8 9 10

Xesdeeni
10th January 2005, 15:24
Answering a question in http://forum.doom9.org/showthread.php?threadid=45459&goto=newpost got me thinking. When I convert PAL 25 fps progressive to NTSC, the output is interlaced. But when we encode 24 fps, the encode can be progressive, and the flags handle the telecine interlacing.

So wouldn't it be possible to create a 25 fps progressive stream of 720x480 and use the flags to do the pseudo telecine to 29.97 fps interlaced?

I think the pattern would be 2:2:3:2:3 instead of 2:3. And the drop-frame (1000/1001) could be handled as well, by dropping one of the set of 3 fields every 1001 fields.

Xesdeeni

tyee
31st January 2005, 19:13
Xesdeeni
Have you tried this yet. I've just tried your script for PAL to NTSC and my first impression is great. It is interlaced but this new method might work and keep it progressive??

tyee

Xesdeeni
31st January 2005, 21:50
No. I didn't have much time shortly after I posted the above, and my working machine is broken at present. On top of that, I'm not sure how to create the pulldown order above in an MPEG stream.

Have you tried it?

Do you know how to create this flag order?

Xesdeeni

Guest
31st January 2005, 21:59
So wouldn't it be possible to create a 25 fps progressive stream of 720x480 and use the flags to do the pseudo telecine to 29.97 fps interlaced? Yes, of course. I've seen several clips that do just that.

Xesdeeni
31st January 2005, 22:02
So it could be encoded progressively, but use the flags to interlace? That would seem to be the best of both worlds. Although there would be a telecine-like hitch, we're used to seeing this. But the encoding would be progressive, and the audio wouldn't have to be touched.

So do you know what s/w will set the flags accordingly?

Xesdeeni

tyee
1st February 2005, 21:47
Xesdeeni
No, unfortunately I don't know how to do this. I was looking on the web for methods other that 3:2 pulldown but didn't find any. Maybe someone here will have to write a little app to do it or modify 'pulldown.exe' to do it.

What about the possibility that NTSC DVD players will not accept 25p with flags that aren't the normal 3:2 pulldown sequence?

tyee

Xesdeeni
1st February 2005, 23:03
That's interesting too. Although, I've never figured out why the flags were necessary in the first place. I'm sure I don't understand completely, but it seems to me, if you encode a 24p DVD, the player knows it is outputting 60i, so it can do the translation. By the same token, a PAL player could know it is outputting 50i, and do the translation (and scaling). But since the flags are there, it seems they might be useful for this.

Xesdeeni

tyee
11th February 2005, 06:30
Xesdeeni
Looks like we're at a dead end here. I thought Donald might give us a tip but not yet. Any luck on your end?


tyee

Guest
11th February 2005, 06:40
It would not be very hard for a programmer to write a utility to do this kind of pulldown. Do you think it is important enough to justify the effort? It might take half a day to do.

Paulcat
11th February 2005, 14:43
It might depend on the player whether it will work or not. A friend of mine has several SVCD's which have a framerate of 25 fps which play fine on his cheap-ass dvd player, but won't play correctly on my sony.

Kind of odd to have a specification and to ignore it...

Guest
11th February 2005, 14:52
Did you check whether those SVCDs actually use pulldown flags?

Xesdeeni
11th February 2005, 15:26
I assume it's worth the effort to find out. If we can encode 25p instead of 30i, the quality should be better. But it depends on the player, I guess, whether it will work. So it'd probably take a test stream to see how compatible it would be. I'd try myself, but I haven't seen source for pulldown.exe.

Xesdeeni

Guest
11th February 2005, 16:05
I'll roll a quick and dirty one this weekend.

tyee
11th February 2005, 16:08
Xesdeeni
Here's the link to the source code for pulldown.exe.

http://www.inwards.com/inwards/?id=36

Maybe it will help.

tyee

tyee
11th February 2005, 16:10
neuron2
Wow, thanks Donald. We just posted within a couple of minutes of each other. I just left the link for the source code above. Maybe it will help.

tyee

Guest
11th February 2005, 20:29
Originally posted by tyee
neuron2
Wow, thanks Donald. We just posted within a couple of minutes of each other. I just left the link for the source code above. Maybe it will help.

tyee I'm 4/5 done with it already, but thanks.

tyee
12th February 2005, 01:00
Great Donald!!

scharfis_brain
12th February 2005, 16:32
would the other way around be possible, too?
(NTSC-Film on PAL with progressive & rff MPEG)

using the flags to telecine 23.976fps to 50 fields per second?

so we could go around the PAL-Speedup (for our audiophiles :) )
at the cost of 2 stutters per second but without the disadvantage of interlaced encoding.

Guest
12th February 2005, 16:52
Yes, you can. We need a more general tool than pulldown.exe. And a one field stutter is usually tolerable. That's why 3:2 looks OK.

I'm using this problem as a test bed for my new parsing architecture. I decided not to do it quick and dirty.

scharfis_brain
12th February 2005, 19:27
And a one field stutter is usually tolerable. That's why 3:2 looks OK.

one field stutter is sadly very common with some broadcasters here in germany.

they do weird things with their movies :
sqeezing movie to show more ads using a speedup to 26fps
(using fieldblending)
hiding censoring with slowdown to 24 fps.
(fieldrepetition without blending)

both conversions are being made using a stupid bobber before, of course. It looks very 'nice' on TV, when the image details are jumping every other half second *grrrrrr*

Because of this I think, some (most?!?) persons would never notice the one field stutter.
(Our audiophiles probably will ignore it ;) )

but I personally would never make usage of a 24p telecine on PAL, because it is far more off-standard and shows this stutter.

Musical Films often were made using 24p telecine in past.
I've seen it on some older PAL-VHS cassetes (eg: Koyaanisqatsi)

Also I do not like 3:2 telecine. The fluidity of the movies is somehow different from the cinema-look.
PAL with speedup looks better to me.

recapitulating, I want to say, that I just was interested whether it is possible to do such pulldown with MPEG.

Maybe I'll give it a try on some musical movies, when you finished programming.

Guest
13th February 2005, 06:07
I'm ready for testing of Pulldown25. Can somebody stick a 25fps progressive MPEG on my server and notify me here? Thank you.

Guest
13th February 2005, 20:59
Well, no files showed up, so I made one by using FF on a 3:2 VOB and then AssumeFPS(25), reencode with TMPGEnc, and remux to a VOB. You gotta be creative!

I got Pulldown25 working and here it is:

http://neuron2.net/misc/pulldown25.zip

Please let me know if the resulting VOBs play OK on your players.

tyee
13th February 2005, 21:17
Thanks Donald. I was just about to upload but I'll give the program a try.

tyee

tyee
13th February 2005, 22:00
neuron2

I tried it with a .vob, but I don't get any output file in the same directory. I get the scrolling line starting with 'display frame ...' in the command window but that's it. What do you get.

tyee

Guest
14th February 2005, 04:45
Sorry, accidentally put up an interim debug output only build. Stand by...

Guest
14th February 2005, 06:12
OK, the download link points to the correct ZIP now.

Please read the text file carefully. I would appreciate hearing the results. Thank you.

tyee
14th February 2005, 06:23
Thanks Donald. Works much better. Plays OK in windvd and info says 29.97. I'll have to change res to 720x480 tomorrow before I can author. Let you know then.

Will this program work with .m2v files and .vob files??
tyee

Guest
14th February 2005, 06:37
>Will this program work with .m2v files and .vob files??

As it says in the text file, which you were supposed to read carefully (:)), it says any program stream. Vobs are program streams. If the M2V is a program stream, it will work. I can add support for elementary and transport streams if this works out OK. So please try it on the VOBs you want to author to a DVD and see if the DVD plays OK in the standalone players.

To identify a program stream, open the file in a hex editor and see if you see this pattern occurring in the file (in hex):

00 00 01 BA

That is a pack start code. All VOBs are program streams with fixed 2048-byte packs.

Guest
14th February 2005, 15:17
I just discovered it is generating illegal transitions. Please stand by for a corrected version.

Guest
14th February 2005, 17:20
Allowing for the 1000/1001 factor is turning out to be very tricky. It sounds easy but it's greatly complicated by several factors: the frames are encountered out of display order during parsing, you can't just count the parsed frames because that is not the correct count after pulldown, you have to suppress the pulldown temporarily without making illegal transitions that change the field order. I want to find a good solution that can be generalized later to other patterns. This will take some time. I can give you a version that doesn't allow for 1000/1001 if you want that right away for testing.

tyee
14th February 2005, 17:41
I was just looking at a sketch I made and how this all works. I can see that for every 5 PAL film frames we generate 6 video frames with a result of 5 progressive and 1 interlaced video frame. This would give 30fps. From here I'm trying to get my head around making it 29.97fps.

Would this version without the 1000/1001 factor generate 30fps instead of 29.97fps?

tyee

Guest
14th February 2005, 18:16
Actually, you get 4 progressives and 2 interlaced:

A A B C D E
A B C C D E

I could set the frame rate to 29.97 or 30. But if I set it to 29.97 without the 1000/1001 adjustment, the AV sync would drift out slowly because there would be too many frames.

I don't really have any doubt that the players can play these streams. But if you wanted to test without the adjustment, I can give it to you. Better to wait until I code the correct solution. As I said, it's pretty tricky and that's probably why no one has done it yet. To do it in a general way is even trickier. But, hey, I love challenges. :)

scharfis_brain
14th February 2005, 18:46
what does a Standalone-DVD-player do with a 30fps stream?

- slowdown to 29.97 fps ?
- drop to 29.97fps (dropping every 1000th frame)
- deny playback

tyee
14th February 2005, 19:02
Good question Scharfis_brain, that's what we'll find out.

neuron2
I think I'm going to have trouble authoring when using program streams. I always author with elementary streams (up until now anyway).

What I have just done is run the PAL 25p through DGIndex, fed this project (.d2v via avisynth, with NTSC resizing), to Mpeg2 encoder which gives me my elementary stream at 720x480 25p.

My authoring s/w will not accept this when set to author NTSC or PAL. (Illegal picture resolution it says!)

Will TMPEGenc accept this half NTSC and half PAL .m2v file or am I just doing it the hard way?

edit --
Well I muxed the .m2v with the .ac3 with ImagoMuxer to get a .vob of 720x480 25p. Ran pulldown25p on it then authored with TMPEGauthor, burning right now. Will update after viewing.

edit --
Good work Donald. Works good on my Sony NS700P. Where is this transition problem I'm supposed to see. What should I look for?

edit --
When I watched the clip, it started out with out of sync audio (which is ok because I didn't do anything to fix it), but after a few minutes it looks like it gets back in very close sync again. I don't know why this happens. Maybe someone else can try it too.


tyee

Guest
14th February 2005, 23:48
That version is not doing 1000/1001 correctly, so the audio will drift. Also, you may get field reversals. Please wait for the correct version.

Regarding program streams, just run it on the final VOBs!

Alcacia
15th February 2005, 02:59
Many of the better standalone DVD players out there have the feature "3:2 Pulldown". Presumably that means that they will ignore flags and output 24p as long as you are using the component video outputs, and your TV is an HDTV. I know, for example, that my Philips 727 has this feature.

Now, my Philips will also play both NTSC and PAL....but there may be players out there that have "3:2 Pulldown" feature, but don't support PAL output.

I wonder if there would be problems with this odd telecined 25p stream when played on standalones with "3:2 pulldown"...

manono
15th February 2005, 08:58
Hi-

Just saw mention of this in the Doom9 News. It looks as if he may have been a bit premature with the announcement.

what does a Standalone-DVD-player do with a 30fps stream?

It sets the drop_frame flag to slow it down to 29.97fps. No frames are actually dropped. The time codes are manipulated. Robshot has a readable explanation here:

http://www.doom9.org/synch.htm

where he says:

Well, to put it in simple term, DROP_FRAME here is in essence EQUAL a SLOWED_DOWN playback from a pure 30fps into the correct NTSC 29.97fps SPEED. In an MPEG-2 domain, this means that the 00 and 01 frames are dropped or SKIPPED from time code, at the start of each minute except minutes which are even multiples of 10.

If the drop frame problem is a temporary holdup, then you might try testing "telecining" off of 24.975fps (such as you'll get from RePAL or Decimate(6)), which will then output 29.97fps.

No player will give you back all progressive frames I don't think. They'll all deinterlace, but it doesn't really matter, because storing 25fps will still be a big improvement over the current solution of storing the full 29.97fps (or 30fps). In addition to which, there will be no blending. Just as neuron2 has seen some MPEG2 streams where a hard telecine was done on a 25fps source, so have I. I don't think I've ever seen an NTSC DVD where 25fps progressive images were stored, though.

Guest
15th February 2005, 15:27
I thought of a super elegant way to solve the problem in a robust, general manner. It's really simple, I make a prepared pulldown pattern file that is just read into memory and applied. The tff25.pat file would be:

2 2 2 2 2 3 0 1 2 2 3 0 1 2 2 3 0 1 2 2 .....2 2 2 2 2 3 0 1 2 2 3 0 1 2 2 ...

The "2 2 2 2 2" runs are inserted to implement the 1000/1001 adjustment and are aligned so as to not change the field order. The beauty is that it is easy to generate these pattern files in display order in advance, then read them into memory, and apply them in encoding order using the temporal_reference picture field. I allow for 1000000 frames, but could easily allow for more. Heck, a 1Mbyte file is nothing these days!

We can also do field dropping instead of frame dropping, but I'll try with frame dropping first because it is slightly cleaner.

I'll have a working release for you this evening. We can make a pattern file for any pulldown you can imagine.

Guest
15th February 2005, 18:01
Here is the revamped version:

http://neuron2.net/guest/dgpulldown001.zip

Please advise on your results. If the whole idea works, I'll add elementary and transport stream support, full generalization of the pulldown, field dropping, ability to specify the output frame rate, and a GUI.

Inwards
15th February 2005, 20:04
Forgive me for being dense, but I don't understand quite what this program is trying to do. Does it actually re-encode the video stream or is it just playing with the the flags in the headers? I ask this because you will encounter numerous problems with trying to massage a 25fps PAL MPEG-2 into something that will play correctly on most standalones.

The last time I tried this I ran into hopeless sync problems. Even after re-encoding the audio stream to match, I found that I still had to perform tricks with the PAL video stream. At first I just resized it to 720x480 and encoded away at 25fps. Then I used pulldown.exe to convert it to 29.97fps with pulldown. What I hadn't counted on was that the VBV values were now hopelessly wrong, causing all kinds of audio breakup on every standalone I tried.

As I recall, I ran into enough other problems that I gave up on encoding tricks and just used AVISynth to convert to NTSC size and framerates (AssumeFPS(23.976), I think) and just encoded the whole thing properly.

Oh yeah, drop_frame and all other timing information stored in the headers are ignored during playback, so if you want this to work, you'll need to physically drop the frames in question.

Inwards
15th February 2005, 20:50
Originally posted by neuron2
I thought of a super elegant way to solve the problem in a robust, general manner. It's really simple, I make a prepared pulldown pattern file that is just read into memory and applied. The tff25.pat file would be:

2 2 2 2 2 3 0 1 2 2 3 0 1 2 2 3 0 1 2 2 .....2 2 2 2 2 3 0 1 2 2 3 0 1 2 2 ...

The "2 2 2 2 2" runs are inserted to implement the 1000/1001 adjustment and are aligned so as to not change the field order. The beauty is that it is easy to generate these pattern files in display order in advance, then read them into memory, and apply them in encoding order using the temporal_reference picture field. I allow for 1000000 frames, but could easily allow for more. Heck, a 1Mbyte file is nothing these days!


You could save yourself a lot of trouble if you did this the same way that pulldown.exe does. Calculate the modulus of the current real frame number using your pattern legnth and then apply the position of the result to your pattern. That way, you could just pass custom patterns via a switch like ---pattern=2222230122301223012.

Eg; using the above 19 character pattern, physical frame 2312 would have a modulus of 13, meaning that code "1" would need to be applied.

Guest
15th February 2005, 21:01
Applying pulldown.exe to a 25fps stream will generate a 31.25fps output stream (because pulldown.exe does only 3:2 pulldown). I assume that is why you ran into problems with sync.

Guest
15th February 2005, 21:03
Originally posted by Inwards
You could save yourself a lot of trouble if you did this the same way that pulldown.exe does. That's exactly what I did at first. As I said in this thread, it starts getting very complicated to allow for the 1000/1001 adjustment with that approach. Remember, pulldown.exe doesn't need to do that adjustment!

My new approach is not "a lot of trouble" in any case.

Inwards
15th February 2005, 21:13
Originally posted by neuron2
Applying pulldown.exe to a 25fps stream will generate a 31.25fps output stream (because pulldown.exe does only 3:2 pulldown). I assume that is why you ran into problems with sync.

No it won't. A 25fps progressive PAL stream is usually just a 24fps FILM stream sped up. If you run pulldown.exe on such a stream, it moves the framerate back to 24fps and adds the appropriate flags to get to 29.97fps. In my tests, the audio was still synched perfectly with the video, it just broke up ever few seconds on standalones. It worked perfectly on a PC.

Inwards
15th February 2005, 21:15
Originally posted by neuron2
That's exactly what I did at first. As I said in this thread, it starts getting very complicated to allow for the 1000/1001 adjustment with that approach. Remember, pulldown.exe doesn't need to do that adjustment!

My new approach is not "a lot of trouble" in any case.

I'm curious; given that the drop_frame flag is ignored on playback, how are you going to drop frames? You can't really cut single frames out of the middle of a GOP without re-encoding...

Guest
15th February 2005, 21:21
I'm not interested in arguing MPEG2 theory with you. The drop frame method is described earlier in the thread.

Inwards
15th February 2005, 21:33
Originally posted by neuron2
I'm not interested in arguing MPEG2 theory with you. The drop frame method is described earlier in the thread.

Sorry, Donald. I don't mean to get your dander up. I was merely trying to understand how you were trying to to achieve the end result. As far as theory vs. practice goes...

I am the author of pulldown.exe. Originally, pulldown.exe was a proof-of-concept prototype that I developed as a first step in creating a suite of three other programs: Anicide, Hybridizer and FieldOrder. After numerous experiments, similar to the ones that you are conducting now, I came to the conclusion that either I was not smart enough to create the first two, or that it was outright impossible. The last program, FieldOrder, was eventually included as part of the DoItFast4U package.

Anyway, unless I am misunderstanding what has been stated in this thread so far, what you are attempting (dropping frames based on the timecode flags) will almost certainly not work. I know, because I tested it myself three years ago. Then again, perhaps I am misreading this thread, or as I said previously, perhaps I just wasn't smart enough.

Best of luck.

daveidmx
15th February 2005, 21:45
whoa, since you guys are both online and posting right now, i better give you a heads up.

I'm putting together a quick model that should handle the conversion in a generalizable fashion. give me an hour or so and I should have something posted.

wheee!

Guest
15th February 2005, 22:12
@Inwards

Oh. Sorry. If you're a developer, you get instant respect. Forgive me.

OK, about the dropping... I don't drop anything. Instead I just don't do any repeats for a cycle so that there is one less display frame. So normally, I do (for TFF):

3 0 1 2 2

Where bit 0 is RFF and bit 1 is TFF. That makes 6 frames out of 5. Then every 1001 display frames, I use:

2 2 2 2 2

So once every 1001 I generate one less display frame.

Regarding the issue of 24fps vs. 25fps, if your stream is validly encoded at 25fps it has audio to match. If you just arbitrarily slow it down by changing the frame rate field, you're gonna end up out of sync. You said you just change it back to 24fps. But how can you do that without changing the audio as well? And what if you have real PAL content that is not just sped up film?

I suppose we'll just have to see if this approach runs into the standalone player problems that you mentioned.

@daveidmx

I've posted a working utility. What do you mean by a "model"?

daveidmx
15th February 2005, 22:51
@neuron2
you said it was super-complicated to do the 1000/1001 adjustment, that your solution involved a pre-calculated file, and that it wasn't generalizable.

i figured out a solution that might help you. i'm just working out the details.

let me know if you don't think you need it.