Advertisement
Guest User

Re-Filtering missed frames

a guest
Jun 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.24 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Still a work in progress!
  4.  
  5. #   Pseudocode:
  6.  
  7. #   Go to the folder NIH2018_Data/Video
  8. #   for s from 1 to 5:
  9. #           Enter the folder /Session + s + /
  10. #           for every file ending with the .MP4 extension
  11. #               Split the file name by "_" and store the first string in a var called name
  12. #               if name starts with "p0"
  13. #                   cd to /Users/$USER/Desktop/ExtractedVidFrames/Banneker/Session$s/$name
  14. #               else if name starts with "p1"
  15. #                   cd to /Users/$USER/Desktop/ExtractedVidFrames/JFK/Session$s/$name
  16. #               else
  17. #                   cd to /Users/$USER/Desktop/ExtractedVidFrames/Unknown/Session$s/$name
  18. #
  19. #               for every subfolder:
  20. #                   check if "training.txt" exists in the folder and store bool in var called "filtered"
  21. #                   if filtered is false:
  22. #                       run Filtering program to filter the newly created frames (thus saving space)
  23. #                       echo Re-filtered $fileName!
  24. #                   else
  25. #                       echo $fileName is already filtered
  26. #           echo Done with Session $s!
  27.  
  28. # Note: this script requires the following programs to be installed and aliased:
  29. # ffmpeg as ffmpeg
  30. # ffprobe as ffprobe
  31. # c# as dotnet
  32.  
  33.  
  34. pathToAllVids="/Volumes/My Passport/Dropbox (MIT)/NIH2018_Data/Video"
  35. pathToFilterPrgm="/Users/$USER/Desktop/Yaseen script files/Filtering/"
  36. pathToExtractedVids="/Volumes/My Passport/ExtractedVidFrames"
  37. continue=true
  38.  
  39. cd "$pathToAllVids"
  40.  
  41. #this is needed for the fileName for-loop
  42. shopt -s nullglob
  43.  
  44. for s in `seq 1 5`;
  45. do
  46.     if [ "$continue" = true ] ; then
  47.         cd "$pathToAllVids/Session$s/"
  48.    
  49.         for fileName in *.mp4 *.MP4; do
  50.             #split name and store into #splitName:
  51.             OIFS=$sFS
  52.             IFS='_' read -r -a splitName <<< "$fileName"
  53.             IFS=$OIFS
  54.  
  55.             #store first element into $name:
  56.             name=${splitName[0]}
  57.             frameDir=""
  58.  
  59.             if [[ $name == p0* ]]; then
  60.                 cd "$pathToExtractedVids"/Banneker/Session$s/$name/
  61.                 frameDir="$pathToExtractedVids/Banneker/Session$s/$name"
  62.             elif [[ $name == p1* ]]; then
  63.                 cd "$pathToExtractedVids"/JFK/Session$s/$name/
  64.                 frameDir="$pathToExtractedVids/JFK/Session$s/$name"
  65.             else
  66.                 cd "$pathToExtractedVids"/Unknown/Session$s/$name/
  67.                 frameDir="$pathToExtractedVids/Unknown/Session$s/$name"
  68.             fi
  69.  
  70.             #cd "$pathToFilterPrgm"
  71.  
  72.             for d in */ ; do
  73.                 if [ ! -f $frameDir/$d/library.txt ]; then
  74.                     echo "There doesn\'t seem to be a training file in $frameDir/$d, so I'm going to run FilteringTerminalArgs.dll on $frameDir/$d"
  75.                     #dotnet FilteringTerminalArgs.dll "$frameDir"/$d -no_output
  76.                     #echo Re-filtered $fileName!
  77.                 else
  78.                     echo .
  79.                     #echo "There is a training.txt file in $frameDir/$d so we're good."
  80.                     #$fileName is already filtered
  81.                 fi
  82.             done
  83.            
  84.         done
  85.  
  86.         echo Done with all the videos in Session $s!
  87.     fi
  88. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement