Hello,
I have a Pixel 6a and it is able to create "Motion Pictures". That are JPEGs with an movie in the metadata embedded. I'd like to extract the video. I tried different ways, but never got an video that VLC was able to play. Do you have an hint how to extract the Motion Picture (mp4-Video) from the file?
An example image is attached.
PXL_20230118_124418216.MP.jpg
If I extract the trailer data
exiftool -b -Trailer PXL_20230118_124418216.MP.jpg >test.mp4
I can see the file signature (66 74 79 70 69 73 6F 6D) for an MP4 at an offset of 0x423d. Since this signature is offset by 4 from the start of the file, if I delete everything before 0x423A, then I get a valid MP4.
Extracted file (https://www.dropbox.com/s/2yucy74pqon1ww5/test.mp4?dl=0)
@StarGeek: Nice!
Here is a command that will extract the video from all jpg images in a directory and store the videos with the same file name as the jpg but with extension .mp4:
exiftool -b -p "${trailer;s/.*(\0\0\0\x1cftypisom)/$1/s}" -ext jpg -w mp4 DIR
- Phil
Wow, thanks, that works. I would never have been able to figure that out myself. Would you be so kind as to explain the "-p" parameter to me, please?
-b
Output metadata in binary format. That's what I've tried.
-p "${trailer;s/.*(\0\0\0\x1cftypisom)/$1/s}"
What the hell are you doing here? I found this link but it doesn't help me:
https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature
-ext jpg
Process files with the specified extension
-w mp4
New filename extension
DIR
Directory or filename
Quote from: supertobi on January 20, 2023, 03:36:33 AM-p "${trailer;s/.*(\0\0\0\x1cftypisom)/$1/s}"
What the hell are you doing here? I found this link but it doesn't help me:
https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature
This uses the advanced formatting feature as you surmised to remove everything before the MP4 header. The "\0\0\0\x1cftypisom" string is the binary MP4 header. ".*" is everything before that. The s/// is the Perl substitution operator (ie. search and replace), and it replaces everything up to and including the header with just the header ("$1" is everything inside the brackets in the search pattern of the substitution operator). Read about "regular expressions" if you want to know more about the syntax.
- Phil
Thank you for your explanation.
I wondered why macOS Sonoma 14.6.1 QuickLook displays only a thumbnail from that command's output PXL_20230118_124418216.MP.mp4 while QuickTime Player can play it OK.
exiftool -b -p '${trailer;s/.*(\0\0\0\x1cftypisom)/$1/s}' -ext jpg -w mp4 PXL_20230118_124418216.MP.jpg
1 output files created
ls
PXL_20230118_124418216.MP.jpg PXL_20230118_124418216.MP.mp4
I could fix that by losslessly selecting just the correct stream:
ffmpeg -i PXL_20230118_124418216.MP.mp4 -map 0:0 -c copy output.mp4
ffprobe7 PXL_20230118_124418216.MP.mp4
ffprobe version 7.0.1 Copyright (c) 2007-2024 the FFmpeg developers
built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
configuration: --cc=/usr/bin/clang --datadir=/opt/local/libexec/ffmpeg7/share/data --docdir=/opt/local/libexec/ffmpeg7/share/doc --progs-suffix=7 --prefix=/opt/local/libexec/ffmpeg7 --enable-audiotoolbox --disable-indev=jack --disable-libjack --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libplacebo --disable-libvmaf --disable-libwebp --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-metal --enable-opencl --disable-outdev=xv --enable-sdl2 --disable-securetransport --enable-videotoolbox --disable-xlib --enable-avfilter --enable-fontconfig --enable-gnutls --enable-lcms2 --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libfribidi --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libzvbi --enable-lzma --enable-pthreads --enable-shared --enable-swscale --enable-zlib --enable-libaom --enable-libsvtav1 --arch=x86_64 --enable-x86asm --enable-gpl --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxvid --enable-postproc
libavutil 59. 8.100 / 59. 8.100
libavcodec 61. 3.100 / 61. 3.100
libavformat 61. 1.100 / 61. 1.100
libavdevice 61. 1.100 / 61. 1.100
libavfilter 10. 1.100 / 10. 1.100
libswscale 8. 1.100 / 8. 1.100
libswresample 5. 1.100 / 5. 1.100
libpostproc 58. 1.100 / 58. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'PXL_20230118_124418216.MP.mp4':
Metadata:
major_brand : isom
minor_version : 131072
compatible_brands: isomiso2mp41
creation_time : 2023-01-18T12:44:18.000000Z
Duration: 00:00:02.73, start: 0.000000, bitrate: 12705 kb/s
Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1440x1080, 12461 kb/s, SAR 1:1 DAR 4:3, 26.38 fps, 90k tbr, 90k tbn (default)
Metadata:
creation_time : 2023-01-18T12:44:18.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1[0x2](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 2048x1536, SAR 1:1 DAR 4:3, 90k tbn (default)
Metadata:
creation_time : 2023-01-18T12:44:18.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:2[0x3](eng): Data: none (mett / 0x7474656D), 94 kb/s (default)
Metadata:
creation_time : 2023-01-18T12:44:18.000000Z
handler_name : MetaHandle
Stream #0:3[0x4](eng): Data: none (mett / 0x7474656D), 0 kb/s (default)
Metadata:
creation_time : 2023-01-18T12:44:18.000000Z
handler_name : MetaHandle
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 0 for input stream 3
ffprobe7 output.mp4
ffprobe version 7.0.1 Copyright (c) 2007-2024 the FFmpeg developers
built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
configuration: --cc=/usr/bin/clang --datadir=/opt/local/libexec/ffmpeg7/share/data --docdir=/opt/local/libexec/ffmpeg7/share/doc --progs-suffix=7 --prefix=/opt/local/libexec/ffmpeg7 --enable-audiotoolbox --disable-indev=jack --disable-libjack --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libplacebo --disable-libvmaf --disable-libwebp --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-metal --enable-opencl --disable-outdev=xv --enable-sdl2 --disable-securetransport --enable-videotoolbox --disable-xlib --enable-avfilter --enable-fontconfig --enable-gnutls --enable-lcms2 --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libfribidi --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libzvbi --enable-lzma --enable-pthreads --enable-shared --enable-swscale --enable-zlib --enable-libaom --enable-libsvtav1 --arch=x86_64 --enable-x86asm --enable-gpl --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxvid --enable-postproc
libavutil 59. 8.100 / 59. 8.100
libavcodec 61. 3.100 / 61. 3.100
libavformat 61. 1.100 / 61. 1.100
libavdevice 61. 1.100 / 61. 1.100
libavfilter 10. 1.100 / 10. 1.100
libswscale 8. 1.100 / 8. 1.100
libswresample 5. 1.100 / 5. 1.100
libpostproc 58. 1.100 / 58. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf58.76.100
Duration: 00:00:02.77, start: 0.000000, bitrate: 12295 kb/s
Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1440x1080, 12290 kb/s, SAR 1:1 DAR 4:3, 26.02 fps, 29.42 tbr, 90k tbn (default)
Metadata:
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Side data:
displaymatrix: rotation of -90.00 degrees
- Matti
First time user and first time command promp user here. Thank you for your tool!
I'm seeking to extract .mp4 movie files from "motion" .href files taken with my Samsung running ana android system in 2022. I seem to have sucessfully installed exif on my laptop and extracted multiple the .mp4 files using the prompt you provided above, but the resulting .mp4 files will not play in Windows Media Player (or its legacy version) or using Microsoft Photos, although th eimbeded movies are viewable on with Photos if I click "motion" on the original files.
Any idea why I might be getting errors saying the file type or codec used to compress the extracted .mp4 file might not be supported, although the original combined still image and movie were viewable? Suggestions?
Could you upload a sample somewhere so we can see what is happening?
- Phil
Which command are you using? You should be using the one from Phil's post (https://exiftool.org/forum/index.php?msg=77523). Additionally, you should be using CMD and not PowerShell.
Quote from: Phil Harvey on June 03, 2025, 12:33:51 PMCould you upload a sample somewhere so we can see what is happening?
- Phil
Thanks, Phil. Here are five images with descriptors:
1) Opening the original file in Microsoft Photos (which shows a still jpg, but plays the imbedded .mp4 when I press "motion";
1 - photos original file.jpg
2) The prompt I used to extract the movie file;
2 - promt.jpg
3) Attempt to open the extracted file in Microsoft Photos;
3 - photos extracted file.jpg
4) Attempt to open the extracted file in current Windows Media Player; and
4 - WMP extracted file.jpg
5) Attempt to open the extracted file in the legacy Windows Media Player.
5 - WMP legacy extracted file.jpg
Quote from: jleon on June 11, 2025, 03:10:21 PMQuote from: Phil Harvey on June 03, 2025, 12:33:51 PMCould you upload a sample somewhere so we can see what is happening?
- Phil
Thanks, Phil. Here are five images with descriptors:
None of these are sample images, they're screen captures.
Phil needs to see one of the actual images, such as your image
20220102_144718.jpg, to figure out the problem.
Here is a sample combined "motion" jpg and mp4 file. The mp4 plays fine in the combined file, but once extracted, the players aren't recognizing the mp4.
Oh, this should have been a completely separate post. You aren't using the Pixel camera that this thread is about (you did mention you were using android).
Exiftool can already extract MP4s from a Samsung file. Your command would be
exiftool -b -EmbeddedVideoFile -ext jpg -w mp4 Y:\!temp\x\y\20220418_155834.jpg
vlc-2025-06-11_14.13.48.jpg
Thank you for your patience. This was temendously helpful. I didn't realize the command would be different for a different android. I needed to pull the imbeded files from several hundred motion images, so I guessed the syntax from the combination of the two commands above and used this, which worked:
exiftool -b -EmbeddedVideoFile -ext jpg -w mp4 DIR
(where DIR was the location of the folder, rather than a particular file)
Please let me know if you'd like me to post this separately under a separate thread so those using a samsung phone can find it more easily. Thanks again for all your help. I really appreciate it!