I want to re-encode a video "exactly like this one". Can I somehow export codecs and container settings from the example file and import them during the encoding process (except the obvious manual solution)?

I'm not copying the compression settings from the input file. There is LosslessCut for this (it also prevents the re-encoding at all). I want to take those settings them from an example file and apply them for re-encoding other files.

I want to achieve a full compatibility with videos taken by a particular camera. Including the ability to play them by that camera (of course, it's decoder is hard-coded and lacks compatibility), and merging the videos from that camera with re-encoded ones losslessly (so LosslessCut must take both camera videos and re-encoded ones as exactly the same format).


No such feature

When encoding ffmpeg will automatically attempt to copy some settings (width, height, frame rate, sample rate, channel layout, pixel format, etc). But it has no such feature to automatically copy all of the encoding settings from the input to the output. It's not really possible.

Stream copy

But you can stream copy (re-mux) instead of encode which is like a copy and paste:

ffmpeg -i input.mkv -map 0 -c copy output.mkv

Perhaps that will achieve what you are trying to do.

Manual method

See example at ffmpeg: transcode using same codec and params as input.

I am the author but I don't recommend doing this.

It's usually not a good idea

Trying to copy settings is almost always an example of the XY problem.

For example, a user may want to copy settings to get a video to play on a particular device. The result is often overly complicated with a suboptimal output when the actual solution is usually much simpler.

If you explain what you are actually trying to achieve we can give a more accurate answer.

  • I've tried to explain. Thanks for the example, it can be changed a bit to work with two different videos but I afraid the Size/Duration ratio is not enough to guess the exact quantization coefficient table :( so videos will not allow to merge streams losslessly (I understand it's not the "completely lossless" operation because the re-encoding I'm asking for can't be lossless, but I'm trying to keep the "etalon"/example intact and re-encode only one of two videos I'm trying to merge). – NickDoom Oct 8 '20 at 19:42
  • @NickDoom So the real question seems to be, "How to make video that plays in a particular camera?". Best way to do that is to provide a sample file from the camera. I can then give you a ffmpeg command that attempts to provide a compatible output. This isn't always easy though due to pickiness of cameras. – llogan Oct 8 '20 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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