Last active
January 17, 2024 12:00
-
-
Save agrathwohl/2c071efc42b5b6d816d1 to your computer and use it in GitHub Desktop.
FFmpeg options that will make your iOS video experience much better
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FFmpeg / iOS Video Taming | |
## General Options: | |
# These settings may be applied to both the INPUT and the OUTPUT | |
# of the FFmpeg command. | |
-r 30 # set the frame rate of the video to Apple's recommended 30 fps | |
-pix_fmt yuv420p # set the output video's pixel format | |
# QuickTime uniquely cannot handle any | |
# format other than yuv420p and it will | |
# complain if anything else is found | |
# in the container metadata | |
## Output Options: | |
# Only add these arguments to the OUTPUT settings | |
# of your FFmpeg command. | |
-copyinkf # By default, FFmpeg does not copy the non-key frames | |
# found at the beginning of most iOS-created QT media | |
# when doing a stream-copy mux. | |
# This option will essentially re-create the unique | |
# quicktime transport feature that causes video playback | |
# to hang right at the beginning of the file, so that AV | |
# sync can catch up | |
-vsync 2 # '2' == 'vfr'. Don't let FFmpeg sync the video stream any other way! | |
-async 1 # Putting '1' here will tell FFmpeg to attempt to stretch/squeeze the | |
# start of the audio stream such that it will need no further treatment | |
# later on in the presentation of the media container's content | |
-vf setpts=PTS-STARTPTS # This is the best way to ensure that the video's PTS is | |
# correctly transferred to the new container file without | |
# nudging back out of sync with the audio stream. | |
-bsf:v h264_mp4toannexb # A bitstream filter that will | |
# allow iOS MP4s to successfully | |
# convert to MPEG-2 TS for HLS creation. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment