-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting4_dvd.py
96 lines (76 loc) · 3.13 KB
/
testing4_dvd.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python
import argparse
import subprocess
import sys
import os
from ififuncs import hashlib_md5
from glob import glob
from sys import platform as _platform
if [ "${#}" = 0 ] ; then echo " drag and drop a file" ; exit
else
sourcepath="$(dirname "$1")"
filename="$(basename "$1")"
filenoext="${filename%.*}"
echo "Would you like to burn straight to DVD Y or N?"
read "burn";
echo "BITC? Enter Y or N"
read "bitc";
if [[ "${bitc}" == "Y" || "${bitc}" == "y" ]] ; then
size=($(ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 "$1"))
wsize=($(ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 "$1"))
ycor=($(bc <<< $size/1.20))
xcor=($(bc <<< $wsize/2))
font=($(bc <<< $size/12))
textoptions=("fontsize=$font:x=$xcor-text_w/2:y=$ycor")
framerate=($(ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 "$1"))
#ffprobe -v error -select_streams v:0 -show_entries format_tags=timecode:stream_tags=timecode -of default=noprint_wrappers=1:nokey=1 B.mxf will print either/or. may be times where none exist.
tctest=($(ffprobe -v error -select_streams v:0 -show_entries format_tags=timecode:stream_tags=timecode -of default=noprint_wrappers=1:nokey=1 "$1"))
tctest2=($(ffprobe -v error -select_streams v:0 -show_entries stream_tags=timecode -of default=noprint_wrappers=1:nokey=1 "$1"))
if [[ "${tctest}" == "" ]] ; then
echo " no timecode present. manually create one with another tool. Sorry. I'll update this feature later. Your file is probably wonky, or maybe it's my script. Who knows?" ;exit
elif [[ "${tctest2}" == "" ]] ; then
IFS=: read -a timecode < <(ffprobe -v error -show_entries format_tags=timecode -of default=noprint_wrappers=1:nokey=1 "$1")
else
IFS=: read -a timecode < <(ffprobe -v error -show_entries stream_tags=timecode -of default=noprint_wrappers=1:nokey=1 "$1")
fi
printf -v timecode "'%s\:%s\:%s\:%s'" "${timecode[@]}"
echo "$timecode"
drawtext_options=(
fontfile="/Library/Fonts/Arial Black.ttf"
fontcolor=white
timecode="$timecode"
rate="$framerate"
boxcolor=0x000000AA
box=1
$textoptions
#x=360-text_w/2
#y=480
)
drawtext_options=$(IFS=:; echo "${drawtext_options[*]}")
export VIDEO_FORMAT=PAL
ffmpeg -i "$1" -vf drawtext="$drawtext_options" -target pal-dvd "$1"_dvd.mpg
mkdir "$sourcepath/$filenoext"
mkdir "$sourcepath/$filenoext/dvd"
dvdauthor -o "$sourcepath/$filenoext/dvd" -t "$1"_dvd.mpg
dvdauthor -o "$sourcepath/$filenoext/dvd" -T
mkisofs -dvd-video -V IFIARCHIVE -o "$1".iso "$sourcepath/$filenoext/dvd"
if [[ "${burn}" == "Y" || "${burn}" == "y" ]] ; then
hdiutil burn "$1".iso
else
exit
fi
else
export VIDEO_FORMAT=PAL
ffmpeg -i "$1" -target pal-dvd "$1"_dvd.mpg
mkdir "$sourcepath/$filenoext"
mkdir "$sourcepath/$filenoext/dvd"
dvdauthor -o "$sourcepath/$filenoext/dvd" -t "$1"_dvd.mpg
dvdauthor -o "$sourcepath/$filenoext/dvd" -T
mkisofs -dvd-video -V IFIARCHIVE -o "$1".iso "$sourcepath/$filenoext/dvd"
if [[ "${burn}" == "Y" || "${burn}" == "y" ]] ; then
hdiutil burn "$1".iso
else
exit
fi
fi
fi