Log in

View Full Version : MPEG-2 decoding filter with timecode burn-in ?


MaeWanto
18th June 2006, 09:24
Would anybody know an MPEG-2 decoding directshow filter with timecode burn-in feature ?
Actually, I have to transcode an MPEG-2 file ( with valid timecode into its video ES GOP headers ) to MPEG-4 and WMV with the timecode displayed in the video frame.

FredThompson
19th June 2006, 05:07
Huh? What do you mean by "timecode"? You have some form of MPEG-2 stream with an embedded time signal like that of a DV camcorder?

Many, many moons ago I asked for help with an AviSynth script to add frame numbers to a stream which is useful for discussing the content of a stream when people are in different locations. I don't remember all the people who helped but you could probably find the thread in the AviSynth forum. The code I kept is:

# Frame number overlay
#
vid00=last
BlankClip(vid00,width=70,height=58,color=$000000)
SeparateFields()
AssumeTFF()
SelectEven()
vid01=ShowFrameNumber()
Layer(vid00,vid01,"add",x=10,y=441,use_chroma=true)

You might also want to look at Thomas Hargrove's VirtualDub filter Add Frame Numbers http://toonarchive.com/addframenumbers/ and fccHandler's VirtualDub filter showtime http://forums.virtualdub.org/index.php?act=ST&f=7&t=9935

Visual DV Time Stamp will add the code which is embedded in DV http://www.dts8888.com/vDTS/vdts.htm

MaeWanto
19th June 2006, 07:21
Huh? What do you mean by "timecode"? You have some form of MPEG-2 stream with an embedded time signal like that of a DV camcorder?
Absolutely, MPEG-2 video elementary streams contain some timecode information and I would like to burn this information into the video frame of a transcoded MPEG-4 file.

Regarding Avisynth, I could use the ShowSMPTE function, but I can't detect automatically the timecode provided in the MPEG-2 file ...
http://www.avisynth.org/Showframes

FredThompson
19th June 2006, 07:40
There is absolute timecode information, such as that supported by DV and there is offset information. I suppose it's possible there are MPEG-2 streams which would contain absolute timecodes. Maybe that is done with some area surveillance systems or something like that.

Relative offset is something you could emulate, so to speak, since you know the frame rate and the starting point will always be 0, right? You can use trim() to exclude parts of the stream you don't want while maintaining the pointer integrity related to the 0 point. You could also load the stream into VirtualDub and serve only the parts you want with the first plugin I mentioned.

DGDecode can handle the vast majority of MPEG-2 streams and deliver valid fields and frames, even if the source is streaming MPEG-2 with things like repeated fields or flipping dominance.

It seems like you're being too clever by half. Why do you need to reference the actual relative timecode if you can get the same values through addition?

Does this make sense or is there something I'm missing?

foxyshadis
19th June 2006, 08:08
Maybe it has something to do with out-of-order b-frames, but I can't really figure out why you'd want that. Or the stream is cut up quite a bit already and he wants to know where it's cut and by how much? Dunno.

MaeWanto
19th June 2006, 08:40
Actually, the MPEG-2 file comes from the acquisition of a Digital Betacam tape with a professional board ( Vela Argus ). The MPEG-2 file has the same timecode than the tape ( the VITC contained in the tape is converted to valid timecode information into MPEG-2's video ES GOP Headers ). I need now to produce an MPEG-4 proxy from the MPEG-2 master source file with the same timecode burnt into the video frame ( for logging needs ). I'm then looking for the best way to automatically extract the timecode informations from the MPEG-2 file in order to burn it into the video frame of the MPEG-4 proxy ...

Wilbert
19th June 2006, 10:31
DGMPGDec 1.4.7 Final:
* Added an option to dump the audio and video PTS/DTS timestamps encountered during a Save Project operation.

http://forum.doom9.org/showthread.php?t=107731

I have no idea how to burn this into your video stream.

Guest
19th June 2006, 12:35
@Wilbert

Those are the PTS/DTS values, not the GOP timecodes. And MaeWanto wants the timecode burned into the video.

The stream carries the timecode in the GOP header and it applies to the first picture with a temporal reference of zero. So to calculate and burn a timecode for each picture will require the decoder to calculate the timecode for the other pictures, allowing for picture structure and picture reordering, and then overlay it in text on the video. I'm not aware of any decoder that does that.

I could do it in DGMPGDec, but MaeWanto specified a DirectShow decoder.

MaeWanto
19th June 2006, 13:51
I could do it in DGMPGDec, but MaeWanto specified a DirectShow decoder.
Actually, DGMPGDec would be great for me ... I talked about DS filter because I thought this was the easiest way to build a transcoding graph with graphedit, but any other solution is absolutely welcome !