View Full Version : Editing H.264 without quality loss
neutrogenik
12th January 2007, 16:43
I finally get my dvb-t usb tuner to work with mpeg-4/AVC channels but i got problems for handling the recorded files.
What i would like to do is beeing able to cut some parts of the videos without loosing quality like with VideoReDo and mpeg-2 streams.
I was thinking about transforming the mpeg-4 files to mpeg-2 so i could use VideoReDo on them and also NvPurevideo for decoding (i can't do it on H.264 vids since i have a GF 6800GT) but i'm wondering if it's a lossless operation.
I tried to do it with HDTV2Mpeg but the soft doesn't recognize the channel :
http://img176.imageshack.us/img176/8656/clipboard01ja4.png
Here is a video sample (30 Mb - H.264 - mpg audio) : download (http://www.mediafire.com/?1yru24yk4mm)
:thanks: in advance for your help :helpful:
apk
12th January 2007, 16:50
you can convert to xvid/x264 and other formats and still maintain very good quality, can you explain a little more about what you would like to do?
neutrogenik
12th January 2007, 17:17
I'm using H.264 samples not xvid or x264 ones !
With mpeg-2 videos it is possible to cut some parts (like ads) without reencoding and so without loosing quality.
I'm wondering if converting mpeg-4/AVC to mpeg-2 is a lossless operation and how can i do it.
Blue_MiSfit
12th January 2007, 19:30
x264 is an implementation of the H.264 (MPEG-4 AVC) standard.
Xvid is an implementation of the MPEG-4 ASP standard.
MPEG-4 (ASP OR AVC) to MPEG-2 is not a lossless conversion. It's a re-encode, and will incur the usual losses. Editing MPEG-4 natively is usually tricky because of the long GOPs typically associated with such high compression formats. To edit without re-encoding, you have to cut on a keyframe, and keyframes can be sometimes 10 seconds apart.
The program HDTVtoMPEG2 is for working with transport streams containing MPEG-2 video, and I wouldn't be surprised if it doesn't work with MPEG-4 content. I'm not sure what program would work, perhaps ProjectX?
~MiSfit
neutrogenik
12th January 2007, 19:45
To edit without re-encoding, you have to cut on a keyframe, and keyframes can be sometimes 10 seconds apart.
Do you know a software that can do that ?
chilledoutuk
13th January 2007, 03:32
well i would demux the h.264 and then mux it into a avi and then cut it using vdub.
timekills
13th January 2007, 06:27
If you want to edit it without losing quality (initially, at least) re-encoding to a lossless codec is the only way due to the limitations in editing MPEG4 video mentioned above, and the inherent loss when reencoding to a lossy codec (I.E. MPEG anything).
I suggest reencoding to HuffyUV then editing. The problem is when you convert back to h264 it is still lossy.
bond
13th January 2007, 11:25
mux to .mp4 and use for example avidemux to edit the stream
neutrogenik
13th January 2007, 12:07
I read your MP4 FAQ which is very instructive but why should i change the container of my vid, it won't change the video / audio data right ?
So if I understand there's actually no way to edit my sample without reencoding ?
bond
13th January 2007, 12:37
because there is no avc in .mpg or .ts editor?
Jay Bee
13th January 2007, 12:49
Had a quick try.
Both chilledoutuk's and bond' suggestions kind of work but both couldn't decode the video you posted properly so you would have to edit "blind". And of course there is no way to do the kind of editing that VideoRedo does, with reencoding of single frames but AFAIK VideoRedo are working on it.
neutrogenik
13th January 2007, 15:39
because there is no avc in .mpg or .ts editor?
But the mp4 editors always reencode source videos right ? That's not what i'm trying to do !
Jay > that's a good news, so i'll be patient and wait for their new version :)
:thanks: again everyone for your answers.
bond
13th January 2007, 16:01
mp4 is a container. containers have nothing to do with reencoding
so no, converting to mp4 doesnt reencode...
frankio
13th January 2007, 16:50
I'm using TS Packet Editor for editing out commercial from H.264 Transport Streams.
You'd better check this thread: http://forum.doom9.org/showthread.php?t=114361&page=4
and the guide link Pookie gave in his post: http://forum.doom9.org/showthread.php?p=931497#post931497
neutrogenik
13th January 2007, 16:50
mp4 is a container. containers have nothing to do with reencoding
so no, converting to mp4 doesnt reencode...
That's not what i meant :)
I meant if i change the container to mp4 it won't make me able to cut some part of the vid without reencoding will it ?
frankio > thanks i'll check it
Edit : this was exactly what i was looking for, thanks a lot :)
Now i have to buy another graphic card so i can use Hardware H.264 decompression :P
Blue_MiSfit
13th January 2007, 23:59
AviDemux has support for editing MP4s, which is great, but like we said, it's only on keyframes AFAIK. That's about the best you can do now.
Of course, if it was possible to only re-encode a changed GOP, and do this automatically behind the scenes, we would have a sweet little editor... :)
~MiSfit
vlada
14th January 2007, 18:41
To summarize it:
Changing containers is a lossless operation. You can switch between TS <-> MKV <-> MP4 <-> AVI without any quality loss.
You can cut/join MPEG-1/2/4 video without recompression on keyframe positions. Avidemux can handle all 3 formats in AVI, MP4 and TS. MP4Box can also cut MP4 files. MKVToolnix can cut MKV files. AVI-Mux GUI cuts AVI and MKV files.
Jay Bee
14th January 2007, 21:12
But do any of them actually work for the file he posted? Avidemux gave me a garbled image and Virtualdub a black screen.
neutrogenik
14th January 2007, 23:20
TS Packet Editor works perfectly for cutting ts files without encoding :)
Jay Bee
14th January 2007, 23:54
Not quite. :) It couldn't decode the file properly but I can't show you since the garbled image doesn't show up in a screenshot. Try it yourself!
neutrogenik
15th January 2007, 00:30
I did :)
You need Cyberlinks power dvd 7 deluxe H.264 decoder to view it :)
Jay Bee
15th January 2007, 09:11
After de-registering all AVC decoders except CoreAVC, it indeed decodes properly with TSPE! The remaining problems are that TSPE can't jump to keyframes so I don't know what exactly I'm cutting and the resulting file has playback problems with both HDTV Pump (zero duration) and Haali Splitter (no sound).
EDIT: TS Converter also works now and the files it creates don't cause any playback problems. Now can anyone tell me how I can remux mp4 to TS?
Blue_MiSfit
18th January 2007, 09:00
You'll probably have to demux the raw 264 file from the mp4 first using mp4box/yamb, and then remux that into a ts... not sure how to do the second part :) ffmpeg maybe?
blubberbirne
18th January 2007, 10:30
mux to .mp4 and use for example avidemux to edit the stream
for me, the virtual dub way, is the better one. Its faster an less buggy :cool: It cut also the AC3 Stream.
After finisching cutting, you can mux it to mkv
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.