| 1 | #!/bin/bash
|
|---|
| 2 |
|
|---|
| 3 | # testing "vf_colorspace"
|
|---|
| 4 | # Produces separate playouts for both vf_colorspace range params as well as input -color_range,
|
|---|
| 5 | # multiplied by format ProRes4444 (fullrange) and ProResHQ (limitedrange) as separate runs.
|
|---|
| 6 |
|
|---|
| 7 | # Conclusion: ffmpeg version git-2017-06-09-9c6b982
|
|---|
| 8 | #
|
|---|
| 9 | # vf_colorspace irange WILL override the input "-color_range",
|
|---|
| 10 | # vf_colorspace irange is not a factor.
|
|---|
| 11 | # vf_colorspace range will NOT override the output pix_fmt,
|
|---|
| 12 | # vf_colorspace range is a factor, will be multiplied by the pix_fmt levels of the encoder
|
|---|
| 13 | #
|
|---|
| 14 |
|
|---|
| 15 | # Remark
|
|---|
| 16 | # Upon viewing the playouts, define the levels in the player manually as it might just follow the defaults.
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | # Define directories, including trailing slash
|
|---|
| 23 | path="/input/dir/with/files/"
|
|---|
| 24 | pathout="/output/dir/"
|
|---|
| 25 | mkdir -p "$pathout"
|
|---|
| 26 |
|
|---|
| 27 | # ffmpeg binary
|
|---|
| 28 | FFBIN="ffmpeg"
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | # filenames, separated by ":"
|
|---|
| 32 | input="PR4444_709_lim.mov"
|
|---|
| 33 | input="$input:PR4444_709_full.mov"
|
|---|
| 34 |
|
|---|
| 35 | mycodecs="prores3:prores_ks"
|
|---|
| 36 |
|
|---|
| 37 | # Change for each test
|
|---|
| 38 | r1="tv" # -color_range= tv|pc|xx
|
|---|
| 39 | r2="tv" # vf cs irange= tv|pc|xx
|
|---|
| 40 | r3="tv" # vf cs range= tv|pc|xx
|
|---|
| 41 |
|
|---|
| 42 | # Examples
|
|---|
| 43 | # input_lim > pc.tv.pc > pix_fmt lim > produces lim
|
|---|
| 44 | # input_lim > xx.tv.pc > pix_fmt lim > produces lim
|
|---|
| 45 | # input_lim > tv.tv.pc > pix_fmt lim > produces lim
|
|---|
| 46 |
|
|---|
| 47 | # input_lim > tv.tv.pc > pix_fmt full > produces full
|
|---|
| 48 |
|
|---|
| 49 | # input_lim > tv.tv.tv > pix_fmt lim > produces lim*lim
|
|---|
| 50 | # input_lim > pc.pc.pc > pix_fmt lim > produces lim*lim
|
|---|
| 51 | # input_lim > xx.pc.pc > pix_fmt lim > produces lim*lim
|
|---|
| 52 |
|
|---|
| 53 | # input_lim > xx.pc.pc > pix_fmt full > produces lim
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | # used but not tested
|
|---|
| 57 | ispace=bt709 # vf cs ispace= (built-in)
|
|---|
| 58 | space=bt709 # vf cs space= (built-in)
|
|---|
| 59 | itrc=gamma22 # vf cs itrc= (built-in)
|
|---|
| 60 | trc=gamma22 # vf cs trc= (built-in)
|
|---|
| 61 | iprimaries=bt709 # vf cs iprimaries= (built-in)
|
|---|
| 62 | primaries=bt709 # vf cs primaries= (built-in)
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | OLDIFS=$IFS
|
|---|
| 67 | IFS=':'
|
|---|
| 68 | for thisinput in $input;do
|
|---|
| 69 | if [[ "$thisinput" == '' ]];then
|
|---|
| 70 | continue;
|
|---|
| 71 | fi
|
|---|
| 72 |
|
|---|
| 73 | # copy the original for reference
|
|---|
| 74 | rsync -aq $path$thisinput $pathout$thisinput
|
|---|
| 75 |
|
|---|
| 76 | for thiscodec in $mycodecs;do
|
|---|
| 77 | IFS=$OLDIFS
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | # The included -pix_fmt is important as a factor
|
|---|
| 81 | if [[ "$thiscodec" == 'prores_ks' ]];then
|
|---|
| 82 | allencoderparams=' -c:v prores_ks -profile:v 4444 -alpha_bits 16 -quant_mat hq -pix_fmt yuva444p10le -b:v 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k ';
|
|---|
| 83 |
|
|---|
| 84 | elif [[ "$thiscodec" == 'prores3' ]];then
|
|---|
| 85 | allencoderparams=' -c:v prores -profile:v 3 -pix_fmt yuv422p10le -b:v 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k ';
|
|---|
| 86 | fi
|
|---|
| 87 |
|
|---|
| 88 | if [[ "$r1" != "xx" ]];then
|
|---|
| 89 | inpp="-color_primaries $iprimaries -colorspace $ispace -color_trc $itrc -color_range $r1"
|
|---|
| 90 | else
|
|---|
| 91 | inpp="-color_primaries $iprimaries -colorspace $ispace -color_trc $itrc"
|
|---|
| 92 | fi
|
|---|
| 93 |
|
|---|
| 94 | if [[ "$r2" != "xx" ]];then
|
|---|
| 95 | Pr2="irange=$r2:"
|
|---|
| 96 | else
|
|---|
| 97 | Pr2=""
|
|---|
| 98 | fi
|
|---|
| 99 |
|
|---|
| 100 | if [[ "$r3" != "xx" ]];then
|
|---|
| 101 | Pr3="range=$r3:"
|
|---|
| 102 | else
|
|---|
| 103 | Pr3=""
|
|---|
| 104 | fi
|
|---|
| 105 |
|
|---|
| 106 | "$FFBIN" -y $inpp -ss 0 -i "$path$thisinput" -ss 0 -frames 1 -an -filter_complex "[0:0]setfield=prog[vtmp1],[vtmp1]\
|
|---|
| 107 | \
|
|---|
| 108 | colorspace=ispace=$ispace:itrc=$itrc:iprimaries=$iprimaries:$Pr2\
|
|---|
| 109 | space=$space:trc=$trc:primaries=$primaries:$Pr3\
|
|---|
| 110 | format=yuv444p12:dither=fsb:wpadapt=identity\
|
|---|
| 111 | \
|
|---|
| 112 | [vtmp2]" -map [vtmp2] $allencoderparams -threads 0 "$pathout$thisinput-$trc-$r1.$r2.$r3-$thiscodec.mov";
|
|---|
| 113 | IFS=':';
|
|---|
| 114 | done
|
|---|
| 115 | done
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|