8

I have videos I want to split across multiple screens, so the solution I've found so far is to just crop the input video 4 times with ffmpeg (is this optimal? Is there some other way so I only need to use one command?)

Anyways, in ffmpeg crop is a video filter, and it seems that I can't specify the video codec as copy when using a video filter. Why is this the case? It seems like nothing should change if I just remove some of the video. I should be perfectly capable of just copying the same video over, with just part of it removed.

Is there any way for me to do a crop in ffmpeg without having to do a re-encode? The extra encoding time makes my processing times really long and the new bitrates caused by the re-encode makes the video parts out of sync and unable to be played properly.

Thanks

1

1 Answer 1

15

A videofilter in ffmpeg always has to modify pixel information hence the reason why you need to re-encode. It seems logical at first that you wouldn't have to do this when cropping but the way lossy video codecs work makes this pretty impossible without re-encoding everything. They usually don't see an array of pixel information but a much more complex representation of pixel blobs that are described in a way that takes up less space than the original pixel blob, you can't really "crop" that encoding, to do a crop you would first need to decode the information to know what you are dealing with but then you need to re-encode to have it compressed again. Thats the main stepping stone. Then they also use things like motion estimation that depends on information before and after certain frames, if that information changes all of the sudden the whole thing is screwed up and you end up with tons of artifacts when decoding the video during playback.

tldr; no its not possible to crop without re-encoding in any tool.

Unless you deal with some very specific lossless non-consumer intermediate codecs that would enable it but in that case transcoding wouldn't be an issue.

5
  • 5
    Interesting bit of trivia: the way QuickTime movies work (.mov, at least pre-QuickTime X) actually did let you define and store crop, resize, minor edits, and even masks as metadata alongside the video stream; the player would just apply them on the fly.
    – NReilingh
    Oct 5, 2014 at 22:26
  • 1
    Interesting feature but sounds like a feature that probably has caused a lot confusions when a small resolution video is taking up huge amount of space because it was heavily cropped and you don't know why.
    – timonsku
    Oct 6, 2014 at 12:12
  • 1
    The only thing I would add is that some formats might support splitting along group of pixel boundaries, but this would only work in very specific formats using particular settings, so there is a slight caveat, but effectively, it isn't possible in most cases and isn't worth doing in most of the situations where it might even be technically possible.
    – AJ Henderson
    Oct 6, 2014 at 14:21
  • True that might be a workaround but probably very hard to actually implement practiacally.
    – timonsku
    Oct 6, 2014 at 14:28
  • Unless maybe you're using some kind of really raw pixel format?
    – rogerdpack
    Dec 2, 2022 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.