Advertisement
Ri0n

1080p_to_720p.sh

Oct 27th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #!/bin/bash
  2. FILENAME_IN="$1"
  3. FILENAME_OUT="output/$1"
  4. while IFS='' read -r line || [[ -n "$line" ]]; do
  5. LINE=$line
  6. NEWLINE=''
  7.  
  8. if [[ $line == *"custom_viewport_width"* ]]
  9. then
  10. CUSTOM_VIEWPORT_WIDTH=$(echo "$line" | sed 's/custom_viewport_width = "\(.*\)"/\1/')
  11. NEWLINE='custom_viewport_width = "'$((CUSTOM_VIEWPORT_WIDTH * 2/3))'"';
  12. fi
  13.  
  14. if [[ $line == *"custom_viewport_height"* ]]
  15. then
  16. CUSTOM_VIEWPORT_HEIGHT=$(echo "$line" | sed 's/custom_viewport_height = "\(.*\)"/\1/')
  17. NEWLINE='custom_viewport_height = "'$((CUSTOM_VIEWPORT_HEIGHT * 2/3))'"';
  18. fi
  19.  
  20. if [[ $line == *"custom_viewport_x"* ]]
  21. then
  22. CUSTOM_VIEWPORT_X=$(echo "$line" | sed 's/custom_viewport_x = "\(.*\)"/\1/')
  23. NEWLINE='custom_viewport_x = "'$((CUSTOM_VIEWPORT_X * 2/3))'"';
  24. fi
  25.  
  26. if [[ $line == *"custom_viewport_y"* ]]
  27. then
  28. CUSTOM_VIEWPORT_Y=$(echo "$line" | sed 's/custom_viewport_y = "\(.*\)"/\1/')
  29. NEWLINE='custom_viewport_y = "'$((CUSTOM_VIEWPORT_Y * 2/3))'"'
  30. fi
  31.  
  32. if [[ $NEWLINE == "" ]]
  33. then
  34. NEWLINE=$LINE
  35. fi
  36. echo "$NEWLINE" >> $FILENAME_OUT
  37. done < "$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement