Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 757e3eb

Browse files
committed
Add video stabilization script
1 parent 8267627 commit 757e3eb

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Script Title
2+
<!--Remove the below lines and add yours -->
3+
A wrapper script for video stabilization using ffmpeg
4+
5+
### Prerequisites
6+
<!--Remove the below lines and add yours -->
7+
* [ffmpeg](https://ffmpeg.org)
8+
9+
### How to run the script
10+
<!--Remove the below lines and add yours -->
11+
```
12+
python3 vid_stab.py
13+
```
14+
Then follow the instructions.
15+
### Screenshot/GIF showing the sample use of the script
16+
<!--Remove the below lines and add yours -->
17+
An example video can be found [here](https://www.youtube.com/watch?v=yKc8uOfLSv4).
18+
19+
## *Author Name*
20+
<!--Remove the below lines and add yours -->
21+
Made with ♥ by [valterm](github.com/valterm)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os, subprocess
2+
from tempfile import NamedTemporaryFile
3+
4+
5+
infile = input('Input file: ')
6+
outfile= input('Output file: ')
7+
shakiness= input('Shakiness (1-10): ')
8+
accuracy= input('Accuracy (1-15): ')
9+
smoothing=input('Smoothing (1-): ')
10+
11+
vidstb= 'vidstabdetect=stepsize=6:shakiness='+shakiness+':accuracy='+accuracy+':result=/dev/stdout'
12+
13+
cmd1=['ffmpeg', '-loglevel', 'panic','-i',infile , '-vf',vidstb, '-f','null','pipe:1']
14+
p = subprocess.Popen(cmd1, stdout=subprocess.PIPE)
15+
vectors, err = p.communicate()
16+
17+
vf = NamedTemporaryFile()
18+
original_path = vf.name
19+
20+
x = bytearray(vectors)
21+
22+
f = open(original_path, 'wb')
23+
f.write(x)
24+
f.close()
25+
26+
os.system('ffmpeg -loglevel panic -i ' + infile + ' -vf vidstabtransform=input='+ original_path +':smoothing='+smoothing+':crop=keep,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -preset slow -tune film -crf 18 -acodec copy ' + outfile )
27+
28+
29+
print('Done')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /