Project

General

Profile

Feature #220 » camff.sh

Latest ffmpeg startup example - Hammel, 27 Aug 2013 08:46

 
1
#!/bin/sh
2
# Stream via ffmpeg, crtmpserver and jwplayer
3
# ---------------------------------------------------
4

    
5
myip=0.0.0.0
6
port=6666
7
width=320
8
height=240
9
fr=10
10

    
11
# Works with ffserver
12
# fr=25
13
# ffmpeg -f video4linux2 -s ${width}x${height} -r $fr -i /dev/video0 http://localhost:8090/webcam.ffm
14
# exit 0
15

    
16
# RTP Streaming with crtmpserver
17

    
18
# Test 1: good, but a bit behind (2-4 seconds)
19
# fr=25
20
# ffmpeg -f video4linux2 -s ${width}x${height} -r $fr -i /dev/video0 -intra -qscale 2 -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
21
# exit 0
22

    
23
# Test 2: Good quality and only slightly behind
24
# fr=30
25
# ffmpeg -f video4linux2 -s ${width}x${height} -r $fr -i /dev/video0 -f flv -qscale 2 -metadata streamName=myStream tcp://0.0.0.0:6666
26
	
27
# Test 3: very good - very small latency
28
# After reading http://trac.ffmpeg.org/wiki/StreamingGuide
29
# fr=30
30
#ffmpeg -f video4linux2 -s ${width}x${height} -r $fr \
31
#	-async 1 -ab 24k -ar 22050 -bufsize 3000k -maxrate 750k \
32
#	-i /dev/video0 -intra -qscale 2 -f flv \
33
#	-metadata streamName=myStream tcp://0.0.0.0:6666
34
	
35
# Test 4: not much improvement
36
# After reading http://trac.ffmpeg.org/wiki/StreamingGuide
37
# fr=25
38
# ffmpeg -f video4linux2 -s ${width}x${height} -r $fr \
39
# 	-b 1k -ac 0 \
40
# 	-async 1 -bufsize 3000k -maxrate 750k \
41
# 	-i /dev/video0 -qscale 2 -f flv \
42
# 	-metadata streamName=myStream tcp://0.0.0.0:6666
43
	
44
# Test 5: very stable, but has 5 second delay which builds from .5 second delay at start, then stabilizes at 5 sec.
45
# ffmpeg -f video4linux2 -s 320x240 -r 21 \
46
# 	-i /dev/video0 \
47
# 	-ac 0 -me_method zero \
48
#  	-qscale 2 \
49
# 	-s 320x240 -r 23\
50
#	-b 1250k -bufsize 2000k -maxrate 1750k \
51
#	-f flv -metadata streamName=myStream tcp://0.0.0.0:6666
52
# exit 0
53
	
54
# Test 6: crtmpserver example - doesn't work
55
# ffmpeg -f video4linux2 -s 320x240 -r 21 \
56
#	-i /dev/video0 \
57
#	-vcodec mpeg4 \
58
#	-b 500000 -s 320x180 -strict experimental -g 25 -me_method zero \
59
#	-acodec aac -ab 96000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb \
60
#	-f mpegts -metadata streamName=myStream tcp://0.0.0.0:9999
61
	
62
# Test 7: crtmpserver example: streams mpeg4 but it never reaches browser
63
# ffmpeg -f video4linux2 -s 320x240 -r 21 \
64
# 	-i /dev/video0 \
65
# 	-vcodec mpeg4 \
66
# 	-b 500000 -s 320x180 -strict experimental -g 25 -me_method zero \
67
# 	-f mpegts -metadata streamName=myStream udp://0.0.0.0:9999
68
# exit 0
69
	
70
# Test 8: Best
71
# ffmpeg -f video4linux2 -s 160x120 -r 25 \
72
# 	-i /dev/video0 \
73
# 	-ac 0 -me_method zero \
74
#	-qscale 1.25 \
75
#	-s 160x120 -r 25\
76
#	-b 1750k -bufsize 2000k -maxrate 2000k \
77
#	-f flv -metadata streamName=myStream tcp://0.0.0.0:6666
78
# exit 0
79

    
80
# Test 8: Best
81
ffmpeg -f video4linux2 -s 160x120 -r 25 \
82
	-i /dev/video0 \
83
	-ac 0 -me_method zero \
84
 	-qscale 1.1 \
85
	-s 160x120 -r 10\
86
	-b 1750k -bufsize 2000k -maxrate 2000k \
87
	-f flv -metadata streamName=myStream tcp://0.0.0.0:6666
88
exit 0
(3-3/5)