I do have a video portrait shot (sincerely recommended not to do so ..), into the computer after it is bound to take rotated 90 °, but did not expect such a simple function, try the N non-linear editing software (openshot , pitivi, still lives father of the pit) after that no one can meet my requirements. Either> does not support custom resolution (openshot), either the image imbalance (pitivi), or is unresponsive (lives, feel that the goods are of major non-linear editing workstation tools, and other Cock silk I can not control). Finally, reluctantly, himself google, foreigners still find tricky, a command to save the world:
ffmpeg -i INPUT.AVI -vcodec libx264 -preset slower -crf 18 -threads 4 -acodec copy OUTPUT.MKV
Explain parameters:
-i
Be transcoded file-vcodec
Select the video encoding. Did some searching, compared with MPEG2, MPEG4, etc., H.264 is recognized as the best high-definition encoding format, while the compression ratio is also higher than MPEG4, so I chose to use H.264 (libx264) for video encoding.-preset
Encoding preset selection, slower = better video quality value can be selectedultrafast
,superfast
,veryfast
,faster
,fast
,medium
,slow
,slower
,veryslow
,placebo
.placebo
It is useless values.-crf
Constant Rate Factor, ranging between 0 to 51, 0 is lossless, the default value is 23, the larger the value, the poorer the overall quality of the video. This parameter is generally between 18 and 28. 18 has reached a visually lossless effect that the human eye can hardly notice the difference and the original film.-threads
Encoded using threads, CPU core is set a few a few threads as well.-vf
Filter, we only need to use a rotary filtertranspose=2
,transpose
the filter is preferably 90 ° counterclockwise 0-3,0 and vertical flip, 1 is rotated by 90 ° clockwise, 90 ° counterclockwise rotation of 2, 90 clockwise. 3 ° and flipped vertically.-acodec
Audio coding, here directly tocopy
retain the original file audio encoding.- Finally, set the output file to OUTPUT.MKV
Detailed Description Parameter refer the FFmpeg and x264 Encoding Guide .