-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathffmpeg.txt
More file actions
59 lines (50 loc) · 2.84 KB
/
ffmpeg.txt
File metadata and controls
59 lines (50 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
http://journal.code4lib.org/articles/9856
- for image is not in 16:9 or 4:3. the image should be normalize into 16:9/4:3 first
- the dimension => 16/9 = 1.7777777(1.78), 4/3 = 1.333333(1.4)
cropping image into height = 90 and width = 120
ffmpeg -i input.png -vf "crop=120:90:ih/2:iw/2" input_crop.png
syntax: ffmpeg -i input.png -vf "crop=w:h:x:y" input_crop.png
- width = 120
- height = 90
- position horizontal - x
- position vertical - y
scale image into height = 90 and the width is relative
ffmpeg -i ngangnhienxayresortkhongphepgiuavuonquocgia.jpeg -vf scale=-1:90 result.jpg
scale image into height is relative and the width = 120
ffmpeg -i luu-hoang-tai-jpg-1457160278.jpg -vf scale=120:-1 tuoitre.jpg
add the border of image with pad=w:h:x:y
- the height = 90
- width is not change
- the x = 0
- the y = 10 px
ffmpeg -i tuoitre.jpg -vf pad=0:90:0:10:black output.jpg
ffmpeg -i tuoitre.jpg -vf pad=0:90:(width/2):(height/2):black output.jpg -- for center x and y
ffmpeg -i /home/hadn/script/tuoitre_crawler/tuoitre/1063453/3af2666a.jpg -vf "pad=780:1040:(780-665)/2:(1040-771)/2:black" /home/hadn/script/tuoitre_crawler/tuoitre/1063453/3af2666a_pad_43.jpg
example:
- the origin image
Image
Format : JPEG
Width : 120 pixels
Height : 67 pixels
Color space : YUV
Bit depth : 8 bits
Compression mode : Lossy
Stream size : 2.99 KiB (100%)
- the output image
Image
Format : JPEG
Width : 120 pixels
Height : 90 pixels
Color space : YUV
Bit depth : 8 bits
Compression mode : Lossy
Stream size : 2.93 KiB (100%)
Cropping syntax
In this chapter, we'll crop the input video to given dimensions.
The command syntax looks like this:
ffmpeg -i before.mp4 -vf "crop=w:h:x:y" after.mp4
The crop filter accepts the following options:
w: Width of the output video (out_w). It defaults to iw. This expression is evaluated only once during the filter configuration.
h: Height of the output video (out_h). It defaults to ih. This expression is evaluated only once during the filter configuration.
x: Horizontal position, in the input video, of the left edge of the output video. It defaults to (in_w-out_w)/2. This expression is evaluated per-frame.
y: Vertical position, in the input video, of the top edge of the output video. It defaults to (in_h-out_h)/2. This expression is evaluated per-frame.