가끔씩 핸드폰 비디오가 90도 돌아가 있는 상태로 저장된것을 봅니다. MP4 header에 orientation이 있어서 새로 transcoding하는 것은 안좋은 상황. 비손실과 속도까지 고려하면 헤더만 change하는것이 좋음
1. FFMPEG으로 transcoding
# rotate video 1=90 cw, 2=90 ccw
# -filter:v transpose=1
ffmpeg -n -i 20190811_000.mp4 -filter:v transpose=2 20190811_000_r.mp4
ffmpeg -i in.mov -vf "transpose=1" out.mov
0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip
2. VLCPlayer로
Tools >> Preferences, Show settings->check "All"
Video >> Filters >> check Rotate video filter
Tools > Effects and Filters > Video Effects > Geometry
TODO:저장되나?
3. MP4 Header만 손수 update
https://superuser.com/questions/1307158/change-rotation-flag-in-mp4-video-without-losing-metadata
open mp4 with hex editor and search for vide to find the metadata of the video track
some rows above (for my files mostly 9, sometimes 12) you should see trak...\tkhd
-
no rotation:
00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 -
180°:
FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 -
90° cw:
00 00 00 00 00 01 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 -
90° ccw:
00 00 00 00 FF FF 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40
4. EXIF 정보만 update
program이 EXIF을 읽는다면
http://owl.phy.queensu.ca/~phil/exiftool/
exiftool -Orientation='Rotate 90 CW' INPUT_FILE
exiftool -Orientation='Rotate 270 CW' INPUT_FILE
---------------
핸드폰으로 찍은 비디오가 참 화질이 좋은데, mediainfo로 보면 진자 기가맥히게 설정이 잘 되어있네요. transcoding/다시encoding해서 퀄리티를 유지하기가 진짜 어려울 정도
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.2
Format settings : CABAC / 1 Ref Frames
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
'Programming' 카테고리의 다른 글
10 simple Linux tips in the command line (0) | 2019.08.20 |
---|---|
Ubuntu upgrade 18.10 -> 19.04 (0) | 2019.08.15 |
FFMPEG으로 비디오 파일에서 10초만 짤라서 만들기 (0) | 2019.08.13 |
linux kernel build on ubuntu (0) | 2019.03.07 |
MinGW-w64 install (0) | 2017.01.22 |