Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [[ -z "$1" || "$1" == --help || "$1" == "-?" ]]; then
  4. echo "Usage: mvimg_play MVIMG_20190806_183324.jpg [other files]"
  5. echo "Plays Google's Motion Photo using mpv. Depends on exiftool, mktemp, bash and mpv."
  6. exit 0
  7. fi
  8.  
  9. FOUND=0
  10. ARGS=()
  11.  
  12. TORM=()
  13. TOKILL=()
  14.  
  15. function cleanup() {
  16. for i in "${TORM[@]}"; do
  17. rm -f "$i"
  18. done
  19. for p in ${TOKILL[@]}; do
  20. wait $p
  21. done
  22. }
  23.  
  24. trap "cleanup" EXIT
  25.  
  26. for i in "$@"; do
  27. O=$(exiftool -t $i | grep -F 'Micro Video Offset' | cut -f 2-2)
  28. if [[ -z "$O" ]]; then
  29. # wrong file? Just appending to playlist as is
  30. ARGS+=($i)
  31. else
  32. FOUND=1
  33. S=$(find $i -printf '%s')
  34. T=`mktemp`
  35.  
  36. ARGS+=("$T")
  37. dd if="$i" skip=$((S-O)) iflag=skip_bytes of="$T" 2> /dev/null &
  38. TOKILL+=($!)
  39. TORM+=("$T")
  40. fi
  41. done
  42.  
  43. if [[ $FOUND == 0 ]]; then
  44. echo "EXIF tag wasn't detected in specified files. Maybe exiftool does not work?" >&2
  45. fi
  46.  
  47. mpv "${ARGS[@]}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement