Skip to content

Instantly share code, notes, and snippets.

@goofwear
Forked from kmark/extractMotionPhotos.sh
Created May 7, 2017 21:30
Show Gist options
  • Save goofwear/bdf6b71ffb8c8cae64f333f25f2e0c3d to your computer and use it in GitHub Desktop.
Save goofwear/bdf6b71ffb8c8cae64f333f25f2e0c3d to your computer and use it in GitHub Desktop.
Samsung Galaxy Motion Photo extraction tool
#!/bin/bash
# Copyright 2017 Kevin Mark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------
# Extracts the MP4 video component of Motion Photos introduced on the
# Samsung Galaxy S7. Uses exiftool to get the job done. Ignores files
# that do not contain motion photo data. Unfortunately, exiftool does
# not yet support removing this embedded data from images.
# See http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Samsung.html
#
# Example usage: extractMultiPhotos.sh /my/photos/*.jpg
hash exiftool 2>/dev/null
if [ $? -ne 0 ]; then
echo "exiftool is not available"
exit 1
fi
for file in "${@}"; do
video_type=$(exiftool -p '$EmbeddedVideoType' -EmbeddedVideoType "${file}" 2>/dev/null)
if [ "${video_type}" != "MotionPhoto_Data" ]; then
continue
fi
echo "Extracting motion photo from ${file}..."
exiftool -b -EmbeddedVideoFile "${file}" > "${file%.*}_MotionPhoto.mp4"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment