Converting bat to bash script

0

Please help me with coversion this script from here to bash: https://stackoverflow.com/a/38291960/11786146

This part of the code seems to be reconciled in me, but I'm not sure that it’s correct:

#  path to ffmpeg
export  ffmpeg='/home/user/bin'
#  source movies from
export  movieSource='/mnt/dev1/radio/Masha'
#  tmp dir
export  tmpDir='/mnt/dev1/radio/Masha'


#  setup positon, color, background, font for the text overlays
#  filterComplex, quotes have to be escaped! -> \"
#  BITC - Burned In Time Code
export  filterComplexTimecode='drawtext=fontfile='/usr/share/fonts/truetype/freefont/FreeSerif.ttf': timecode='10\:00\:00\:00': timecode_rate=24: x=(w-tw)/2: y=h-(1*lh)-3: fontsize=20: fontcolor=white@0.4: box=1: boxcolor=0x00000000@0.4: boxborderw=4'
#  Date
export  filterComplexDate='drawtext=fontfile='/usr/share/fonts/truetype/freefont/FreeSerif.ttf': text='%{localtime\:%X}': x=(w-tw-3): y=h-(1*lh)-3: fontsize=20: fontcolor=white@0.4: box=1: boxcolor=0x00000000@0.4: boxborderw=4'
#  Shotname
export  filterComplexShotname='drawtext=fontfile='/usr/share/fonts/truetype/freefont/FreeSerif.ttf': x=0: y=h-(1*lh)+1: fontsize=20: fontcolor=white@0.4: box=1: boxcolor=0x00000000@0.4: boxborderw=4:'

#  create a list of all files
find "$movieSource" -name "*.mp4" -type f | sort -R | while read j; do echo "file '$j'" >> $tmpDir/filelist.txt; done

echo filename, durationInSeconds > $tmpDir/fileNameDuration.txt
for file in $movieSource/*.mp4; do
  #  Reset current duration to 0 (zero) for each loop
  export  curDuration=0
  #  get the filename without file extenion
  export  fileName=${file##*/}
  #  get the duration of a single clip
  #  and write it to a tmp textfile
  $ffmpeg/ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file" > $tmpDir/fileTempDuration.txt
  #  read the textfile again into a variable
 read -p  < $tmpDir/fileTempDuration.txt last curDuration

  #  write the filename and the duration to a new list of all files
echo $fileName,$curDuration >> $tmpDir/fileNameDuration.txt ;done

#  concate a filter complex string for ffmpeg with all clipnames as textlayer with a inpoint and outpoint
export  filterComplexShotnameCombined=
#  floating numbers are not supported by batch, so we need to work-around that
source  :IntAsFP b=0.000000
for i in $tmpDir/fileNameDuration.txt; do
  source  :IntAsFP a=$j
  source  :IntToFP inPoint=$b 6
  export  c=$(expr a + b)
  export   b=c
  source  :IntToFP outPoint=$c 6
  #  just to check whats going on...
  echo name: $i   duration: $j   inPoint: $inPoint   outPoint: $outPoint
  export  filterComplexShotnameCombined='$filterComplexShotnameCombined, $filterComplexShotname text=$i: enable=between(t\,$inPoint\,$outPoint^^^)';done
bash
ffmpeg
concat
asked on Stack Overflow Jul 15, 2019 by dezxela

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0