2
votes

i have a .mp4 video, that is recorded in iphone4s.This video file contains 'Rotate - 180' metadata.

When i am converting the .mp4 file to .ts using ffmpeg. I lost the 'Rotate' meta tag.

The ffmpeg command that i have used is given below.

ffmpeg -i input_file.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb output_file.ts

is there any one know how to set 'Rotate' meta data to a .ts file ?

or

any other way to copy all meta datas in the input .mp4 file to output .ts file

Thank you

1
You need to also include the complete ffmpeg console output.llogan

1 Answers

2
votes

Nothing seems to work to add the rotation metadata to .ts files with ffmpeg. Only re-encoding works.

My input file has a rotation value of 90.
Terminal command:

./ffmpeg -i input_file.mp4

Metadata:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input_file.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
creation_time : 2013-08-27 21:25:13
Duration: 00:00:21.33, start: 0.000000, bitrate: 16820 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17011 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc
Metadata:
rotate : 90
creation_time : 2013-08-27 21:25:13
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 121 kb/s
Metadata:
creation_time : 2013-08-27 21:25:13
handler_name : SoundHandle

The following attempts did not get the rotation value to copy over:

./ffmpeg -y -i input_file.mp4 -vcodec copy -acodec copy -bsf h264_mp4toannexb output_file.ts
./ffmpeg -y -i input_file.mp4 -vcodec copy -acodec copy -bsf h264_mp4toannexb -metadata rotate=90 output_file.ts
//------ even manually specifying the metadata as the first video stream does not work: ------//
./ffmpeg -y -i input_file.mp4 -vcodec copy -acodec copy -bsf h264_mp4toannexb -metadata:s:v:0 rotate=90 output_file.ts

Even though you can manually inject metadata like:

./ffmpeg -y -i input_file.mp4 -vcodec copy -acodec copy -bsf h264_mp4toannexb -metadata TITLE='Test Title' output_file.ts

This does work, but requires re-encoding, which is really inefficient compared to video and audio codec copying above.
(1 == 90 degree CW rotation)

./ffmpeg -y -i input_file.mp4 -vf "transpose=1" output_file.ts