R
R
Rinat2017-08-26 12:21:28
PHP
Rinat, 2017-08-26 12:21:28

Ffmpeg rotate video how to update metadata?

Greetings, I've been fighting for more than one hour and I can't figure out how to convert video correctly.
first I read the data of the uploaded video, check the size to resize or not. so I check if, for example, I shoot from the phone, I get mediainfo data '.$video.' | grep Rotation
on the iPhone test. I get info that the video needs to be rotated. Next I make a poster.
In general, everything works as it should. but the problem is that when I encode with a rotation, the html5 video continues to show it with the original data. those. rotates the video already rotated.
I assume that the meta data of the video is not updated and html5 reads it and rotates it automatically.
How to update data after a flip?
media info before conversion

spoiler
Format : MPEG-4
Format profile : QuickTime
Codec ID : qt 0000.00 (qt )
File size : 2.52 MiB
Duration : 24 s 747 ms
Overall bit rate mode : Variable
Overall bit rate : 853 kb/s
Encoded date : UTC 2017-08-26 06:27:24
Tagged date : UTC 2017-08-26 06:27:49
Writing library : Apple QuickTime
com.apple.quicktime.make : Apple
com.apple.quicktime.model : iPhone 6 Plus
com.apple.quicktime.software : 10.3.2
com.apple.quicktime.creationdate : 2017-08-26T11:27:24+0500
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : No
Format settings, RefFrames : 1 frame
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 24 s 747 ms
Bit rate : 756 kb/s
Width : 480 pixels
Height : 360 pixels
Display aspect ratio : 4:3
Rotation : 90?
Frame rate mode : Variable
Frame rate : 29.970 (29970/1000) FPS
Minimum frame rate : 28.571 FPS
Maximum frame rate : 30.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.146
Stream size : 2.23 MiB (89%)
Title : Core Media Video
Encoded date : UTC 2017-08-26 06:27:24
Tagged date : UTC 2017-08-26 06:27:49
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.601
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 24 s 747 ms
Source duration : 24 s 799 ms
Bit rate mode : Variable
Bit rate : 86.6 kb/s
Channel(s) : 1 channel
Channel positions : Front: C
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 262 KiB (10%)
Source stream size : 262 KiB (10%)
Title : Core Media Audio
Encoded date : UTC 2017-08-26 06:27:24
Tagged date : UTC 2017-08-26 06:27:49
Other #1
Type : meta
Duration : 24 s 747 ms
Duration_FirstFrame : 5370
Duration_LastFrame : 18443
Bit rate mode : VBR
Other #2
Type : meta
Duration : 24 s 747 ms
Bit rate mode : CBR

after conversion
spoiler
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 1.78 MiB
Duration : 24 s 823 ms
Overall bit rate mode : Variable
Overall bit rate : 601 kb/s
Writing application : Lavf56.25.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : Yes
Format settings, RefFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 24 s 759 ms
Bit rate : 512 kb/s
Width : 360 pixels
Height : 480 pixels
Display aspect ratio : 0.750
Rotation : 90?
Frame rate mode : Constant
Frame rate : 29.970 (30000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.099
Stream size : 1.53 MiB (86%)
Writing library : x264 core 142 r2495 6a301b6
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=1 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=512 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 24 s 823 ms
Bit rate mode : Variable
Bit rate : 75.8 kb/s
Maximum bit rate : 96.0 kb/s
Channel(s) : 2 channels
Channel(s)_Original : 1 channel
Channel positions : Front: C
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 230 KiB (13%)
Default : Yes
Alternate group : 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Moskus, 2017-08-27
@renya555

Here is an article on this topic (language - English), there are a lot of details.
Indeed, after the conversion, you either need to correct the contents of the rotation tag, or just delete it for nothing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question