The Google Pixel 2 and probably other phones since have the capability to cover "Motion Photos". These are saved as MVIMG and comparatively big.
I’m looking for a way to remove/extract the video.
So far I found a promising exif tag
$ exiftool -xmp:all MVIMG_123.jpg
XMP Toolkit : Adobe XMP Core 5.1.0-jc003
Micro Video : 1
Micro Video Version : 1
Micro Video Offset : 4032524
I thought the video might be present at the specified offset, but this doesn’t work:
$ dd if=MVIMG_123.jpg of=video.mp4 bs=4032524 skip=1
$ file video.mp4
video.mp4: data
Are there any resources that document the embedding? Are there even any tools to remove/extract the video?
Press ALT+PRINT SCREEN. Play the video and pause it at the point you want to take a still from it. Press PRINT SCREEN or ALT+PRINT SCREEN, depending on whether the video is playing full screen or in an active window.
Hit 'view motion picture', scroll left/ right to find the frame you want to keep, hit the back button at the top left. The frame you selected will be the one currently on view. Select the 3 dots in the bottom right and select the option to remaster picture.
I did find https://github.com/cliveontoast/GoMoPho which scans for the mp4 header and then dumps the video.
We can do the same, scanning for ftypmp4
from the MP4 header (actual file starts 4 bytes earlier):
Thus to extract videos:
for i in MVIMG*.jpg; do \
ofs=$(grep -F --byte-offset --only-matching --text ftypmp4 "$i"); \
ofs=${ofs%:*}; \
[[ $ofs ]] && dd "if=$i" "of=${i%.jpg}.mp4" bs=$((ofs-4)) skip=1; \
done
And to remove videos:
for i in MVIMG*.jpg; do \
ofs=$(grep -F --byte-offset --only-matching --text ftypmp4 "$i"); \
ofs=${ofs%:*}; \
[[ $ofs ]] && truncate -s $((ofs-4)) "$i"; \
done
The EXIF tag is useful, but the offset is with the respect to the end of the file. The mp4 file is embedded at:
[file_size-micro_video_offset, file_size)
For example:
$ exiftool -xmp:all MVIMG_123.jpg
XMP Toolkit : Adobe XMP Core 5.1.0-jc003
Micro Video : 1
Micro Video Version : 1
Micro Video Offset : 2107172
Micro Video Presentation Timestamp Us: 966280
$ python -c 'import os; print os.path.getsize("MVIMG_123.jpg") - 2107172'
3322791
$ dd if=MVIMG_123.jpg of=video.mp4 bs=3322791 skip=1
$ file video.mp4
video.mp4: ISO Media, MP4 v2 [ISO 14496-14]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With