Reputation: 11760
I am trying to replace an MP4 file played back in a relatively restricted environment and so I am trying to create a video file as close to the current one as possible to make sure it'll work. ffprobe
has this:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
creation_time : 2016-12-07T20:39:51.000000Z
encoder : HandBrake 0.9.9 2013051800
Duration: 00:00:11.01, start: 0.000000, bitrate: 4789 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1080x1920 [SAR 1:1 DAR 9:16], 4648 kb/s, 24 fps, 24 tbr, 90k tbn, 180k tbc (default)
I do not know how to specify mp42
and mp42isomavc1
. The rest I have some ideas about: -vf
supports setsar
and setdar
, -pix_fmt yuv420p
, -framerate 24
.
Upvotes: 0
Views: 1340
Reputation: 93048
Assuming that you start with a video input and that resolution doesn't matter, use
ffmpeg -i source -vf setsar=1,format=yuv420p -r 24 \
-c:v libx264 -profile:v main -video_track_timescale 90k \
-color_primaries 1 -color_trc 1 -colorspace 1 -color_range 1 \
-brand mp42 -movflags +faststart out.mp4
FFmpeg does not allow one to manually set the minor_version
. When encoding, the encoder will select a codec time base tbc
and it's not recommended to manually set it. The color properties are set to match your given input but if your source has different properties and you don't convert them using filters, then these attributes will be false. Of course, your decoder may ignore these container level flags and check only the bitstream.
If your input framerate isn't 24, then ffmpeg will drop/duplicate frames to meet the output rate. Unless your input has a framerate not supported by the player, better to skip the -r
option.
Upvotes: 1