forked from happycube/ld-decode
-
Notifications
You must be signed in to change notification settings - Fork 46
/
gen_chroma_vid_palm.sh
executable file
·42 lines (39 loc) · 2.24 KB
/
gen_chroma_vid_palm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
CHROMA_DECODER="transform2d"
CHROMA_GAIN=1
FILTER_COMPLEX="[1:v]format=yuv422p10le[chroma];[0:v][chroma]mergeplanes=0x001112:yuv422p10le[output]"
# Append audio track captured over line input or with external sound recorder, skip if absent:
if [ -f "$1.wav" ] ; then
ffmpeg -hide_banner -thread_queue_size 1024 \
-color_range tv \
-i <( \
ld-dropout-correct -i "$1.tbc" --output-json /dev/null - | \
ld-chroma-decoder --chroma-gain 0 -f mono -p y4m --input-json "$1.tbc.json" - - \
) \
-i <( \
ld-dropout-correct -i "$1_chroma.tbc" --input-json "$1.tbc.json" --output-json /dev/null - | \
ld-chroma-decoder -f $CHROMA_DECODER --luma-nr 0 --chroma-gain $CHROMA_GAIN -p y4m --input-json "$1.tbc.json" - - \
) \
-itsoffset -00:00:00.000 -i "$1.wav" \
-filter_complex "$FILTER_COMPLEX" \
-map "[output]":v -c:v ffv1 -coder 1 -context 1 -g 30 -level 3 -slices 16 -slicecrc 1 -top 1 \
-pixel_format yuv422p10le -color_range tv -color_primaries bt470bg -color_trc bt709 \
-colorspace bt470bg -aspect 4:3 -c:a flac -compression_level 12 -map 2:a? -shortest -y "$1.mkv"
else
ffmpeg -hide_banner -thread_queue_size 1024 \
-color_range tv \
-i <( \
ld-dropout-correct -i "$1.tbc" --output-json /dev/null - | \
ld-chroma-decoder --chroma-gain 0 -f mono -p y4m --input-json "$1.tbc.json" - - \
) \
-i <( \
ld-dropout-correct -i "$1_chroma.tbc" --input-json "$1.tbc.json" --output-json /dev/null - | \
ld-chroma-decoder -f $CHROMA_DECODER --luma-nr 0 --chroma-gain $CHROMA_GAIN -p y4m --input-json "$1.tbc.json" - - \
) \
-filter_complex "$FILTER_COMPLEX" \
-map "[output]":v -c:v ffv1 -coder 1 -context 1 -g 30 -level 3 -slices 16 -slicecrc 1 -top 1 \
-pixel_format yuv422p10le -color_range tv -color_primaries bt470bg -color_trc gamma28 \
-colorspace bt470bg -aspect 4:3 -shortest -y "$1.mkv"
fi
# Encode internet-friendly clip of previous lossless result:
#ffmpeg -hide_banner -i "$1.mkv" -vf scale=in_color_matrix=bt601:out_color_matrix=bt709:768x576,bwdif=1:0:0 -c:v libx264 -preset veryslow -b:v 6M -maxrate 6M -bufsize 6M -pixel_format yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -aspect 4:3 -c:a libopus -b:a 192k -strict -2 -movflags +faststart -y "$1_lossy.mp4"