PDA

View Full Version : How to change mpeg-2 field order without re-encoding?


leonid_makarovsky
7th October 2006, 22:00
Hi there,

I recently captured video from VHS directly into MPEG-2 using intervideo mpeg-2 (custom format 352x480, 29.97fps). When I authored the DVD using this mpeg-2 and then burned it, I noticed that the field order was wrong due to the flag. The mpeg-2 itself has the top field first 'cause it plays fine on my TV-Out through Matrox graphics card G550. Matrox always ignores the flag and plays the actual field first. So the question is, how do I change the flag in the mpeg-2 header (without re-encoding the file) and what mpeg editing software I should use. I am only familiar with TMPGenc, but didn't find the way to change the flag there. Thanks in advance.

--Leonid

AVIL
8th October 2006, 00:09
Hi,

Get an utility called ReStream:

http://www.free-codecs.com/download/ReStream.htm

1. Demux with TMPGENC.
2. Apply ReStream on mv2 file
3. Remux with TMPGENC the modified mv2 file.

Good luck

zoinbergs
9th October 2006, 01:08
Does MPEG2 video exist where the bottom is really first? Or is it just a flag thing?

I think I have some video that goes [x.1a][1b.2a][2b.3a][3b.4a]... but it's not progressive shifted over, it's really interlaced material.

I believe it plays backwards-forwards-backwards (jumpy) when I create the avisynth script:

Mpeg2Source(........)

AssumeFrameBased()
AssumeBFF()
SeparateFields()

and run it frame-by-frame through VDubMod.

How would something like this play on a regular TV w/ a set-top DVD player? I always thought TVs displayed the top field first, then the bottom.

Man my head hurts! I'm so confused! I just got the hang of interlaced too.. until of course I ran into BFF!

Also, if it's truly BFF material, does one have to actually re-encode it using a field-reversal of some sort?

Thanks to any who can enlighten me!!!

neuron2
9th October 2006, 03:37
Does MPEG2 video exist where the bottom is really first? Yes.

I think I have some video that goes [x.1a][1b.2a][2b.3a][3b.4a]... but it's not progressive shifted over, it's really interlaced material. That sounds incoherent to me.

I believe it plays backwards-forwards-backwards (jumpy) when I create the avisynth script:

Mpeg2Source(........)

AssumeFrameBased()
AssumeBFF()
SeparateFields()

and run it frame-by-frame through VDubMod. Then you should try TFF.

How would something like this play on a regular TV w/ a set-top DVD player? I always thought TVs displayed the top field first, then the bottom. You're asking what happens when the MPEG stream specifies a field order different from the display device. The display process will simply discard the first field from the stream and then begin playing, with the stream and display now aligned in field polarity.

Also, if it's truly BFF material, does one have to actually re-encode it using a field-reversal of some sort? No.

zoinbergs
9th October 2006, 05:54
Oops, I forgot to mention that I ran that specific avisynth script on purpose, to see if my clip was really outputting BFF (which it was).

The display process will simply discard the first field from the stream and then begin playing, with the stream and display now aligned in field polarity.

Thank you for your insight! How interesting that it does that, too.


Okay, so I have multiple clips going into one track w/ chapters... most clips (but now chapters at this point) are TFF, and one is BFF. Am I correct in believing that the track will play fine in a DVD player -- just dropping that one field when the time comes?

Mug Funky
9th October 2006, 11:20
that'll be fine.

