Thursday, June 29, 2023
RTLBS.net
Welcome new domain name
RTLBS.net
Real Time Location Based Services . net
Wednesday, September 7, 2022
ffmpeg concat
I’m not a huge Video guy. I mean I have a lot of videos but I’m not really a
“Video expert” If that makes any sense. I’m an expert “Watching” videos :)
Although I do know a thing or two about it. “How to get to watch them” I use
ffmpeg a lot because I like to do stuff from the command line.
ffmpeg fits the bill https://ffmpeg.org/
I use it for converting / combining / etcetra….
Small script below that I use for combining videos.
timc@sc2:~$ cat concat.sh ECHO="/usr/bin/echo" FFMPEG="/usr/bin/ffmpeg" $ECHO " =========================================================" $FFMPEG -f concat -safe 0 -i ./concat.txt -c copy output.mp4 $ECHO "=========================================================" exit timc@sc2:~$
Where concat.txt is as follows. These are the two files I want to combine
timc@sc2:~$ cat concat.txt #file './Moby.Dick.Part.1.1998.480p.AMZN.WEB-DL.DDP2.0.H.264-playWEB.mkv' #file './Moby.Dick.Part.2.1998.480p.AMZN.WEB-DL.DDP2.0.H.264-playWEB.mkv' file './Les.Vampires.1915.Part.1.mkv' file './Les.Vampires.1915.Part.2.mkv' timc@sc2:~$
and the file output.mp4 is a combination of the two files above. It works it’s way
through the files giving me any issues it sees and if audio is off and by how much
as well as stream issues.
Really cool free program. These guys rock. I’m planning to donate to them at some
point, but haven’t yet. Highly recommend that program for working with video from
the command line
Wednesday, May 4, 2022
Counting Movies
How many movies do I have?
What years are they from?
Resolution?
Type of encoding?
HEHEHE.
#!/bin/bash
ls -lR /nas/a/movies/ | sort +8 | awk ‘{print $9}’ | grep -v “/” | grep -v .srt > /tmp/movies.list
for YEAR in {1910..2021}
do
COUNT=`grep $YEAR /tmp/movies.list | wc -l`
echo $YEAR “=” $COUNT
done
TEN=`grep 1080 /tmp/movies.list | wc -l`
SEV=`grep 720 /tmp/movies.list | wc -l`
TOT=`cat /tmp/movies.list | wc -l`
AVI=`cat /tmp/movies.list | grep “.avi” | wc -l`
MKV=`cat /tmp/movies.list | grep “.mkv” | wc -l`
MP4=`cat /tmp/movies.list | grep “.mp4” | wc -l`
MPG=`cat /tmp/movies.list | grep “.mpg” | wc -l`
M4V=`cat /tmp/movies.list | grep “.m4v” | wc -l`
echo “___________________________________”
echo “AVI = $AVI”
echo “MKV = $MKV”
echo “MP4 = $MP4”
echo “MPG = $MPG”
echo “M4V = $M4V”
echo “___________________________________”
echo “1080p = $TEN”
echo ” 720p = $SEV”
echo “TOTAL = $TOT”
echo “___________________________________”/usr/bin/du -ch /nas/a/movies; echo ==========;/usr/bin/du | sort -n | tail -3
Results
root@nas4:~/bin# ./movie.year.sh
1910 = 0
1911 = 2
1912 = 0
1913 = 0
1914 = 1
1915 = 5
1916 = 6
1917 = 3
1918 = 2
1919 = 4
1920 = 7
1921 = 3
1922 = 6
1923 = 4
1924 = 6
1925 = 5
1926 = 6
1927 = 7
1928 = 7
1929 = 10
1930 = 15
1931 = 25
1932 = 28
1933 = 36
1934 = 31
1935 = 46
1936 = 40
1937 = 45
1938 = 32
1939 = 35
1940 = 48
1941 = 48
1942 = 55
1943 = 37
1944 = 34
1945 = 34
1946 = 38
1947 = 38
1948 = 51
1949 = 46
1950 = 63
1951 = 48
1952 = 57
1953 = 60
1954 = 65
1955 = 64
1956 = 63
1957 = 72
1958 = 65
1959 = 55
1960 = 56
1961 = 61
1962 = 65
1963 = 63
1964 = 69
1965 = 85
1966 = 89
1967 = 97
1968 = 98
1969 = 122
1970 = 112
1971 = 131
1972 = 173
1973 = 163
1974 = 167
1975 = 142
1976 = 142
1977 = 166
1978 = 169
1979 = 182
1980 = 170
1981 = 154
1982 = 163
1983 = 159
1984 = 191
1985 = 200
1986 = 202
1987 = 223
1988 = 208
1989 = 224
1990 = 207
1991 = 225
1992 = 215
1993 = 209
1994 = 218
1995 = 219
1996 = 253
1997 = 235
1998 = 254
1999 = 275
2000 = 298
2001 = 311
2002 = 280
2003 = 302
2004 = 342
2005 = 372
2006 = 439
2007 = 445
2008 = 467
2009 = 539
2010 = 487
2011 = 580
2012 = 644
2013 = 670
2014 = 778
2015 = 878
2016 = 947
2017 = 1086
2018 = 1297
2019 = 1746
2020 = 2750
2021 = 2527
___________________________________
AVI = 1811
MKV = 8179
MP4 = 16458
MPG = 2
M4V = 215
___________________________________
1080p = 5653
720p = 4746
TOTAL = 27885
Sunday, February 6, 2022
Make sure a process is running?
I have a openvpn tunnel up normally for certain things and want to kill some processes
if the tunnel goes down…
Check every minute
* * * * * /root/bin/tun.up.sh >> /var/log/tunnel.up.log
Which checks for the tunnel tun0 and kill some processes if it’s not.
IFCONFIG=/sbin/ifconfig GREP=/usr/bin/grep ECHO=/usr/bin/echo AWK=/usr/bin/awk PS=/usr/bin/ps PKILL=/usr/bin/pkill DATE=`/usr/bin/date +"%m.%d.%y.%H.%M"` PGREP=/usr/bin/pgrep TEST=`$IFCONFIG | $GREP tun | $AWK '{print $1}'` TOKILL=`$PS | $GREP ktorrent` if [ $TEST == "tun0:" ]; then $ECHO $TEST " UP " $DATE exit fi PROC=`$PGREP ktorrent` #$ECHO "Killing " $PROC $ECHO $TEST " DOWN " $DATE $PKILL -f ktorrent
Going to write a bit more code in the near future to bring the tunnel back up when it goes down
but that’s something for a different day.
Killing a process every day at certain time?
Gotta Schedule it with crontab -e (I use joe a wordstar equivalent)
alias cron='crontab -e'
=====================================================
root@ms2:/home/timc/bin# select-editor Select an editor. To change later, run 'select-editor'. 1. /usr/bin/joe 2. /usr/bin/jstar 3. /usr/bin/jpico 4. /usr/bin/jmacs 5. /bin/nano <---- easiest 6. /usr/bin/vim.basic 7. /usr/bin/rjoe 8. /usr/bin/vim.tiny 9. /bin/ed
=====================================================
4 0 * * * /home/timc/bin/kill.exp.sh &> /var/log/kill.log
===========================================================
#!/bin/bash #ps -elf | grep chia | grep exp > t TOUCH=/usr/bin/touch ECHO=/usr/bin/echo CHMOD=/usr/bin/chmod RM=/usr/bin/rm PS=/usr/bin/ps CAT=/usr/bin/cat GREP=/usr/bin/grep AWK=/usr/bin/awk DIR="/home/timc/bin" TMPFILE="temp.kill.file" KILLFILE="kill.up.exp.sh" $RM $DIR/$TMPFILE $RM $DIR/$KILLFILE $TOUCH $DIR/$TMPFILE $TOUCH $DIR/$KILLFILE $PS -elf | $GREP chia | $GREP exp | $AWK '{print $4}' >> $TMPFILE $ECHO "Start kill file to exec (kill.up.exp.sh)" $CAT $DIR/$TMPFILE | while read line do $ECHO kill -9 $line >> $DIR/$KILLFILE done $CHMOD 755 $DIR/$KILLFILE $DIR/$KILLFILE