Introduction
I use this command to deshake and stabilize a video:
ffmpeg2 -i SHAKY_INPUT_VIDEO.mp4 -vf \
vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=transform_vectors.trf \
-f null -
ffmpeg2 -i SHAKY_INPUT_VIDEO.mp4 -vf \
vidstabtransform=input=transform_vectors.trf:zoom=1:smoothing=30,unsharp=5:5:0.8:3:3:0.4 \
-vcodec libx264 -preset slow -tune film -crf 18 -acodec copy SMOOTH_OUTPUT_VIDEO.mkv
(I use mkv since mp4 output results in this error: Could not find tag for codec pcm_s16le in stream #1, codec not currently supported in container)
Source: https://www.epifocal.net/blog/video-stabilization-with-ffmpeg
I use ffmpeg2 (See Deshaking videos using script)
How to reduce the video size?
Above two lines stabilize the video size. How can I reduce the size?
I see two aspects:
- audio
- resolution. If I understand the following output the resolution is at the moment 1920x1080. I think 720p would be enough.
My video meta data:
===> ffprobe2 20170217_114248.MOV
ffprobe version git-2017-02-19-3206ea4 Copyright (c) 2007-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --disable-ffserver --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libtheora --enable-libwavpack --enable-libopenjpeg --enable-libgsm --enable-nvenc
libavutil 55. 47.100 / 55. 47.100
libavcodec 57. 80.101 / 57. 80.101
libavformat 57. 66.102 / 57. 66.102
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 73.100 / 6. 73.100
libavresample 3. 2. 0 / 3. 2. 0
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20170217_114248-Felix-Jáchymovská.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2017-02-17T10:39:32.000000Z
Duration: 00:03:15.00, start: 0.000000, bitrate: 23478 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 22060 kb/s, 60 fps, 60 tbr, 60k tbn, 120k tbc (default)
Metadata:
creation_time : 2017-02-17T10:39:32.000000Z
handler_name : iCatch Alias Data Handler
encoder : iCatch AVCC
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 44100 Hz, 2 channels, s16, 1411 kb/s (default)
Metadata:
creation_time : 2017-02-17T10:39:32.000000Z
handler_name : iCat Alias Data Handler