How to delete a single metadata item from an MP4 file
Context and question
I recorded a video with my MotoG3 phone Android phone and the resulting video (perhaps due to shaking the phone) plays rotated, that is, vertically, which is not something that I want. The video was saved in an MP4 container.
Upon inspecting the file that was recorded, I saw (using both ffprobe and mediainfo) that it contains a flag that indicates that the video stream is rotated 90 degrees, which explains the rotation while playing the video. Here is the output from ffprobe:
$ ffprobe -hide_banner ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Since this video is from one rare event with my son, I would like to minimally change the video file, preferrably, only removing the rotation metadata and nothing else.
Unfortunately, using information from other answers didn't help. I tried using:
ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
But other metadata, like the date etc. are not present in the resulting file. This, in particular, makes organizer programs be confused while showing the files by date, among other things.
Is there any way of minimally changing the input data (possibly remuxing it) so as to keep it as close as possible to the original data? In particular, I don't want to reencode the file.
Any tools that are available under Linux are preferred.
Extra information
Since the full output of ffmpeg was asked, here it goes. This is a pure Debian testing userland.
As a side note, ffmpeg is complaining about mismatched libraries because it is compiled two times in Debian, once without potentially problematic codecs and another with some extra codecs. I'm using the version with extra codecs, but I suppose that that doesn't matter, since only the muxing is being used here.
Metadata before remuxing
$ ffprobe ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
The remuxing process
Note here that the audio metadata is not copied (which I expected, due to the -metadata:s:v:0 option) and ffmpeg tells me that it is copying the video metadata (without the rotation setting).
$ ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
ffmpeg version 3.0.2-4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Output #0, mp4, to 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 6.0
encoder : Lavf57.25.100
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 90k tbc (default)
Metadata:
encoder : MOTO
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
rotate : 0
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=29640 fps=403 q=-1.0 Lsize= 2121038kB time=00:17:01.91 bitrate=17003.0kbits/s speed=13.9x
video:2120800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.011211%
Metadata after remuxing
Note here that there is no video metadata in the output, only container-level metadata.
$ ffprobe vid_20160619_170845475_unrotated.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Duration: 00:17:01.95, start: 0.000000, bitrate: 17002 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
video ffmpeg video-conversion metadata
|
show 3 more comments
Context and question
I recorded a video with my MotoG3 phone Android phone and the resulting video (perhaps due to shaking the phone) plays rotated, that is, vertically, which is not something that I want. The video was saved in an MP4 container.
Upon inspecting the file that was recorded, I saw (using both ffprobe and mediainfo) that it contains a flag that indicates that the video stream is rotated 90 degrees, which explains the rotation while playing the video. Here is the output from ffprobe:
$ ffprobe -hide_banner ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Since this video is from one rare event with my son, I would like to minimally change the video file, preferrably, only removing the rotation metadata and nothing else.
Unfortunately, using information from other answers didn't help. I tried using:
ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
But other metadata, like the date etc. are not present in the resulting file. This, in particular, makes organizer programs be confused while showing the files by date, among other things.
Is there any way of minimally changing the input data (possibly remuxing it) so as to keep it as close as possible to the original data? In particular, I don't want to reencode the file.
Any tools that are available under Linux are preferred.
Extra information
Since the full output of ffmpeg was asked, here it goes. This is a pure Debian testing userland.
As a side note, ffmpeg is complaining about mismatched libraries because it is compiled two times in Debian, once without potentially problematic codecs and another with some extra codecs. I'm using the version with extra codecs, but I suppose that that doesn't matter, since only the muxing is being used here.
Metadata before remuxing
$ ffprobe ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
The remuxing process
Note here that the audio metadata is not copied (which I expected, due to the -metadata:s:v:0 option) and ffmpeg tells me that it is copying the video metadata (without the rotation setting).
$ ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
ffmpeg version 3.0.2-4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Output #0, mp4, to 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 6.0
encoder : Lavf57.25.100
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 90k tbc (default)
Metadata:
encoder : MOTO
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
rotate : 0
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=29640 fps=403 q=-1.0 Lsize= 2121038kB time=00:17:01.91 bitrate=17003.0kbits/s speed=13.9x
video:2120800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.011211%
Metadata after remuxing
Note here that there is no video metadata in the output, only container-level metadata.
$ ffprobe vid_20160619_170845475_unrotated.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Duration: 00:17:01.95, start: 0.000000, bitrate: 17002 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
video ffmpeg video-conversion metadata
Have you seen this answer that explains how to copy just the metadata from one file to another using FFmpeg?
– JakeGould
Jun 24 '16 at 1:57
Please show the complete console output from yourffmpegcommand.
– llogan
Jun 24 '16 at 3:52
@LordNeckbeard, I added all the information that you asked me to. If there's any other information that I should provide, please let me know.
– rbrito
Jun 24 '16 at 20:41
@JakeGould, I don't believe that that answer will help me, as I want to only partially copy the metadata, not the full metadata. If I understoo it incorrectly, please let me know. I want to fix this as well as I can.
– rbrito
Jun 24 '16 at 20:43
1
When you say only partially copy, I assume you mean copy all metadata except rotation. If so, tryffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
– Gyan
Jun 25 '16 at 5:39
|
show 3 more comments
Context and question
I recorded a video with my MotoG3 phone Android phone and the resulting video (perhaps due to shaking the phone) plays rotated, that is, vertically, which is not something that I want. The video was saved in an MP4 container.
Upon inspecting the file that was recorded, I saw (using both ffprobe and mediainfo) that it contains a flag that indicates that the video stream is rotated 90 degrees, which explains the rotation while playing the video. Here is the output from ffprobe:
$ ffprobe -hide_banner ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Since this video is from one rare event with my son, I would like to minimally change the video file, preferrably, only removing the rotation metadata and nothing else.
Unfortunately, using information from other answers didn't help. I tried using:
ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
But other metadata, like the date etc. are not present in the resulting file. This, in particular, makes organizer programs be confused while showing the files by date, among other things.
Is there any way of minimally changing the input data (possibly remuxing it) so as to keep it as close as possible to the original data? In particular, I don't want to reencode the file.
Any tools that are available under Linux are preferred.
Extra information
Since the full output of ffmpeg was asked, here it goes. This is a pure Debian testing userland.
As a side note, ffmpeg is complaining about mismatched libraries because it is compiled two times in Debian, once without potentially problematic codecs and another with some extra codecs. I'm using the version with extra codecs, but I suppose that that doesn't matter, since only the muxing is being used here.
Metadata before remuxing
$ ffprobe ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
The remuxing process
Note here that the audio metadata is not copied (which I expected, due to the -metadata:s:v:0 option) and ffmpeg tells me that it is copying the video metadata (without the rotation setting).
$ ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
ffmpeg version 3.0.2-4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Output #0, mp4, to 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 6.0
encoder : Lavf57.25.100
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 90k tbc (default)
Metadata:
encoder : MOTO
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
rotate : 0
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=29640 fps=403 q=-1.0 Lsize= 2121038kB time=00:17:01.91 bitrate=17003.0kbits/s speed=13.9x
video:2120800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.011211%
Metadata after remuxing
Note here that there is no video metadata in the output, only container-level metadata.
$ ffprobe vid_20160619_170845475_unrotated.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Duration: 00:17:01.95, start: 0.000000, bitrate: 17002 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
video ffmpeg video-conversion metadata
Context and question
I recorded a video with my MotoG3 phone Android phone and the resulting video (perhaps due to shaking the phone) plays rotated, that is, vertically, which is not something that I want. The video was saved in an MP4 container.
Upon inspecting the file that was recorded, I saw (using both ffprobe and mediainfo) that it contains a flag that indicates that the video stream is rotated 90 degrees, which explains the rotation while playing the video. Here is the output from ffprobe:
$ ffprobe -hide_banner ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Since this video is from one rare event with my son, I would like to minimally change the video file, preferrably, only removing the rotation metadata and nothing else.
Unfortunately, using information from other answers didn't help. I tried using:
ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
But other metadata, like the date etc. are not present in the resulting file. This, in particular, makes organizer programs be confused while showing the files by date, among other things.
Is there any way of minimally changing the input data (possibly remuxing it) so as to keep it as close as possible to the original data? In particular, I don't want to reencode the file.
Any tools that are available under Linux are preferred.
Extra information
Since the full output of ffmpeg was asked, here it goes. This is a pure Debian testing userland.
As a side note, ffmpeg is complaining about mismatched libraries because it is compiled two times in Debian, once without potentially problematic codecs and another with some extra codecs. I'm using the version with extra codecs, but I suppose that that doesn't matter, since only the muxing is being used here.
Metadata before remuxing
$ ffprobe ~/Pictures/2016/06/19/vid_20160619_170845475.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
The remuxing process
Note here that the audio metadata is not copied (which I expected, due to the -metadata:s:v:0 option) and ffmpeg tells me that it is copying the video metadata (without the rotation setting).
$ ffmpeg -i ~/Pictures/2016/06/19/vid_20160619_170845475.mp4 -c copy -metadata:s:v:0 rotate=0 -an vid_20160619_170845475_unrotated.mp4
ffmpeg version 3.0.2-4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/rbrito/Pictures/2016/06/19/vid_20160619_170845475.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-19 20:25:49
com.android.version: 6.0
Duration: 00:17:01.96, start: 0.000000, bitrate: 17134 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
encoder : MOTO
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2016-06-19 20:25:49
handler_name : SoundHandle
Output #0, mp4, to 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 6.0
encoder : Lavf57.25.100
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 90k tbc (default)
Metadata:
encoder : MOTO
creation_time : 2016-06-19 20:25:49
handler_name : VideoHandle
rotate : 0
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=29640 fps=403 q=-1.0 Lsize= 2121038kB time=00:17:01.91 bitrate=17003.0kbits/s speed=13.9x
video:2120800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.011211%
Metadata after remuxing
Note here that there is no video metadata in the output, only container-level metadata.
$ ffprobe vid_20160619_170845475_unrotated.mp4
ffprobe version 3.0.2-4 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-3) 20160603
configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=4 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_amrwbenc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vid_20160619_170845475_unrotated.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Duration: 00:17:01.95, start: 0.000000, bitrate: 17002 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17000 kb/s, 29 fps, 29.42 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
video ffmpeg video-conversion metadata
video ffmpeg video-conversion metadata
edited May 23 '17 at 11:33
Community♦
1
1
asked Jun 24 '16 at 1:43
rbritorbrito
207110
207110
Have you seen this answer that explains how to copy just the metadata from one file to another using FFmpeg?
– JakeGould
Jun 24 '16 at 1:57
Please show the complete console output from yourffmpegcommand.
– llogan
Jun 24 '16 at 3:52
@LordNeckbeard, I added all the information that you asked me to. If there's any other information that I should provide, please let me know.
– rbrito
Jun 24 '16 at 20:41
@JakeGould, I don't believe that that answer will help me, as I want to only partially copy the metadata, not the full metadata. If I understoo it incorrectly, please let me know. I want to fix this as well as I can.
– rbrito
Jun 24 '16 at 20:43
1
When you say only partially copy, I assume you mean copy all metadata except rotation. If so, tryffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
– Gyan
Jun 25 '16 at 5:39
|
show 3 more comments
Have you seen this answer that explains how to copy just the metadata from one file to another using FFmpeg?
– JakeGould
Jun 24 '16 at 1:57
Please show the complete console output from yourffmpegcommand.
– llogan
Jun 24 '16 at 3:52
@LordNeckbeard, I added all the information that you asked me to. If there's any other information that I should provide, please let me know.
– rbrito
Jun 24 '16 at 20:41
@JakeGould, I don't believe that that answer will help me, as I want to only partially copy the metadata, not the full metadata. If I understoo it incorrectly, please let me know. I want to fix this as well as I can.
– rbrito
Jun 24 '16 at 20:43
1
When you say only partially copy, I assume you mean copy all metadata except rotation. If so, tryffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
– Gyan
Jun 25 '16 at 5:39
Have you seen this answer that explains how to copy just the metadata from one file to another using FFmpeg?
– JakeGould
Jun 24 '16 at 1:57
Have you seen this answer that explains how to copy just the metadata from one file to another using FFmpeg?
– JakeGould
Jun 24 '16 at 1:57
Please show the complete console output from your
ffmpeg command.– llogan
Jun 24 '16 at 3:52
Please show the complete console output from your
ffmpeg command.– llogan
Jun 24 '16 at 3:52
@LordNeckbeard, I added all the information that you asked me to. If there's any other information that I should provide, please let me know.
– rbrito
Jun 24 '16 at 20:41
@LordNeckbeard, I added all the information that you asked me to. If there's any other information that I should provide, please let me know.
– rbrito
Jun 24 '16 at 20:41
@JakeGould, I don't believe that that answer will help me, as I want to only partially copy the metadata, not the full metadata. If I understoo it incorrectly, please let me know. I want to fix this as well as I can.
– rbrito
Jun 24 '16 at 20:43
@JakeGould, I don't believe that that answer will help me, as I want to only partially copy the metadata, not the full metadata. If I understoo it incorrectly, please let me know. I want to fix this as well as I can.
– rbrito
Jun 24 '16 at 20:43
1
1
When you say only partially copy, I assume you mean copy all metadata except rotation. If so, try
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4– Gyan
Jun 25 '16 at 5:39
When you say only partially copy, I assume you mean copy all metadata except rotation. If so, try
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4– Gyan
Jun 25 '16 at 5:39
|
show 3 more comments
2 Answers
2
active
oldest
votes
FFmpeg by default doesn't transfer most user metadata over, but it does transfer fields like rotation tag.
The command below instructs FFmpeg to transfer all metadata over but then overrides the rotation tag value.
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
add a comment |
import os
from mutagen.mp4 import MP4
## sudo python3.6 -m pip install mutagen
## or
## sudo python2.7 -m pip install mutagen
VIDEO_FOLDER = "/media/removable/64GB-Micro/Videos"
def get_all_files(path):
return os.listdir(path)
def clean_metadata(videos_dir, files):
for file_name in files:
file_path = os.path.join(videos_dir, file_name)
## create MP4 video_file instance
video_file = MP4(file_path)
## uncomment print(video_file) to lists all key-value for video_file:
print(video_file)
## show video_file artist and title before clean
print("file_name: {}".format(file_name))
print("Old ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("Old aArt: {}".format(video_file.get('aART', "Key not found")))
print("Old nam: {}".format(video_file.get('xa9nam', "Key not found")))
## clean artist and name
video_file['xa9ART'] = ''
video_file['aART'] = ''
video_file['xa9nam'] = ''
## save new metadata
video_file.save()
## show video_file artist and title after clean
print("New ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("New aArt: {}".format(video_file.get('aART', "Key not found")))
print("New nam: {}".format(video_file.get('xa9nam', "Key not found")))
if __name__ == '__main__':
files = get_all_files(VIDEO_FOLDER)
clean_metadata(videos_dir=VIDEO_FOLDER, files=files)
Some explanation as to what this does and how to implement it will make it more of an answer. Right now a) the question already has an answer, and b) its not immediately clear what this does.
– music2myear
Jan 15 at 22:15
The question asks for a solution using a tool, not a program. And it has an accepted answer using a command. (1) What does your program do that is different from the ffmpeg command? Specifically, how/why is it better? (2) How does one run your program? OK, I see a couple of (what look like) comments near the beginning that look like commands, but they aren’t very clear. You should have at least a couple of sentences outside of the code that answer these questions. … (Cont’d)
– Scott
Jan 15 at 22:29
(Cont’d) … (3) And why would the user needsudoto read a file that he has read access to, and create an output file in a directory where he has write access? … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete.
– Scott
Jan 15 at 22:29
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1092951%2fhow-to-delete-a-single-metadata-item-from-an-mp4-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
FFmpeg by default doesn't transfer most user metadata over, but it does transfer fields like rotation tag.
The command below instructs FFmpeg to transfer all metadata over but then overrides the rotation tag value.
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
add a comment |
FFmpeg by default doesn't transfer most user metadata over, but it does transfer fields like rotation tag.
The command below instructs FFmpeg to transfer all metadata over but then overrides the rotation tag value.
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
add a comment |
FFmpeg by default doesn't transfer most user metadata over, but it does transfer fields like rotation tag.
The command below instructs FFmpeg to transfer all metadata over but then overrides the rotation tag value.
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
FFmpeg by default doesn't transfer most user metadata over, but it does transfer fields like rotation tag.
The command below instructs FFmpeg to transfer all metadata over but then overrides the rotation tag value.
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4
answered Jul 2 '16 at 7:00
GyanGyan
15k21845
15k21845
add a comment |
add a comment |
import os
from mutagen.mp4 import MP4
## sudo python3.6 -m pip install mutagen
## or
## sudo python2.7 -m pip install mutagen
VIDEO_FOLDER = "/media/removable/64GB-Micro/Videos"
def get_all_files(path):
return os.listdir(path)
def clean_metadata(videos_dir, files):
for file_name in files:
file_path = os.path.join(videos_dir, file_name)
## create MP4 video_file instance
video_file = MP4(file_path)
## uncomment print(video_file) to lists all key-value for video_file:
print(video_file)
## show video_file artist and title before clean
print("file_name: {}".format(file_name))
print("Old ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("Old aArt: {}".format(video_file.get('aART', "Key not found")))
print("Old nam: {}".format(video_file.get('xa9nam', "Key not found")))
## clean artist and name
video_file['xa9ART'] = ''
video_file['aART'] = ''
video_file['xa9nam'] = ''
## save new metadata
video_file.save()
## show video_file artist and title after clean
print("New ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("New aArt: {}".format(video_file.get('aART', "Key not found")))
print("New nam: {}".format(video_file.get('xa9nam', "Key not found")))
if __name__ == '__main__':
files = get_all_files(VIDEO_FOLDER)
clean_metadata(videos_dir=VIDEO_FOLDER, files=files)
Some explanation as to what this does and how to implement it will make it more of an answer. Right now a) the question already has an answer, and b) its not immediately clear what this does.
– music2myear
Jan 15 at 22:15
The question asks for a solution using a tool, not a program. And it has an accepted answer using a command. (1) What does your program do that is different from the ffmpeg command? Specifically, how/why is it better? (2) How does one run your program? OK, I see a couple of (what look like) comments near the beginning that look like commands, but they aren’t very clear. You should have at least a couple of sentences outside of the code that answer these questions. … (Cont’d)
– Scott
Jan 15 at 22:29
(Cont’d) … (3) And why would the user needsudoto read a file that he has read access to, and create an output file in a directory where he has write access? … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete.
– Scott
Jan 15 at 22:29
add a comment |
import os
from mutagen.mp4 import MP4
## sudo python3.6 -m pip install mutagen
## or
## sudo python2.7 -m pip install mutagen
VIDEO_FOLDER = "/media/removable/64GB-Micro/Videos"
def get_all_files(path):
return os.listdir(path)
def clean_metadata(videos_dir, files):
for file_name in files:
file_path = os.path.join(videos_dir, file_name)
## create MP4 video_file instance
video_file = MP4(file_path)
## uncomment print(video_file) to lists all key-value for video_file:
print(video_file)
## show video_file artist and title before clean
print("file_name: {}".format(file_name))
print("Old ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("Old aArt: {}".format(video_file.get('aART', "Key not found")))
print("Old nam: {}".format(video_file.get('xa9nam', "Key not found")))
## clean artist and name
video_file['xa9ART'] = ''
video_file['aART'] = ''
video_file['xa9nam'] = ''
## save new metadata
video_file.save()
## show video_file artist and title after clean
print("New ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("New aArt: {}".format(video_file.get('aART', "Key not found")))
print("New nam: {}".format(video_file.get('xa9nam', "Key not found")))
if __name__ == '__main__':
files = get_all_files(VIDEO_FOLDER)
clean_metadata(videos_dir=VIDEO_FOLDER, files=files)
Some explanation as to what this does and how to implement it will make it more of an answer. Right now a) the question already has an answer, and b) its not immediately clear what this does.
– music2myear
Jan 15 at 22:15
The question asks for a solution using a tool, not a program. And it has an accepted answer using a command. (1) What does your program do that is different from the ffmpeg command? Specifically, how/why is it better? (2) How does one run your program? OK, I see a couple of (what look like) comments near the beginning that look like commands, but they aren’t very clear. You should have at least a couple of sentences outside of the code that answer these questions. … (Cont’d)
– Scott
Jan 15 at 22:29
(Cont’d) … (3) And why would the user needsudoto read a file that he has read access to, and create an output file in a directory where he has write access? … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete.
– Scott
Jan 15 at 22:29
add a comment |
import os
from mutagen.mp4 import MP4
## sudo python3.6 -m pip install mutagen
## or
## sudo python2.7 -m pip install mutagen
VIDEO_FOLDER = "/media/removable/64GB-Micro/Videos"
def get_all_files(path):
return os.listdir(path)
def clean_metadata(videos_dir, files):
for file_name in files:
file_path = os.path.join(videos_dir, file_name)
## create MP4 video_file instance
video_file = MP4(file_path)
## uncomment print(video_file) to lists all key-value for video_file:
print(video_file)
## show video_file artist and title before clean
print("file_name: {}".format(file_name))
print("Old ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("Old aArt: {}".format(video_file.get('aART', "Key not found")))
print("Old nam: {}".format(video_file.get('xa9nam', "Key not found")))
## clean artist and name
video_file['xa9ART'] = ''
video_file['aART'] = ''
video_file['xa9nam'] = ''
## save new metadata
video_file.save()
## show video_file artist and title after clean
print("New ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("New aArt: {}".format(video_file.get('aART', "Key not found")))
print("New nam: {}".format(video_file.get('xa9nam', "Key not found")))
if __name__ == '__main__':
files = get_all_files(VIDEO_FOLDER)
clean_metadata(videos_dir=VIDEO_FOLDER, files=files)
import os
from mutagen.mp4 import MP4
## sudo python3.6 -m pip install mutagen
## or
## sudo python2.7 -m pip install mutagen
VIDEO_FOLDER = "/media/removable/64GB-Micro/Videos"
def get_all_files(path):
return os.listdir(path)
def clean_metadata(videos_dir, files):
for file_name in files:
file_path = os.path.join(videos_dir, file_name)
## create MP4 video_file instance
video_file = MP4(file_path)
## uncomment print(video_file) to lists all key-value for video_file:
print(video_file)
## show video_file artist and title before clean
print("file_name: {}".format(file_name))
print("Old ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("Old aArt: {}".format(video_file.get('aART', "Key not found")))
print("Old nam: {}".format(video_file.get('xa9nam', "Key not found")))
## clean artist and name
video_file['xa9ART'] = ''
video_file['aART'] = ''
video_file['xa9nam'] = ''
## save new metadata
video_file.save()
## show video_file artist and title after clean
print("New ART: {}".format(video_file.get('xa9ART', "Key not found")))
print("New aArt: {}".format(video_file.get('aART', "Key not found")))
print("New nam: {}".format(video_file.get('xa9nam', "Key not found")))
if __name__ == '__main__':
files = get_all_files(VIDEO_FOLDER)
clean_metadata(videos_dir=VIDEO_FOLDER, files=files)
answered Jan 15 at 21:35
Jozsef TuriJozsef Turi
1
1
Some explanation as to what this does and how to implement it will make it more of an answer. Right now a) the question already has an answer, and b) its not immediately clear what this does.
– music2myear
Jan 15 at 22:15
The question asks for a solution using a tool, not a program. And it has an accepted answer using a command. (1) What does your program do that is different from the ffmpeg command? Specifically, how/why is it better? (2) How does one run your program? OK, I see a couple of (what look like) comments near the beginning that look like commands, but they aren’t very clear. You should have at least a couple of sentences outside of the code that answer these questions. … (Cont’d)
– Scott
Jan 15 at 22:29
(Cont’d) … (3) And why would the user needsudoto read a file that he has read access to, and create an output file in a directory where he has write access? … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete.
– Scott
Jan 15 at 22:29
add a comment |
Some explanation as to what this does and how to implement it will make it more of an answer. Right now a) the question already has an answer, and b) its not immediately clear what this does.
– music2myear
Jan 15 at 22:15
The question asks for a solution using a tool, not a program. And it has an accepted answer using a command. (1) What does your program do that is different from the ffmpeg command? Specifically, how/why is it better? (2) How does one run your program? OK, I see a couple of (what look like) comments near the beginning that look like commands, but they aren’t very clear. You should have at least a couple of sentences outside of the code that answer these questions. … (Cont’d)
– Scott
Jan 15 at 22:29
(Cont’d) … (3) And why would the user needsudoto read a file that he has read access to, and create an output file in a directory where he has write access? … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete.
– Scott
Jan 15 at 22:29
Some explanation as to what this does and how to implement it will make it more of an answer. Right now a) the question already has an answer, and b) its not immediately clear what this does.
– music2myear
Jan 15 at 22:15
Some explanation as to what this does and how to implement it will make it more of an answer. Right now a) the question already has an answer, and b) its not immediately clear what this does.
– music2myear
Jan 15 at 22:15
The question asks for a solution using a tool, not a program. And it has an accepted answer using a command. (1) What does your program do that is different from the ffmpeg command? Specifically, how/why is it better? (2) How does one run your program? OK, I see a couple of (what look like) comments near the beginning that look like commands, but they aren’t very clear. You should have at least a couple of sentences outside of the code that answer these questions. … (Cont’d)
– Scott
Jan 15 at 22:29
The question asks for a solution using a tool, not a program. And it has an accepted answer using a command. (1) What does your program do that is different from the ffmpeg command? Specifically, how/why is it better? (2) How does one run your program? OK, I see a couple of (what look like) comments near the beginning that look like commands, but they aren’t very clear. You should have at least a couple of sentences outside of the code that answer these questions. … (Cont’d)
– Scott
Jan 15 at 22:29
(Cont’d) … (3) And why would the user need
sudo to read a file that he has read access to, and create an output file in a directory where he has write access? … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete.– Scott
Jan 15 at 22:29
(Cont’d) … (3) And why would the user need
sudo to read a file that he has read access to, and create an output file in a directory where he has write access? … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete.– Scott
Jan 15 at 22:29
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1092951%2fhow-to-delete-a-single-metadata-item-from-an-mp4-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you seen this answer that explains how to copy just the metadata from one file to another using FFmpeg?
– JakeGould
Jun 24 '16 at 1:57
Please show the complete console output from your
ffmpegcommand.– llogan
Jun 24 '16 at 3:52
@LordNeckbeard, I added all the information that you asked me to. If there's any other information that I should provide, please let me know.
– rbrito
Jun 24 '16 at 20:41
@JakeGould, I don't believe that that answer will help me, as I want to only partially copy the metadata, not the full metadata. If I understoo it incorrectly, please let me know. I want to fix this as well as I can.
– rbrito
Jun 24 '16 at 20:43
1
When you say only partially copy, I assume you mean copy all metadata except rotation. If so, try
ffmpeg -i in.mp4 -c copy -map_metadata 0 -metadata:s:v:0 rotate=0 -an out.mp4– Gyan
Jun 25 '16 at 5:39