phoboslab преди 9 години
родител
ревизия
b20cf1a767
променени са 1 файла, в които са добавени 10 реда и са изтрити 10 реда
  1. 10 10
      README.md

+ 10 - 10
README.md Целия файл

1
 # JSMpeg – MPEG1 Video & MP2 Audio Decoder in JavaScript
1
 # JSMpeg – MPEG1 Video & MP2 Audio Decoder in JavaScript
2
 
2
 
3
-JSMpeg is a Video Player written in JavaScript. It consists of an MPEG-TS demuxer, MPEG1 video & MP2 audio decoders, WebGL & Canvas2D renderers and WebAudio sound output. JSMpeg can load static videos via Ajax and allows low latency streaming (~75ms) via WebSocktes.
3
+JSMpeg is a Video Player written in JavaScript. It consists of an MPEG-TS demuxer, MPEG1 video & MP2 audio decoders, WebGL & Canvas2D renderers and WebAudio sound output. JSMpeg can load static videos via Ajax and allows low latency streaming (~50ms) via WebSocktes.
4
 
4
 
5
 JSMpeg can decode 720p Video at 30fps on an iPhone 5S, works in any modern browser (Chrome, Firefox, Safari, Edge) and comes in at just 20kb gzipped.
5
 JSMpeg can decode 720p Video at 30fps on an iPhone 5S, works in any modern browser (Chrome, Firefox, Safari, Edge) and comes in at just 20kb gzipped.
6
 
6
 
43
 - `disableGl` - whether to disable WebGL and always use the Canvas2D renderer. Default `false`.
43
 - `disableGl` - whether to disable WebGL and always use the Canvas2D renderer. Default `false`.
44
 - `preserveDrawingBuffer` – whether the WebGL context is created with `preserveDrawingBuffer` - necessary for "screenshots" via `canvas.toDataURL()`. Default `false`.
44
 - `preserveDrawingBuffer` – whether the WebGL context is created with `preserveDrawingBuffer` - necessary for "screenshots" via `canvas.toDataURL()`. Default `false`.
45
 - `progressive` - whether to load data in chunks (static files only). When enabled, playback can begin before the whole source has been completely loaded. Default `true`.
45
 - `progressive` - whether to load data in chunks (static files only). When enabled, playback can begin before the whole source has been completely loaded. Default `true`.
46
-- `throttled` - when using `progressive`, whether to defer loading chunks when they're not needed for playback yet. Default `true`
46
+- `throttled` - when using `progressive`, whether to defer loading chunks when they're not needed for playback yet. Default `true`.
47
 - `chunkSize` - when using `progressive`, the chunk size in bytes to load at a time. Default `1024*1024` (1mb).
47
 - `chunkSize` - when using `progressive`, the chunk size in bytes to load at a time. Default `1024*1024` (1mb).
48
 - `decodeFirstFrame` - whether to decode and display the first frame of the video. Useful to set up the Canvas size and use the frame as the "poster" image. This has no effect when using `autoplay` or streaming sources. Default `true`.
48
 - `decodeFirstFrame` - whether to decode and display the first frame of the video. Useful to set up the Canvas size and use the frame as the "poster" image. This has no effect when using `autoplay` or streaming sources. Default `true`.
49
 - `maxAudioLag` – when streaming, the maximum enqueued audio length in seconds.
49
 - `maxAudioLag` – when streaming, the maximum enqueued audio length in seconds.
112
 
112
 
113
 The internal buffers for video and audio are fairly small (512kb and 128kb respectively) and JSMpeg will discard old (even unplayed) data to make room for newly arriving data without much fuzz. This could introduce decoding artifacts when there's a network congestion, but ensures that latency is kept at a minimum. If necessary You can increase the `videoBufferSize` and `audioBufferSize` through the options.
113
 The internal buffers for video and audio are fairly small (512kb and 128kb respectively) and JSMpeg will discard old (even unplayed) data to make room for newly arriving data without much fuzz. This could introduce decoding artifacts when there's a network congestion, but ensures that latency is kept at a minimum. If necessary You can increase the `videoBufferSize` and `audioBufferSize` through the options.
114
 
114
 
115
-JSMpeg comes with a tiny WebSocket "relay", written in Node.js. This server accepts an MPEG-TS source over HTTP and serves it via WebSocket to all connecting Browsers. The incoming HTTP stream can be generated using [ffmpeg](https://ffmpeg.org/), gstreamer or by other means.
115
+JSMpeg comes with a tiny WebSocket "relay", written in Node.js. This server accepts an MPEG-TS source over HTTP and serves it via WebSocket to all connecting Browsers. The incoming HTTP stream can be generated using [ffmpeg](https://ffmpeg.org/), [gstreamer](https://gstreamer.freedesktop.org/) or by other means.
116
 
116
 
117
 The split between the source and the WebSocket relay is necessary, because ffmpeg doesn't speak the WebSocket protocol. However, this split also allows you to install the WebSocket relay on a public server and share your stream on the Internet (typically NAT in your router prevents the public Internet from connecting _into_ your local network).
117
 The split between the source and the WebSocket relay is necessary, because ffmpeg doesn't speak the WebSocket protocol. However, this split also allows you to install the WebSocket relay on a public server and share your stream on the Internet (typically NAT in your router prevents the public Internet from connecting _into_ your local network).
118
 
118
 
119
 In short, it works like this:
119
 In short, it works like this:
120
 
120
 
121
-1) run the websocket-relay.js
122
-2) run ffmpeg, send output to the relay's HTTP port
123
-3) connect JSMpeg in the browser to the relay's Websocket port
121
+1. run the websocket-relay.js
122
+2. run ffmpeg, send output to the relay's HTTP port
123
+3. connect JSMpeg in the browser to the relay's Websocket port
124
 
124
 
125
 
125
 
126
 ## Example Setup for Streaming: Raspberry Pi Live Webcam
126
 ## Example Setup for Streaming: Raspberry Pi Live Webcam
158
 9) Open the streaming website in your browser. The `http-server` will tell you the ip (usually `192.168.[...]`) and port (usually `8080`) where it's running on:
158
 9) Open the streaming website in your browser. The `http-server` will tell you the ip (usually `192.168.[...]`) and port (usually `8080`) where it's running on:
159
 `http://192.168.[...]:8080/view-stream.html`
159
 `http://192.168.[...]:8080/view-stream.html`
160
 
160
 
161
-10) In a third terminal window, start ffmpeg to capture the webcam video and send it to the Websocket relay. Provide the password and port (from step 8) in the destination URL:
161
+10) In a third terminal window, start ffmpeg to capture the webcam video and send it to the Websocket relay. Provide the password and port (from step 7) in the destination URL:
162
 ```
162
 ```
163
 ffmpeg \
163
 ffmpeg \
164
 	-f v4l2 \
164
 	-f v4l2 \
182
 	-f v4l2 \
182
 	-f v4l2 \
183
 		-framerate 25 -video_size 640x480 -i /dev/video0 \
183
 		-framerate 25 -video_size 640x480 -i /dev/video0 \
184
 	-f alsa \
184
 	-f alsa \
185
-		-ar 44100 -c 2 -i -i hw:0 \
185
+		-ar 44100 -c 2 -i hw:0 \
186
 	-f mpegts \
186
 	-f mpegts \
187
 		-codec:v mpeg1video -s 640x480 -b:v 1000k -bf 0 \
187
 		-codec:v mpeg1video -s 640x480 -b:v 1000k -bf 0 \
188
 		-codec:a mp2 -b:a 128k \
188
 		-codec:a mp2 -b:a 128k \
190
 	http://localhost:8081/supersecret
190
 	http://localhost:8081/supersecret
191
 ```
191
 ```
192
 
192
 
193
-Note the `muxdelay` argument. This should reduce lag, but doesn't always work when streaming video and audio - see remarks below.:
193
+Note the `muxdelay` argument. This should reduce lag, but doesn't always work when streaming video and audio - see remarks below.
194
 
194
 
195
 
195
 
196
 ## Some remarks about ffmpeg muxing and latency
196
 ## Some remarks about ffmpeg muxing and latency
209
 # In a second terminal
209
 # In a second terminal
210
 ffmpeg \
210
 ffmpeg \
211
 	-f alsa \
211
 	-f alsa \
212
-		-ar 44100 -c 2 -i -i hw:0 \
212
+		-ar 44100 -c 2 -i hw:0 \
213
 	-f mpegts \
213
 	-f mpegts \
214
 		-codec:a mp2 -b:a 128k \
214
 		-codec:a mp2 -b:a 128k \
215
 		-muxdelay 0.001 \
215
 		-muxdelay 0.001 \