Is there any software that can losslessly crop video? I did a Google search but was surprised not to find anything at all.
Incidentally, I've read a lot of people saying it's "impossible" to losslessly crop videos. What absolute nonsense! It may be difficult to write the software to do it, but it's certainly not impossible. In theory it's quite simple. Cropping I-frames losslessly is just like cropping a JPEG losslessly. And then for the B- and P- frames, it's simply a matter of adding the missing data back in, so they're no longer dependent on the missing parts of the picture. Far from impossible.
+ Reply to Thread
Results 1 to 16 of 16
-
-
Last edited by davexnet; 13th Jun 2019 at 12:48.
-
Any video that needs to be cropped has to be re-encoded,if it's nonsense to you that a program should be able to crop it lossless then you should write a program to do this.
I think,therefore i am a hamster. -
Maybe the OP should expand on his terminology.
'Lossless' could mean the codec employed and then any vid that does not already have a lossless codec will have to be totally re-encoded.
He may also mean that the existing video just retains all the current characteristics, codec, bitrate etc so then surely avidemux (if it supports the characteristics) can write the ctopped video back to disks using the 'copy' settings. Yes it is, in a fashion, re-encoded, but not as much as the 'total' example. -
The op wants to crop videos with no quality loss such as in muxing and cutting terms,can't be done.
I think,therefore i am a hamster. -
Yes, but I doubt he wants to increase the filesize by a factor of 10 or whatever it is.
He could crop it in an AviSynth script (as mentioned) or in the player, but that's just for playback, and to make a permanent copy at a reasonable size requires reencoding to a lossy codec. I think I remember jagabo mentioning cropping in the video headers or something, but that many (if not most) players wouldn't honor those crops. -
In this section of a post made in 2010, which I quoted below, jagabo explained why it still isn't possible to find editing software which can losslessly crop any video, even video that uses lossy codecs with interframe compression and motion vectors. It really is too difficult to crop such video without re-encoding it, even now.
In a section of another post in the same thread jagabo states that in theory, it should be possible to create editing software that is able to losslessly crop MJPEG.
[Edit]Re-encoding to crop = A bird in the hand, something that one definitely has access to now. Theoretical lossless cropping = A bird in the bush, something that might be obtainable at some date in the future, possibly the distant future.Last edited by usually_quiet; 13th Jun 2019 at 15:25.
Ignore list: hello_hello, tried, TechLord, Snoopy329 -
As the others have said above - not unless you stay uncompressed or losslessly compressed . You cannot regain the original lossy compression if you started with something lossy .
Besides temporal compression, Unlike jpeg, typical modern video compression such as AVC, HEVC also have Intra spatial prediction . This prevents you from cropping while still in the lossy compressed state
Also DCT codecs like AVC, HEVC have are different block sizes , sort of like a jigsaw puzzle. They are not arranged nicely in rows and columns like a rectangle. You can't arbitrarily crop some value without the possibility of cropping inbetween a block . -
OK when I said "lossless cropping", I thought that was fairly self-explanatory, but let me just clarify…
What I mean is to take a lossy video, crop it, and output a new lossy video, without re-encoding it.
Sure, it will be "re-encoded" in the sense that the software is re-building a new file, with some changes. But it won't be "re-encoded" in the sense of there being any further compression, quality loss, or relative change in the file size.
The vast bulk of the picture data will be effectively untouched and identical, the only changes being to those blocks which straddle or reference the cropped area, which would obviously have to be adjusted, or split into smaller blocks. That goes without saying.
There are programs which can losslessly crop lossy files such as JPEGs and mp3s. I assumed there must be some program that can do it with videos - I guess not.
But I don't see any reason why it's "impossible" as many people claim. "Impossible" is such an absolute statement. It may be difficult to program, but how can anyone say it's impossible? -
That makes it lossy when you use a lossy codec. That goes without saying.
Let's assume for discussion purposes that you can live with that loss:
Potentially for AVC that could be 32 pixels if you include the dependent neighbor (max block size is 16x16 for AVC) . HEVC can have 64x64 CTU's , but HEVC extends it 2 rows, so it's 192 pixels potentially affected at the borders .
Also you're thinking 1 dimensionally . It's a lot more complicated than that. It's a cascading problem
Inter prediction means other frames can rely on adjacent frames, and not just the frame border edges. Consider sequence where a car goes in an out of the frame left to right. Lets say it's 50% represented on the I frame (half in the frame, but coming farter into the frame the next frame). If you crop that car, it will affect those later frames in the central portion or the frame . So no, not just the borders and the perpheral adjacent area are affected
Also, modern codecs can use P and B frame references . They don't have to derive everything from the IDR frame . You might have a large residual in a nearby P or B frame used as reference
But I don't see any reason why it's "impossible" as many people claim. "Impossible" is such an absolute statement. It may be difficult to program, but how can anyone say it's impossible? -
We understood you fairly well.
What you are wanting could be 1: Crop "meta-data" which apply cropping during runtime (or "play"-time). Very few file formats support this. Of those, the only ones that easily support it are MPEG2, MP4 (w h264, h265 encoding), and possibly QT MOV (from which MP4 is based). And probably MKV.
But, as was mentioned already, finding a player app that HONORS those crop meta-data is what is virtually, if not truly, impossible. Go ahead searching for one that does, but I've been around for a long time here and I don't know of any (certainly not any that do it consistently).
An alternate option 2: would be what some above were referring to: actual re-encoding but without recompression. This would have to be done in the DCT domain and be based on blocks (so probably would have to be MOD2, MOD4, etc depending on the codec). However, there is currently NO software that I know of (single exception might be some old mpeg2 DCT reencode apps like ReMPEG, but those would ONLY work with MPEG2 of a certain type). It's not "impossible" but unless you want to write it yourself, or commission someone to write it for you, or drum up interest in others for you, there is NOTHING of this sort to help you.
JPEG does work in the DCT domain in a similar way, but in comparison in terms of complexity of format and complexity of application to modify, it is child's play, plus it has been around for at least 5-7 years longer than good old MPEG2, so has had more time to develop particular edit tools. MP3 has a similar function, and a similar history and a similar (relative) simplicity compared to modern codecs.
Face it, you can crop & encode, or not crop.
Scott -
metadata method does work consistently for software players - if it's done at the bitstream level , at least for AVC and HEVC (you can use ffmpeg -bsf for example)
For AVC it works on all typical software players VLC, MPCHC, Potplayer, etc... Browsers like firefox, chrome direct play ok too . HEVC isn't as well supported in browser
I think some hardware decoders choke on it e.g. some standalone portable players with cheap chipsets . And video editors won't like it, since it's a playback VUI flag. They might crash or show black borders where your crop area is
So if it's just for playback / viewing pleasure, metadata method is definitely an option -
I stand corrected. Didn't know they'd improved that much.
Hope the OP is using software players, then.
Scott -
There are some very common croppings for AVC/HEVC that should work on almost any player. E.g. "1080p" AVC video is really 1088p with crop metadata because AVC works with 16x16 blocks.
-
I’m in the same boat, that is, looking for a software that can take a video file, crop it and save to a new file without re-encoding it. That is, saving a new file with the same codec and wrapper as the original one, only a shorter video, or file. (Please ignore the debate of lossy vs. lossless).
Also, a software that can take few video files of the same resolution, codec and wrapper and join them to a new file without re-encoding it.
Doing it in the player or browser doesn’t answer my needs. Also, Avisynth without a proper GUI doesn’t work for me, for I’m not into scripting.
Is there any such solution?
Similar Threads
-
How can I losslessly capture video from an 8mm tape?
By Drew Neilson in forum Capturing and VCRReplies: 85Last Post: 29th May 2021, 01:22 -
Capture Analog Video Losslessly Via FireWire !!
By dellsam34 in forum Capturing and VCRReplies: 43Last Post: 20th Apr 2020, 00:22 -
Losslessly convert Professional resolution Master video from .mov to .m2ts
By Rajesh Singh in forum Video ConversionReplies: 10Last Post: 25th Sep 2018, 20:19 -
Decimate/De-duplicate H.264 video losslessly?
By tubagod in forum Video ConversionReplies: 11Last Post: 18th Nov 2017, 14:57 -
Cut/Copy .mp4 video losslessly to .ts container
By Rajesh Singh in forum EditingReplies: 2Last Post: 30th Aug 2017, 14:18