Skip to content

Instantly share code, notes, and snippets.

@r41d
Last active July 30, 2025 15:10
Show Gist options
  • Save r41d/65491a2b05593d2d99f9bb47063f7d14 to your computer and use it in GitHub Desktop.
Save r41d/65491a2b05593d2d99f9bb47063f7d14 to your computer and use it in GitHub Desktop.
Scripts for handling Google Pixel MotionPicture files
#!/bin/bash
for mp in `ls -1 PXL_*.MP.jpg`; do
# Find out where in the file the video part starts
# old string: "\x00\x00\x00\x18\x66\x74\x79\x70\x6d\x70\x34\x32"
extractposition=$(grep --binary --byte-offset --only-matching --text -P "\x00\x00\x00\x1c\x66\x74\x79\x70\x69\x73\x6f\x6d" $mp | sed 's/^\([0-9]*\).*/\1/')
# Extract the video
dd if="$mp" skip=1 bs=$extractposition of="$(basename -s .jpg $mp).mp4"
done
#!/bin/bash
for mp in `ls -1 PXL_*.MP.jpg`; do
# Find out where in the file the video part starts
# old string: "\x00\x00\x00\x18\x66\x74\x79\x70\x6d\x70\x34\x32"
extractposition=$(grep --binary --byte-offset --only-matching --text -P "\x00\x00\x00\x1c\x66\x74\x79\x70\x69\x73\x6f\x6d" $mp | sed 's/^\([0-9]*\).*/\1/')
# Extract only the image
dd if="$mp" count=1 bs=$extractposition of="$(basename -s .MP.jpg $mp).clean.jpg"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment