Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ -z "$1" || "$1" == --help || "$1" == "-?" ]]; then
- echo "Usage: mvimg_play MVIMG_20190806_183324.jpg [other files]"
- echo "Plays Google's Motion Photo using mpv. Depends on exiftool, mktemp, bash and mpv."
- exit 0
- fi
- FOUND=0
- ARGS=()
- TORM=()
- TOKILL=()
- function cleanup() {
- for i in "${TORM[@]}"; do
- rm -f "$i"
- done
- for p in ${TOKILL[@]}; do
- wait $p
- done
- }
- trap "cleanup" EXIT
- for i in "$@"; do
- O=$(exiftool -t $i | grep -F 'Micro Video Offset' | cut -f 2-2)
- if [[ -z "$O" ]]; then
- # wrong file? Just appending to playlist as is
- ARGS+=($i)
- else
- FOUND=1
- S=$(find $i -printf '%s')
- T=`mktemp`
- ARGS+=("$T")
- dd if="$i" skip=$((S-O)) iflag=skip_bytes of="$T" 2> /dev/null &
- TOKILL+=($!)
- TORM+=("$T")
- fi
- done
- if [[ $FOUND == 0 ]]; then
- echo "EXIF tag wasn't detected in specified files. Maybe exiftool does not work?" >&2
- fi
- mpv "${ARGS[@]}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement