PDA

View Full Version : editing Mpeg2- Files without losing quality


Matt Kirby
26th April 2005, 14:18
I have captured a movie from DVB-Sat (Format: 704*576 MPEG2) and it has very good quality (better than some DVDs) Of course I don't want to lose it by encoding. But I want also crop the logo from the TV-station away. Exactly i want to "over-paint" it. The movie has a black letterbox frame where fortunately the logo is inside. Now i ask myself why isn't it possible to set the pixels (blocks or areas) at the bottom of every picture to black. Nothing has to chance than this colorvalue. Transcoders do things that are more difficult but they don't need to encode the file. Perhaps some guys from here who have the knowledge of MPEG2 and Transcoding/Encoding can help me. I'm sure that i'm not the onlyone who is interested in a loss-free technology for editing pictures of a movie.

Selur
26th April 2005, 16:53
"Transcoders do things that are more difficult but they don't need to encode the file."
there's a transcoder that doesn't reencode the file, don't think so,..
(if you are speaking of tools like dvdshrink you might want to read up how they work,..)

afaik there's no method to crop/remove parts of the pictur from an mpeg file without reencoding.

Cu Selur

Matt Kirby
26th April 2005, 17:27
will ja nichts wegschneiden sondern nur vorhandene Werte auf schwarz setzen.

lark
26th April 2005, 18:11
and the official language was.... sauerkraut?

even if you don't want to crop, you'd need to define somehow the area to be blanked and then perhaps the macroblocks should be altered (don't know about that, depends on the area).
in theory, if the area to be blanked would correspond macroblocks, this might be doable, but what if there's something right next to the area and it belongs to the same macroblock...

regards
t :)

fu2k
27th April 2005, 02:52
TV stations often want to insert their logos into already compressed MPEG2 streams. They have special purpose devices/software that can do this without reencoding anymore of the picture than is necessary. This is not so straightforward, since motion compensation can easily drag the corners of the screen to the centre in subsequent frames.

So what you ask for is possible in theory, but I know of no way for it to be available to you in a cost effective manner.

SeeMoreDigital
1st May 2005, 12:58
Hi fu2k.... Welcome back :D


Cheers

fu2k
2nd May 2005, 10:42
I never went away. I read these forums every other day. I just don't post much.

jpyeron
3rd May 2005, 01:17
It has been a very long time since I read a MPEG standard, but you will get artifacts or spend many CPU cycles preventing the artifacts by blotting out the logo.

You might have a better time trimming the bottom (and top) rows off the image.

I don't know what will happen if you have motion reference from off picture????

Would it use NTSC or PAL reference black?????? or execute a HCF instruction.

Matt Kirby
10th May 2005, 20:13
meanwhile i decided to put a black empty subtitle border above the logo
it's better than encoding

E-Male
10th May 2005, 20:56
was juts about to recommend this


also this should be moved

Matt Kirby
11th May 2005, 00:26
to forum "users who solved their problems alone"

hank315
11th May 2005, 22:38
to forum "users who solved their problems alone"And there's nothing wrong with that, it could just mean you're smarter than the rest :D

But the reply of fu2k just said it all, if the Macro Blocks of the logo are used for motion estimation
it's almost impossible to remove them without re-encoding.
If they are just simply inserted in the black bar without reference to other parts of the frame it can easily be solved.

So you have to check that first.

Enots_
25th May 2005, 13:42
One would not have to re-encode the entire picture of the sequence in question, reencoding the macroblocks in question would do the trick. There are a few limitations on that however. First there is the problem if in a non-reference frame one of the macroblocks you need to reencode is in the middle of a sequence of skipped blocks and a new skipped block won't do the trick. This will throw off the sequence and force you to re-encode more than the relevant one macroblocks. Since the guy asking the question was talking about black bars it's very likely to have skipped blocks.

However that opens up another possibillity when you have black bars you usually have a black bar on the bottom of the picture too. This usually contains a slice of all black macroblocks. Now replace the slice containing the logo with a copy of the slice from the bottom of the picture and modify the slice header to fit. This shouldn't be all together too difficult given that sliceheaders are on byte boundries.

Last since we're this is all likely to change the size of the pictures we'd have to revist the packetizing and buffer model of the muxing.

As a side comment - motion vectors outside the picture are not allowed and can cause decoders to crash, resynchronize, ...

Anyway there is a far simpler technique. Meassure out where the logo is. Cut out a piece of black cardboard this size and glue it over that spot on your TV.

Koepi
25th May 2005, 13:54
Originally posted by Enots_
Anyway there is a far simpler technique. Meassure out where the logo is. Cut out a piece of black cardboard this size and glue it over that spot on your TV.

Cool. I'm going to write an app which let's you select the logo-area, let's you enter the size of your TV set/beamer/... and then prints a black rectangle of that size (if too large, i.e. for cinematic sizes, it'll use that old but fency poster-technique where you have to cut out and glue together more pages).

Far simpler to code than a stream analyser+modifier+... ;)

Cheers
Koepi

P.S.: since i'm so busy at work, it'll need some time though ;) I hope 6-12months is ok for you!

