document current most important todo for jellyfin streaming
[hevc-pipeline.git] / hevc-pipeline.sh
CommitLineData
a6e74b9c
JC
1#!/bin/bash
2mapfile -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
898ff83b
JC
7if [ ${#hevc_films[@]} -eq 0 ]; then
8 >&2 echo "no files to process"
9 exit 1
10fi
11
a6e74b9c
JC
12printf '%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'"'"''
b557bf68
JC
26# TODO this cat generates an .mkv container with invalid timestamps or something else Jellyfin + HLS
27# can't understand. Requires reconstruction on the other side.
28# it's often re-encoded at >150x speed so it's not important, but maybe it should be piped to ffmpeg
29# on the other system automatically.
30# ffmpeg -i $out.mkv.new -map 0 -vcodec copy -acodec copy $out.mkv.new.mkv