diff --git a/README.md b/README.md index 70c40b6..0903ce5 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,17 @@ $ ios-simulator-gif [options] {out_file} {-- [ffmpeg options]} | -r, --rate | Framerate of the output | `6` | | -f, --format | Output format | `gif` | | -vf, --video-filter | Video filter for `ffmpeg` | `scale=320:-1` | +| -t, --transpose | Transpose the video for landscape orientation | N/A | | --no-watermark | Remove watermark from gif | N/A | | -h, --help | Prints helper message | N/A | | -v, --version | Prints current version | N/A | If no file name is given, it will save the gif to `./simulator.gif` +When recording a video in landscape mode you'll need to provide the appropriate transposing argument. It's usually the following: +1. `--transpose 1` when the simulator is rotated 90º (camera to the right) +2. `--transpose 2` when the simulator is rotated 270º (camera to the left) + ### Sending extra arguments to `ffmpeg` If you need to send extra arguments to `ffmpeg`, everything sent after double slashes (`--`) will be diff --git a/bin/ios-simulator-gif b/bin/ios-simulator-gif index 97ea6a1..ced696b 100755 --- a/bin/ios-simulator-gif +++ b/bin/ios-simulator-gif @@ -14,8 +14,8 @@ VIDEO=/tmp/simulator-gif.mov ############## main() { parse_args "$@" - # check_booted - # record + check_booted + record convert_gif } @@ -87,6 +87,10 @@ convert_gif() { PALLETE="/tmp/palette.png" FILTERS="${HIDE_WATERMARK-$WATERMARK_CMD,}${VIDEOFILTER},fps=${RATE}" + if [[ ! -z "${TRANSPOSE}" ]]; then + FILTERS="${FILTERS},transpose=${TRANSPOSE}" + fi + ffmpeg -v warning -i ${VIDEO} -vf "$FILTERS,palettegen=stats_mode=diff" -y ${PALLETE} ffmpeg -i ${VIDEO} -i ${PALLETE} -lavfi "$FILTERS,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -r $RATE -f $FORMAT -y $FILE_NAME $EXTRA &> /tmp/ffmpeg.log @@ -129,6 +133,10 @@ parse_args() { echo "${PKG_VERSION}" exit 0 ;; + -t|--transpose) + TRANSPOSE="$2" + shift 2 + ;; --no-watermark) HIDE_WATERMARK='' shift 1 @@ -165,6 +173,7 @@ display_help() { echo " -r, --rate Framerate of the output (default: 15)" echo " -f, --format Output format (default: gif)" echo " -vf, --video-filter Video filter for ffmpeg (default: scale=320:-1:flags=lanczos)" + echo " -t, --transpose Transpose the video for landscape orientation (usually 1 for 90deg and 2 for 270deg)" echo " --no-watermark Remove watermark from gif" echo " -h, --help Outputs this help message" echo " -v, --version Outputs the version number"