Matt Kirby
25th May 2005, 14:10
That's ok

Would you send an alpha Version to me every month ?

communist
31st May 2005, 21:18
http://forum.doom9.org/showthread.php?t=77313
Its doable with special hardware so I guess it should be doable in software - someone just needs to write a program for it ;)

vhelp
1st June 2005, 05:09
I'm not MPEG expert, though I have been stuying it at a slow pace..

I think I understand that "slice" bit too. But, isn't that *before*
the motion-compenstion part ??

Anyways. How about working in grids, ( MPEG-2 's 16x16 ) and replace
with either a clean grid or a new one (ie, a dif color) that is.

Instead of re-encoding, can't this be done *directly* through the
process of reading in a stream sequence, if you can pull them by
frames each, and work that way..

1 --> open MPEG stream
2 --> read in one frame
3 --> dissassemble the macro-blocks in ques. (assuming bottom logo area)
4 --> replace with fresh set of macro-blocks (can ben whatever - mask)
5 --> advance to next frame.

But, I think that this would be hard for two other reasons.. (hank,
correct me if I'm wrong) motion compensation, were who's macro block
areas are in motion and worked on.. and the other reason.. there may
not be any clean blocks to (that have no logo pixel data in) replace
with clean one pixels.

But, in my understanding of MPEG, I see no reason to re-encode, if
you know the machanics of MPEG stream and frames, and how they are
put together, and if there are no obsticles (such as motion compensation)
to be in the way, *then* one could be able to minipulate pixels
information w/out too much damanage (if any) if you work on the macro
blocks boundaries. But, how would that effect the "bitrate" info,
and maybe other hidden detials. I don't know. I'm just basing
these ideas off my continueing learing of MPEG. ( I am in the
process of creating an MPEG encoder of my own, starting with MPEG-1
for now, and later, to move onto MPEG-2 I hope. maybe seek some
advice here. anyways)

Cheers,

-vhelp

exx452
26th December 2005, 15:08
meanwhile i decided to put a black empty subtitle border above the logo
it's better than encoding

Deutsch: Super Idee mit den Untertiteln. Kannst du bitte eine kurze Anleitung schreiben, wie und mit welchem Programm du das gemacht hast (meinetwegen auch nur auf Deutsch)?

Englisch: Great Idea with the subtitles. Can you please make a short guide, how and with which program you had made this?

Und jetzt noch ein Zitat, was zu deinem Namen passt:
"Hey, du Meisenarsch! Mach mal ganz schnell diesen hier oder willst Du Deine Schwingen in der Schlinge tragen?"

devilrider
21st January 2006, 22:02
also ich bin nicht der experte abr ich glaube as das nicht so einfach ist, währe zwar möglich aber glaub sehr rechenintensiev.

Es gab mal ein geiles TV Tool zum DVB aufnehmen bei dem man schon beim anschauen des Senders die logos raus machen konnte, dies wurde leider jedoch Verboten da es eine Verfügung gab das dies nicht erlaubt sei. Gab auch TV und Videorekorder die von sich aus Logos rausnhemen konnten auch alle vom Markt verschwunden (zumindest in europa) - Media-mafia sei dank.

Weis den Namen nicht mehr von dem tool aber denk mal wird eh schwer das aufzutreiben :/

Falls noch wer das DigiTV Tool kennt, Name oder besser DL-Link wär cool.

Denke das wär coolste lösung für dich.

devilrider
21st January 2006, 22:09
http://forum.doom9.org/showthread.php?t=77313
Its doable with special hardware so I guess it should be doable in software - someone just needs to write a program for it ;)

Hm overread that one, like (in german) i stated before i know there where TV's and video-recorders and even a software DVB-TV Viewer with MPEG2 recording function that where able to remove Logos, but all vanished from market.

About the software maybe some one remembers its name, it was in maybe around 2000 when it was spread in the net, but was closed down due lawsuite (like DVD Decryptor).

Dmitry Vergheles
22nd January 2006, 12:38
I have captured a movie from DVB-Sat (Format: 704*576 MPEG2) and it has very good quality (better than some DVDs) Of course I don't want to lose it by encoding. But I want also crop the logo from the TV-station away. Exactly i want to "over-paint" it. The movie has a black letterbox frame where fortunately the logo is inside. Now i ask myself why isn't it possible to set the pixels (blocks or areas) at the bottom of every picture to black. Nothing has to chance than this colorvalue. Transcoders do things that are more difficult but they don't need to encode the file. Perhaps some guys from here who have the knowledge of MPEG2 and Transcoding/Encoding can help me. I'm sure that i'm not the onlyone who is interested in a loss-free technology for editing pictures of a movie.

In fact there is no need to recompress all the MPEG-2 stream to edit it (e.g. trim or cut out some commercial parts).

In a common case it is only necessary to recompress part of first and last GOPs. Ususly GOP consists of about 12 frames.

By the way such a feature (frame accuracy MPEG-2 trimming without full re-encoding will be implemented to Elecard XMuxer (http://elecard.com/products/consumer/156/xmuxer-pro)in the nearest future). Also there will be an appropriate editing SDK.