How to extract the Photo/Video component of a MVIMG?

前端 未结 4 805
遥遥无期
遥遥无期 2021-02-13 23:17

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

4条回答
  •  [愿得一人]
    2021-02-14 00:07

    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
    

提交回复
热议问题