Created
August 29, 2017 13:34
-
-
Save SavinaRoja/9008b09060ad0ed18e230b2d7d1fa156 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Multitranscode - Perform a series of h264 video transcodes on the input video | |
Usage: | |
multitranscode <input> [-p PRESET] [-t TUNE] CRF ... | |
multitranscode (-h | --help) | |
multitranscode --version | |
Arguments: | |
CRF ... The CRF value to use for libx264, 0 is lossless and the standard | |
range for lossy is usually 18 to 28. | |
PRESET The libx264 presets will be recognized here to modify encode rate. | |
examples: veryslow, slow, fast, ultrafast | |
TUNE The libx264 tune settings will be recognized here to modify certain | |
encoding parameters. examples: film, zerolatency, fastdecode | |
Options: | |
-p --preset <preset> libx264 preset to use [default: veryslow] | |
-t --tune <tune> libx264 tune setting to use [default: film] | |
-h --help Show this screen. | |
--version Show version. | |
https://trac.ffmpeg.org/wiki/Encode/H.264 is your friend! | |
""" | |
from docopt import docopt | |
import subprocess | |
if __name__ == '__main__': | |
args = docopt(__doc__, version='Multitranscode 1.0') | |
for crf_val in args['CRF']: | |
if crf_val == '0': | |
name = 'xcode_lossless_h264.mkv' | |
else: | |
name = 'xcode_crf{}_h264.mkv'.format(crf_val.zfill(2)) | |
#Perform the transcodes | |
subprocess.run(['ffmpeg', '-i', args['<input>'], | |
'-map', '0', | |
'-c:a', 'copy', | |
'-c:v', 'libx264', '-preset', args['--preset'], '-tune', args['--tune'], '-crf', crf_val, name]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment