From 0c9086d70d8975fa73652cafe8d2a8e7518df3d4 Mon Sep 17 00:00:00 2001 From: Basti Becker Date: Thu, 12 Oct 2017 12:49:35 +0200 Subject: [PATCH] Update requested changes Fix HTML, some typos and improve some explanations. Thanks for review. --- index.html | 57 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index 0ffe50e..8aeba52 100644 --- a/index.html +++ b/index.html @@ -141,35 +141,36 @@

Record and Live-Stream simultaneously

ffmpeg -re -i ${INPUTFILE} -map 0 -flags +global_header -vf scale="1280:-1,format=yuv420p" -pix_fmt yuv420p -level 3.1 -vsync passthrough -crf 26 -g 50 -bufsize 3500k -maxrate 1800k -c:v libx264 -c:a aac -b:a 128000 -r:a 44100 -ac 2 -t ${STREAMDURATION} -f tee "[movflags=+faststart]${TARGETFILE}|[f=flv]${STREAMTARGET}"

- I use this script to stream to a RTMP target and record the stream locally as .mp4 with only one ffmpeg-instance.
- As input, I use bmdcapture which is piped to ffmpeg. But it can also be used with a static videofile as input.
- The input will be scaled to 1280px width, maintaining height. Also the stream will stop after a given time (see -t option.)

-

Note 1
- I recommend to use this inside a shell script. then you can define the variables ${INPUTFILE}, ${STREAMDURATION}, ${TARGETFILE}, ${STREAMTARGET}.

-

Note 2
- This is in daily use to live-stream a real-world TV show. No errors for nearly 4 years. Some parameters were found by trial-and-error or empiric testing. So suggestions / questions are welcome.

+

I use this script to stream to a RTMP target and record the stream locally as .mp4 with only one ffmpeg-instance.

+

As input, I use bmdcapture which is piped to ffmpeg. But it can also be used with a static videofile as input.

+

The input will be scaled to 1280px width, maintaining height. Also the stream will stop after a given time (see -t option.)

+

Notes

+
    +
  1. I recommend to use this inside a shell script. then you can define the variables ${INPUTFILE}, ${STREAMDURATION}, ${TARGETFILE}, ${STREAMTARGET}.
  2. +
  3. This is in daily use to live-stream a real-world TV show. No errors for nearly 4 years. Some parameters were found by trial-and-error or empiric testing. So suggestions / questions are welcome.
  4. +
-
/usr/local/bin/ffmpeg
starts the command
-
-re
Read input at native framerate
-
-i input.mov
The input file. Can also be a - to use STDIN if you pipe in from webcam or SDI.
-
-map 0
map ALL streams from input file to output
-
-flags +global_header
Dont place extradata in every keyframe
-
-vf scale="1280:-1"
Scale to 1280 width, maintain aspect ratio.
-
-pix_fmt yuv420p
convert to 420p color space
-
-level 3.1
H264 Level (defines some thresholds for bitrate)
-
-vsync passthrough
Each frame is passed with its timestamp from the demuxer to the muxer.
-
-crf 26
Constant rate factor - basically the quality
-
-g 50
GOP size.
-
-bufsize 3500k
Ratecontrol buffer size (~ maxrate x2)
-
-maxrate 1800k
Maximum bit rate
-
-c:v libx264
The video codec
-
-c:a aac
The audio codec
-
-b:a 128000
The audio bitrate
-
-r:a 44100
The audio samplerate
-
-ac 2
Two audio channels
-
-t ${STREAMDURATION}
Time (in seconds) after which the stream should automatically end.
-
-f tee
Use multiple outputs. Outputs defined below.
-
"[movflags=+faststart]target-file.mp4|[f=flv]rtmp://stream-url/stream-id"
The output divided by pipe (|). First is local file. Second is Live Stream. Options for each target in square brackets before the target.
+
ffmpeg
starts the command
+
-re
Read input at native framerate
+
-i input.mov
The input file. Can also be a - to use STDIN if you pipe in from webcam or SDI.
+
-map 0
map ALL streams from input file to output
+
-flags +global_header
Don't place extra data in every keyframe
+
-vf scale="1280:-1"
Scale to 1280 width, maintain aspect ratio.
+
-pix_fmt yuv420p
convert to 420p chroma subsampling scheme
+
-level 3.1
H264 Level (defines some thresholds for bitrate)
+
-vsync passthrough
Each frame is passed with its timestamp from the demuxer to the muxer.
+
-crf 26
Constant rate factor - basically the quality
+
-g 50
GOP size.
+
-bufsize 3500k
Ratecontrol buffer size (~ maxrate x2)
+
-maxrate 1800k
Maximum bit rate
+
-c:v libx264
encode output video stream using H.264
+
-c:a aac
encode output audio stream using AAC
+
-b:a 128000
The audio bitrate
+
-r:a 44100
The audio samplerate
+
-ac 2
Two audio channels
+
-t ${STREAMDURATION}
Time (in seconds) after which the stream should automatically end.
+
-f tee
Use multiple outputs. Outputs defined below.
+
"[movflags=+faststart]target-file.mp4|[f=flv]rtmp://stream-url/stream-id"
The output divided by pipe (|). First is local file. Second is Live Stream. Options for each target in square brackets before the target.