This is not going to be trivial. I'm not aware of a single script that'd take care of these tasks, which are usually done manually. For the most info about the encoding settings, on Unix/Linux or OS X, you can use mediainfo
with some Bash tricks.
For example, for an x264-encoded video in an MP4 file:
mediainfo input.mp4 | grep "Encoding settings" | cut -d':' -f2- | tr '/' '\n' | sed 's/ //'
This will output a list of x264 options:
cabac=1 ref=3 deblock=1:-1:-1 analyse=0x3:0x113 me=hex subme=7 psy=1 …
You could then manually pass these options to the x264 binary.
If you go through FFmpeg, that's a little more complicated though, as not all of x264's options can or should be mapped like this. Note that often a simple preset, tune and profile specification will do as well (as seen in x264 --fullhelp
and the x264 encoding guide), and specifying the CRF level is enough.
And this is not even considering audio, where luckily, there aren't that many options.