a6cc09abcd6c20c708adca2286984b6d67d0db6b
[hevc-pipeline.git] / hevc-pipeline.sh
1 #!/bin/bash
2 mapfile -t hevc_films < <(ssh mbp 'find /srv/deluge/Downloads/ \( -name '"'"'*.mkv'"'"' -o -name '"'"'*.mp4'"'"' \) -type f -print0| xargs -0 -P 4 -I@ bash -c '"'"'test "hevc" == $(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "@") && echo "@"'"'"'' )
3
4 # copy all streams from input 0 except subs and annotations
5 # -map -0:s -map -0:t \
6
7 if [ ${#hevc_films[@]} -eq 0 ]; then
8 >&2 echo "no files to process"
9 exit 1
10 fi
11
12 printf '%s\0' "${hevc_films[@]}" | xargs -0 -P 1 -I@ bash -c 'ssh mbp '"'"'cat "@"'"'"' |
13 ffmpeg \
14 -fflags +igndts \
15 -i - \
16 -map 0 \
17 -c:v libx264 -level:v 4.1 -tag:v avc1 \
18 -crf 23 \
19 -vf \
20 format=yuv420p \
21 -preset veryfast \
22 -c:a copy \
23 -f matroska \
24 - | \
25 ssh mbp '"'"'cat > "@".new'"'"''