View Full Version : Lossless cutting of H264 video?
whugemann
27th July 2009, 19:12
My new JVC HD camcorder records in MTS format. I wonder whether I could cut these files losslessly by any chance. Basically, I would like to extract smaller chunks from larger files.
With my former DV camcorder, this could be achieved with VirtualDub via "DirectStreamCopy". Something comparable should be possible with H264 video files, too, as long as I start at an I-frame. Has anyone ever heard of a program which can perform this task?
Is there any analysis tool comparable to G-Spot, which performs an I-P-B-analysis for AVI files?
So far, I manipulate the MTS files with AVIsynth / VirtualDub by using the Haali splitter and the H264 codec from ffdshow tryouts. Works fine, but not lossless.
Gokumon
27th July 2009, 22:14
Yes, there are plenty of programs that can split transport streams losslessly. For example there is TSSplitter (http://www.ffprojects.net/tssplitter/).
whugemann
28th July 2009, 08:38
Thanks, I have just tested TSSplitter and it comes close to what I am looking for: I can at least cut any MTS file into several chunks. The aim of TSSplitter is obviously to cut the video into chunks that fit on certain media.
But I only want to cut out pieces of several seconds: We do crash tests and the camera runs for a few minutes, while the main event takes about one second.
So I am more or less looking for a viewer / player that allows me to jump to the next / previous keyframe (like VirtualDub) and allows me to extract a video part starting with a certain keyframe.
Any hints?
patoloco
28th July 2009, 18:42
Perhaps 'iframes' will work for you.
http://jonkers.net.au/Iframe.aspx
cheers,
//p
setarip_old
29th July 2009, 04:11
@whugemann
Hi!
"tsMuxeR" should serve your needs nicely ;>}
whugemann
29th July 2009, 08:17
IFrames:
As far as I understood, IFrames automatically identifies scene changes by fades, etc. (In fact, I wondered, how tsSplitter would do this, probably cutting in the middle of a scene (?)) Iframes however did not display any "scenes" in my MTS file, possibly because they generally show only one scene.
tsMuxeR:
Yes, you can extract a certain time range from a video (which you have to identify first by means of another program, I guess). However, I couldn't figure out whether this extraction is lossless or not; the program description just doesn't tell (?).
tsMuxeR:
Yes, you can extract a certain time range from a video (which you have to identify first by means of another program, I guess). However, I couldn't figure out whether this extraction is lossless or not; the program description just doesn't tell (?).
Sure it's lossless. When splitting/cutting streams, tsMuxer works in pretty much the same way as TSSplitter. These tools don't even decode the video completely.
LoRd_MuldeR
29th July 2009, 14:55
IFrames:
As far as I understood, IFrames automatically identifies scene changes by fades, etc. (In fact, I wondered, how tsSplitter would do this, probably cutting in the middle of a scene (?)) Iframes however did not display any "scenes" in my MTS file, possibly because they generally show only one scene.
Not exactly. I-Frames are frames that are compressed without reference to other frames. And hence they can be decoded without "knowing" other frames.
However in H.264 the I-Frames aren't necessarily "cut points", because H.264 allows multiple references. So a P-Frame (or B-Frame) after the I-Frame may reference to a frame before the I-Frame!
In that case we need to "know" frames located before the I-Frame to decode the frames located after the I-Frame. Cutting the stream at such I-Frames would result in a borked stream :eek:
Therefore H.264 has yet another type of Frame: IDR-Frames. These IDR-Frames are guaranteed to be "cut points", because the flush reference buffer.
To make things even more complicated, even normal I-Frames may be perfectly valid "cut points", which can be indicated by the encoder via special Recovery Point messages in the stream...
(BTW: A "smart" encoder would place I- or IDR-Frames at scene changes, indeed. That's because a P- or B-Frame wouldn't be beneficial there. But that isn't guaranteed at all)
Helpful information on the topic, although I'm not sure if you noticed that whugemann was referring to the IFrames (http://jonkers.net.au/Iframe.aspx) application that patoloco mentioned above. Have to say that naming a tool this way can be seriously confusing. :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.