how the player handles it is not specified in mpeg-2 specs (just says it's _allowed_ to drop/add a field, but implementation is up to the manufacturer), but all players are required to be able to handle field-order transitions, and lots of discs out there have them (make a d2v and if there's a .bad file then there's been a field-flip at some stage, usually right at the beginning or end).

zoinbergs
9th October 2006, 12:33
Thank you so much for helping me out on this Mug Fanky!

I think in time I'll get the hang of all this....



Hmmmm.....

So I noticed in the post that started this thread that the guy had true TFF footage, but that it simply was playing back BFF.

While a simple restream could do the trick to fix such an issue...

Could restream's "top field first" button be checked for truly BFF material? Would that just physically discard the first field in the file, or like, simply tell players to do such a thing?



Ooh! My mind is ticking.. and I just thought up a good question (I think).

This is prolly somewhere else in the forum.. but my search has turned up nothing (yet)...

Are there two ways that MPEG2 is encoded? Like, field based (interlaced) and frame based (progressive)?

What I mean is, are 59.94 actual FIELDS being encoded (consecutively and separately) in an MPEG2 stream, as opposed to say, 29.97 interlaced FRAMES -- that players spit into fields and play that way?

I see in restream that all my clips show either all TFF or all BFF in the GOP section... could I presume that in those there exists frames with two pictures woven together and are in essence one "bitmap." Or is the weaving done only when the file is played (say on a progressive monitor)?

Because if my guess is correct, I believe my interlaced MPEG2 clips are all encoded field-by-field (59.94 of them in a second), thereby allowing a field drop with ease, if requested, as opposed to cutting a progressively encoded interlaced frame in half.

My oh my, why can't this world just have produced progressive TVs as the standard when they were invented! Interlacing (especially FILM footage) just seems so, unnecessary!

I guess that's life though.. and ya gotta get used to it, right?

Thank you SO much for helping me out on this, whoever you may be. =) Hopefully I can use what I learn to help other people like myself!

Mug Funky
9th October 2006, 17:21
mpeg-2 allows a few ways to encode interlaced.

most of the time the frame is encoded as a full frame (ie both fields), but that can have several options that make interlaced frames compress easier - interlaced DCT, interlaced ME, and alternate scanning.

some encoders (Procoder, Mainconcept, bbEnc, not sure what else) support field-pictures. this is more like 59.94 (or 50) discrete fields encoded per second. i'm not sure what the efficiency gain is with field-pictures, but i suspect it's quite a lot on higher motion interlaced stuff. i imagine frame pictures would have the edge when not much is moving.

My oh my, why can't this world just have produced progressive TVs as the standard when they were invented! Interlacing (especially FILM footage) just seems so, unnecessary!

technology at the time didn't really allow for 60p or 50p. and 25p or 30p would be a tad rough on the eyes - it'd flicker like hell.

also, the timebase for power supplies in europe/england/australia/most-of-the-world is 50Hz, and in north america and japan (and almost nowhere else!) the timebase is 60Hz. so it makes sense for TVs and cameras to fit nicely into that. the 59.94 v 60 is a quirk of NTSC colour. i've never heard a good explanation for it beyond "it's for the colour" though, and PAL certainly didn't need it.

the big question is "why, in this brave new world of High Definition, digital technologies, progressive displays, et cetera, did we continue with interlaced pictures?" 1080i?? why not develop HDMI with a bit more bandwidth and go 1080p at 48fps, or something more closely related to film. sticking to NTSC/PAL rates has solved no problems at all - just added more lines.

perhaps it's to keep companies like Snell & Willcox in business? :)

leonid_makarovsky
9th October 2006, 17:44
Thanks a lot! That worked!

--Leonid

Hi,

Get an utility called ReStream:

http://www.free-codecs.com/download/ReStream.htm

1. Demux with TMPGENC.
2. Apply ReStream on mv2 file
3. Remux with TMPGENC the modified mv2 file.

Good luck

zoinbergs
10th October 2006, 00:43
the big question is "why, in this brave new world of High Definition, digital technologies, progressive displays, et cetera, did we continue with interlaced pictures?" 1080i?? why not develop HDMI with a bit more bandwidth and go 1080p at 48fps, or something more closely related to film. sticking to NTSC/PAL rates has solved no problems at all - just added more lines.

perhaps it's to keep companies like Snell & Willcox in business? :)


Hehe, I totally agree! 1080i seems like a ridiculous concept when you got all this new technology to work with.

I'm guessing they did it for backward compatibility, perhaps? Maybe so broadcast stations can send out just one interlaced stream (that can automatically be recognized and decoded by regular TVs as a 720x480 stream), but that HD receivers can pick up at a full 1920x1080. Much like with how DD5.1 AC-3 streams are automatically downmixed to 2.0 if a DVD player can't actually decode all six channels. Just a guess though. :o

I see on broadcast stations all the time (like FOX) that say "shown in HDTV where available." I presume all you need is an HDTV decoder to take advantage in the detail increase?