Add more options
This commit is contained in:
parent
9f92e46111
commit
8221c36558
2 changed files with 74 additions and 80 deletions
127
README.md
127
README.md
|
@ -4,9 +4,13 @@ I wrote this to convert Judge Judy from ts files created by Plex to mkv files. T
|
||||||
|
|
||||||
# help
|
# help
|
||||||
```
|
```
|
||||||
[info] ts-to-mkv.sh -- v2
|
root@rn628x:/data/tv# ./ts-to-mkv.sh -h
|
||||||
|
[info] ./ts-to-mkv.sh -- v2
|
||||||
[help] -d, path to custom ffmpeg (default: /data/sourcecode/ffmpeg/ffmpeg-4.1.3-amd64-static/ffmpeg)
|
[help] -d, path to custom ffmpeg (default: /data/sourcecode/ffmpeg/ffmpeg-4.1.3-amd64-static/ffmpeg)
|
||||||
|
[help] -f, force overwriting existing files
|
||||||
|
[help} -n, never overwrite existing files
|
||||||
[help] -k, keep the original ts file
|
[help] -k, keep the original ts file
|
||||||
|
[help] -q, disable output from ffmpeg (default: info)
|
||||||
[help] -p, custom path to scan recursively (default: ./)
|
[help] -p, custom path to scan recursively (default: ./)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -15,81 +19,56 @@ I wrote this to convert Judge Judy from ts files created by Plex to mkv files. T
|
||||||
|
|
||||||
# Example Output
|
# Example Output
|
||||||
```
|
```
|
||||||
root@rn628x:/data/tv# bash ts-to-mkv.sh
|
root@rn628x:/data/tv# bash ts-to-mkv.sh -f
|
||||||
[info] ts-to-mkv.sh -- v2
|
[info] ts-to-mkv.sh -- v2
|
||||||
|
[debug] overwriting existing files
|
||||||
[info] finding files
|
[info] finding files
|
||||||
[info] working on ./Judge Judy/Season 23/Judge Judy (1996) - S23E214 - Ice Cream Parlor Owner Not so Sweet .ts
|
[info] working on ./Cops/Cops - S28E32 - No Helmet, No Ride (RawHD).ts
|
||||||
[debug] Infile: ./Judge Judy/Season 23/Judge Judy (1996) - S23E214 - Ice Cream Parlor Owner Not so Sweet .ts
|
[debug] Infile: ./Cops/Cops - S28E32 - No Helmet, No Ride (RawHD).ts
|
||||||
[debug] Outfile: ./Judge Judy/Season 23/Judge Judy (1996) - S23E214 - Ice Cream Parlor Owner Not so Sweet .mkv
|
[debug] Outfile: ./Cops/Cops - S28E32 - No Helmet, No Ride (RawHD).mkv
|
||||||
ffmpeg version 4.1.3-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
|
[info] ffmpeg version 4.1.3-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
|
||||||
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
|
[info] built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
|
||||||
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --ena
|
[info] configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzvbi --enable-libzimg
|
||||||
ble-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex
|
[info] libavutil 56. 22.100 / 56. 22.100
|
||||||
--enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzvbi --enable-libzimg
|
[info] libavcodec 58. 35.100 / 58. 35.100
|
||||||
libavutil 56. 22.100 / 56. 22.100
|
[info] libavformat 58. 20.100 / 58. 20.100
|
||||||
libavcodec 58. 35.100 / 58. 35.100
|
[info] libavdevice 58. 5.100 / 58. 5.100
|
||||||
libavformat 58. 20.100 / 58. 20.100
|
[info] libavfilter 7. 40.101 / 7. 40.101
|
||||||
libavdevice 58. 5.100 / 58. 5.100
|
[info] libswscale 5. 3.100 / 5. 3.100
|
||||||
libavfilter 7. 40.101 / 7. 40.101
|
[info] libswresample 3. 3.100 / 3. 3.100
|
||||||
libswscale 5. 3.100 / 5. 3.100
|
[info] libpostproc 55. 3.100 / 55. 3.100
|
||||||
libswresample 3. 3.100 / 3. 3.100
|
[info] Input #0, mpegts, from './Cops/Cops - S28E32 - No Helmet, No Ride (RawHD).ts':
|
||||||
libpostproc 55. 3.100 / 55. 3.100
|
[info] Duration: 00:20:20.87, start: 0.587722, bitrate: 14699 kb/s
|
||||||
Input #0, mpegts, from './Judge Judy/Season 23/Judge Judy (1996) - S23E214 - Ice Cream Parlor Owner Not so Sweet .ts':
|
[info] Program 1
|
||||||
Duration: 00:17:33.44, start: 1.401556, bitrate: 16470 kb/s
|
[info] Stream #0:0[0x101b]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], 14100 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
|
||||||
Program 1
|
[info] Stream #0:1[0x1033](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
|
||||||
Metadata:
|
[info] Input #1, lavfi, from 'movie='./Cops/Cops - S28E32 - No Helmet, No Ride (RawHD).ts'[out+subcc]':
|
||||||
service_name : Service01
|
[info] Duration: N/A, start: 0.587722, bitrate: N/A
|
||||||
service_provider: FFmpeg
|
[info] Stream #1:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
|
||||||
Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
|
[info] Stream #1:1: Subtitle: eia_608
|
||||||
Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s
|
[info] Stream mapping:
|
||||||
Stream #0:2[0x102](spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 192 kb/s
|
[info] Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
|
||||||
Input #1, lavfi, from 'movie='./Judge Judy/Season 23/Judge Judy (1996) - S23E214 - Ice Cream Parlor Owner Not so Sweet .ts'[out+subcc]':
|
[info] Stream #0:1 -> #0:1 (copy)
|
||||||
Duration: N/A, start: 1.500100, bitrate: N/A
|
[info] Stream #1:1 -> #0:2 (eia_608 (cc_dec) -> subrip (srt))
|
||||||
Stream #1:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
|
[info] Press [q] to stop, [?] for help
|
||||||
Stream #1:1: Subtitle: eia_608
|
[libx264 @ 0x70bd980] [info] using SAR=1/1
|
||||||
Stream mapping:
|
[libx264 @ 0x70bd980] [info] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
|
||||||
Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
|
[libx264 @ 0x70bd980] [info] profile Progressive High, level 4.0, 4:2:0, 8-bit
|
||||||
Stream #0:1 -> #0:1 (copy)
|
[libx264 @ 0x70bd980] [info] 264 - core 157 r2969 d4099dd - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
|
||||||
Stream #0:2 -> #0:2 (copy)
|
[info] Output #0, matroska, to './Cops/Cops - S28E32 - No Helmet, No Ride (RawHD).mkv':
|
||||||
Stream #1:1 -> #0:3 (eia_608 (cc_dec) -> subrip (srt))
|
[info] Metadata:
|
||||||
Press [q] to stop, [?] for help
|
[info] encoder : Lavf58.20.100
|
||||||
[libx264 @ 0x5536c00] using SAR=1/1
|
[info] Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 1k tbn, 29.97 tbc
|
||||||
[libx264 @ 0x5536c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
|
[info] Metadata:
|
||||||
[libx264 @ 0x5536c00] profile Progressive High, level 4.0, 4:2:0, 8-bit
|
[info] encoder : Lavc58.35.100 libx264
|
||||||
[libx264 @ 0x5536c00] 264 - core 157 r2969 d4099dd - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
|
[info] Side data:
|
||||||
Output #0, matroska, to './Judge Judy/Season 23/Judge Judy (1996) - S23E214 - Ice Cream Parlor Owner Not so Sweet .mkv':
|
[info] cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
|
||||||
Metadata:
|
[info] Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
|
||||||
encoder : Lavf58.20.100
|
[info] Stream #0:2(eng): Subtitle: subrip (srt)
|
||||||
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 1k tbn, 29.97 tbc
|
[info] Metadata:
|
||||||
Metadata:
|
[info] encoder : Lavc58.35.100 srt
|
||||||
encoder : Lavc58.35.100 libx264
|
...
|
||||||
Side data:
|
|
||||||
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
|
|
||||||
Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 384 kb/s Stream #0:2(spa): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s Stream #0:3(eng): Subtitle: subrip (srt)
|
|
||||||
Metadata:
|
|
||||||
encoder : Lavc58.35.100 srt
|
|
||||||
[Parsed_movie_0 @ 0x53d3a40] EOF timestamp not reliable2.12 bitrate=4460.1kbits/s speed=0.724x
|
|
||||||
frame=31567 fps= 22 q=-1.0 Lsize= 575764kB time=00:17:33.33 bitrate=4477.8kbits/s speed=0.723x
|
|
||||||
video:500855kB audio:74061kB subtitle:90kB other streams:0kB global headers:0kB muxing overhead: 0.131831%
|
|
||||||
[libx264 @ 0x5536c00] frame I:397 Avg QP:18.31 size:131260
|
|
||||||
[libx264 @ 0x5536c00] frame P:8915 Avg QP:22.13 size: 33958
|
|
||||||
[libx264 @ 0x5536c00] frame B:22255 Avg QP:25.09 size: 7101
|
|
||||||
[libx264 @ 0x5536c00] consecutive B-frames: 1.8% 2.6% 30.1% 65.4%
|
|
||||||
[libx264 @ 0x5536c00] mb I I16..4: 7.3% 89.3% 3.4%
|
|
||||||
[libx264 @ 0x5536c00] mb P I16..4: 1.6% 5.2% 0.2% P16..4: 49.9% 11.6% 8.2% 0.0% 0.0% skip:23.3%
|
|
||||||
[libx264 @ 0x5536c00] mb B I16..4: 0.1% 0.2% 0.0% B16..8: 35.5% 1.1% 0.2% direct: 1.1% skip:61.8% L0:41.5% L1:54.1% BI: 4.3%
|
|
||||||
[libx264 @ 0x5536c00] 8x8 transform intra:79.6% inter:90.9%
|
|
||||||
[libx264 @ 0x5536c00] coded y,uvDC,uvAC intra: 61.9% 65.4% 17.5% inter: 11.5% 17.0% 0.1%
|
|
||||||
[libx264 @ 0x5536c00] i16 v,h,dc,p: 24% 32% 12% 33%
|
|
||||||
[libx264 @ 0x5536c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 20% 30% 3% 3% 4% 4% 4% 4%
|
|
||||||
[libx264 @ 0x5536c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 44% 9% 4% 7% 6% 6% 4% 5%
|
|
||||||
[libx264 @ 0x5536c00] i8c dc,h,v,p: 43% 26% 24% 7%
|
|
||||||
[libx264 @ 0x5536c00] Weighted P-Frames: Y:0.5% UV:0.2%
|
|
||||||
[libx264 @ 0x5536c00] ref P L0: 58.2% 11.4% 23.3% 7.1% 0.0%
|
|
||||||
[libx264 @ 0x5536c00] ref B L0: 86.5% 11.3% 2.3%
|
|
||||||
[libx264 @ 0x5536c00] ref B L1: 96.2% 3.8%
|
|
||||||
[libx264 @ 0x5536c00] kb/s:3894.93
|
|
||||||
[info] successful conversion
|
[info] successful conversion
|
||||||
[debug] deleting original file
|
[debug] deleting original file
|
||||||
removed './Judge Judy/Season 23/Judge Judy (1996) - S23E214 - Ice Cream Parlor Owner Not so Sweet .ts'
|
removed 'working on ./Cops/Cops - S28E32 - No Helmet, No Ride (RawHD).ts'
|
||||||
```
|
```
|
||||||
|
|
25
ts-to-mkv.sh
25
ts-to-mkv.sh
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
## functions ##
|
## functions ##
|
||||||
vercomp () {
|
vercomp () {
|
||||||
if [[ $1 == $2 ]]
|
if [[ "$1" == "$2" ]]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -42,6 +42,7 @@ ffmpegcheck(){
|
||||||
## Env ##
|
## Env ##
|
||||||
SAVEIFS=$IFS
|
SAVEIFS=$IFS
|
||||||
IFS=$(echo -en "\n\b")
|
IFS=$(echo -en "\n\b")
|
||||||
|
loglevel="level+info"
|
||||||
FFMPEG="/data/sourcecode/ffmpeg/ffmpeg-4.1.3-amd64-static/ffmpeg"
|
FFMPEG="/data/sourcecode/ffmpeg/ffmpeg-4.1.3-amd64-static/ffmpeg"
|
||||||
if [[ ! -f "$FFMPEG" ]]; then
|
if [[ ! -f "$FFMPEG" ]]; then
|
||||||
FFMPEG=$(/usr/bin/env which ffmpeg)
|
FFMPEG=$(/usr/bin/env which ffmpeg)
|
||||||
|
@ -59,7 +60,7 @@ version="2"
|
||||||
|
|
||||||
## Start ##
|
## Start ##
|
||||||
echo "[info] $0 -- v$version"
|
echo "[info] $0 -- v$version"
|
||||||
while getopts d:hk:p: OPT; do
|
while getopts d:p:fnhkq OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
d)
|
d)
|
||||||
if [[ -e "$OPTARG" ]]; then
|
if [[ -e "$OPTARG" ]]; then
|
||||||
|
@ -68,27 +69,39 @@ while getopts d:hk:p: OPT; do
|
||||||
else
|
else
|
||||||
echo "[debug] no custom daemon; using $FFMPEG"
|
echo "[debug] no custom daemon; using $FFMPEG"
|
||||||
fi ;;
|
fi ;;
|
||||||
|
f)
|
||||||
|
force="-y"
|
||||||
|
echo "[debug] overwriting existing files " ;;
|
||||||
h)
|
h)
|
||||||
echo "[help] -d, path to custom ffmpeg (default: $FFMPEG)"
|
echo "[help] -d, path to custom ffmpeg (default: $FFMPEG)"
|
||||||
|
echo "[help] -f, force overwriting existing files"
|
||||||
|
echo "[help} -n, never overwrite existing files"
|
||||||
echo "[help] -k, keep the original ts file"
|
echo "[help] -k, keep the original ts file"
|
||||||
|
echo "[help] -q, disable output from ffmpeg (default: info)"
|
||||||
echo "[help] -p, custom path to scan recursively (default: $WORKPATH)"
|
echo "[help] -p, custom path to scan recursively (default: $WORKPATH)"
|
||||||
exit 0;;
|
exit 0;;
|
||||||
k)
|
k)
|
||||||
echo "[debug] keeping the original file"
|
echo "[debug] keeping the original file"
|
||||||
keepsource="1";;
|
keepsource="1";;
|
||||||
|
n)
|
||||||
|
force="-n"
|
||||||
|
echo "[debug] not overwriting existing files " ;;
|
||||||
p)
|
p)
|
||||||
if [[ -e "$OPTARG" ]]; then
|
if [[ -d "$OPTARG" ]]; then
|
||||||
WORKPATH="$OPTARG"
|
WORKPATH="$OPTARG"
|
||||||
echo "[debug] custom pathing: $OPTARG"
|
echo "[debug] custom pathing: $OPTARG"
|
||||||
else
|
else
|
||||||
echo "[debug] no custom pathing; using $WORKPATH"
|
echo "[debug] no custom pathing; using $WORKPATH"
|
||||||
fi ;;
|
fi ;;
|
||||||
|
q)
|
||||||
|
loglevel="quiet"
|
||||||
|
echo "[debug] disabling ffmpeg output" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
shift $(($OPTIND-1))
|
shift $((OPTIND-1))
|
||||||
echo "[info] finding files"
|
echo "[info] finding files"
|
||||||
filelist="$(find $WORKPATH -name "*.ts")"
|
filelist="$(find "$WORKPATH" -name "*.ts")"
|
||||||
if [[ "$filelist" ]]; then
|
if [[ "$filelist" ]]; then
|
||||||
for i in $filelist;
|
for i in $filelist;
|
||||||
do
|
do
|
||||||
|
@ -107,6 +120,8 @@ if [[ "$filelist" ]]; then
|
||||||
-codec:a copy \
|
-codec:a copy \
|
||||||
-codec:s srt \
|
-codec:s srt \
|
||||||
-metadata:s:s:0 language=eng \
|
-metadata:s:s:0 language=eng \
|
||||||
|
$force \
|
||||||
|
-loglevel "$loglevel" \
|
||||||
"${OUTFILE}"
|
"${OUTFILE}"
|
||||||
|
|
||||||
exitcode="$?"
|
exitcode="$?"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue