diff --git a/index.html b/index.html index 5c6edb7..3c5f100 100644 --- a/index.html +++ b/index.html @@ -1907,203 +1907,203 @@ - -
-

Other

- - - - -
-

Play an image sequence

-

Play an image sequence directly as moving images, without having to create a video first.

-

ffplay -framerate 5 input_file_%06d.ext

-
-
ffplay
starts the command
-
-framerate 5
plays image sequence at rate of 5 images per second
- Note: this low framerate will produce a slideshow effect.
-
-i input_file
path, name and extension of the input file
- This must match the naming convention used! The regex %06d matches six-digit-long numbers, possibly with leading zeroes. This allows the full sequence to be read in ascending order, one image after the other.
- The extension for TIFF files is .tif or maybe .tiff; the extension for DPX files is .dpx (or even .cin for old files). Screenshots are often in .png format.
-
-

Notes:

-

If -framerate is omitted, the playback speed depends on the images’ file sizes and on the computer’s processing power. It may be rather slow for large image files.

-

You can navigate durationally by clicking within the playback window. Clicking towards the left-hand side of the playback window takes you towards the beginning of the playback sequence; clicking towards the right takes you towards the end of the sequence.

-
- +
+

Other

- - - -
-

Split audio and video tracks

-

ffmpeg -i input_file -map 0:v:0 video_output_file -map 0:a:0 audio_output_file

-

This command splits the original input file into a video and audio stream. The -map command identifies which streams are mapped to which file. To ensure that you’re mapping the right streams to the right file, run ffprobe before writing the script to identify which streams are desired.

-
-
ffmpeg
starts the command
-
-i input_file
path, name and extension of the input file
-
-map 0:v:0
grabs the first video stream and maps it into:
-
video_output_file
path, name and extension of the video output file
-
-map 0:a:0
grabs the first audio stream and maps it into:
-
audio_output_file
path, name and extension of the audio output file
-
- + + + +
+

Play an image sequence

+

Play an image sequence directly as moving images, without having to create a video first.

+

ffplay -framerate 5 input_file_%06d.ext

+
+
ffplay
starts the command
+
-framerate 5
plays image sequence at rate of 5 images per second
+ Note: this low framerate will produce a slideshow effect.
+
-i input_file
path, name and extension of the input file
+ This must match the naming convention used! The regex %06d matches six-digit-long numbers, possibly with leading zeroes. This allows the full sequence to be read in ascending order, one image after the other.
+ The extension for TIFF files is .tif or maybe .tiff; the extension for DPX files is .dpx (or even .cin for old files). Screenshots are often in .png format.
+
+

Notes:

+

If -framerate is omitted, the playback speed depends on the images’ file sizes and on the computer’s processing power. It may be rather slow for large image files.

+

You can navigate durationally by clicking within the playback window. Clicking towards the left-hand side of the playback window takes you towards the beginning of the playback sequence; clicking towards the right takes you towards the end of the sequence.

+ +
+ + + + + +
+

Split audio and video tracks

+

ffmpeg -i input_file -map 0:v:0 video_output_file -map 0:a:0 audio_output_file

+

This command splits the original input file into a video and audio stream. The -map command identifies which streams are mapped to which file. To ensure that you’re mapping the right streams to the right file, run ffprobe before writing the script to identify which streams are desired.

+
+
ffmpeg
starts the command
+
-i input_file
path, name and extension of the input file
+
-map 0:v:0
grabs the first video stream and maps it into:
+
video_output_file
path, name and extension of the video output file
+
-map 0:a:0
grabs the first audio stream and maps it into:
+
audio_output_file
path, name and extension of the audio output file
+
+ +
+ + + + + +
+

Create ISO files for DVD access

+

Create an ISO file that can be used to burn a DVD. Please note, you will have to install dvdauthor. To install dvd author using Homebrew run: brew install dvdauthor

+

ffmpeg -i input_file -aspect 4:3 -target ntsc-dvd output_file.mpg

+

This command will take any file and create an MPEG file that dvdauthor can use to create an ISO.

+
+
ffmpeg
starts the command
+
-i input_file
path, name and extension of the input file
+
-aspect 4:3
declares the aspect ratio of the resulting video file. You can also use 16:9.
+
-target ntsc-dvd
specifies the region for your DVD. This could be also pal-dvd.
+
output_file.mpg
path and name of the output file. The extension must be .mpg
+
+ +
+ + + + + +
+

Exports CSV for scene detection using YDIF

+

ffprobe -f lavfi -i movie=input_file,signalstats -show_entries frame=pkt_pts_time:frame_tags=lavfi.signalstats.YDIF -of csv

+

This ffprobe command prints a CSV correlating timestamps and their YDIF values, useful for determining cuts.

+
+
ffprobe
starts the command
+
-f lavfi
uses the Libavfilter input virtual device as chosen format
+
-i movie=input file
path, name and extension of the input video file
+
,
comma signifies closing of video source assertion and ready for filter assertion
+
signalstats
tells ffprobe to use the signalstats command
+
-show_entries
sets list of entries to show per column, determined on the next line
+
frame=pkt_pts_time:frame_tags=lavfi.signalstats.YDIF
specifies showing the timecode (pkt_pts_time) in the frame stream and the YDIF section of the frame_tags stream
+
-of csv
sets the output printing format to CSV. -of is an alias of -print_format.
+
+ +
+ + + + + +
+

Cover head switching noise

+

ffmpeg -i input_file -filter:v drawbox=w=iw:h=7:y=ih-h:t=max output_file

+

This command will draw a black box over a small area of the bottom of the frame, which can be used to cover up head switching noise.

+
+
ffmpeg
starts the command
+
-i input_file
path, name and extension of the input file
+
-filter:v drawbox=
+
This calls the drawtext filter with the following options: +
+
w=in_w
Width is set to the input width. Shorthand for this command would be w=iw
+
h=7
Height is set to 7 pixels.
+
y=ih-h
Y represents the offset, and ih-h sets it to the input height minus the height declared in the previous parameter, setting the box at the bottom of the frame.
+
t=max
T represents the thickness of the drawn box. Default is 3.
+
+
+
output_file
path and name of the output file
+
+ +
+ + + + + +
+

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.)

+

Notes

+
    +
  1. I recommend to use this inside a shell script - then you can define the variables ${INPUTFILE}, ${STREAMDURATION}, ${TARGETFILE}, and ${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. +
+
+
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 4:2:0 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 as H.264
+
-c:a aac
encode output audio stream as 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 outputs, separated by a pipe (|). The first is the local file, the second is the live stream. Options for each target are given in square brackets before the target.
+
+ +
+ + + + + +
+

View information about a specific decoder, encoder, demuxer, muxer, or filter

+

ffmpeg -h type=name

+
+
ffmpeg
starts the command
+
-h
Call the help option
+
type=name
+
tells FFmpeg which kind of option you want, for example: +
    +
  • encoder=libx264
  • +
  • decoder=mp3
  • +
  • muxer=matroska
  • +
  • demuxer=mov
  • +
  • filter=crop
  • +
+
+
+ +
+
- +
- - - -
-

Create ISO files for DVD access

-

Create an ISO file that can be used to burn a DVD. Please note, you will have to install dvdauthor. To install dvd author using Homebrew run: brew install dvdauthor

-

ffmpeg -i input_file -aspect 4:3 -target ntsc-dvd output_file.mpg

-

This command will take any file and create an MPEG file that dvdauthor can use to create an ISO.

-
-
ffmpeg
starts the command
-
-i input_file
path, name and extension of the input file
-
-aspect 4:3
declares the aspect ratio of the resulting video file. You can also use 16:9.
-
-target ntsc-dvd
specifies the region for your DVD. This could be also pal-dvd.
-
output_file.mpg
path and name of the output file. The extension must be .mpg
-
- -
- + + + - - - -
-

Exports CSV for scene detection using YDIF

-

ffprobe -f lavfi -i movie=input_file,signalstats -show_entries frame=pkt_pts_time:frame_tags=lavfi.signalstats.YDIF -of csv

-

This ffprobe command prints a CSV correlating timestamps and their YDIF values, useful for determining cuts.

-
-
ffprobe
starts the command
-
-f lavfi
uses the Libavfilter input virtual device as chosen format
-
-i movie=input file
path, name and extension of the input video file
-
,
comma signifies closing of video source assertion and ready for filter assertion
-
signalstats
tells ffprobe to use the signalstats command
-
-show_entries
sets list of entries to show per column, determined on the next line
-
frame=pkt_pts_time:frame_tags=lavfi.signalstats.YDIF
specifies showing the timecode (pkt_pts_time) in the frame stream and the YDIF section of the frame_tags stream
-
-of csv
sets the output printing format to CSV. -of is an alias of -print_format.
-
- -
- - - - - -
-

Cover head switching noise

-

ffmpeg -i input_file -filter:v drawbox=w=iw:h=7:y=ih-h:t=max output_file

-

This command will draw a black box over a small area of the bottom of the frame, which can be used to cover up head switching noise.

-
-
ffmpeg
starts the command
-
-i input_file
path, name and extension of the input file
-
-filter:v drawbox=
-
This calls the drawtext filter with the following options: -
-
w=in_w
Width is set to the input width. Shorthand for this command would be w=iw
-
h=7
Height is set to 7 pixels.
-
y=ih-h
Y represents the offset, and ih-h sets it to the input height minus the height declared in the previous parameter, setting the box at the bottom of the frame.
-
t=max
T represents the thickness of the drawn box. Default is 3.
-
-
-
output_file
path and name of the output file
-
- -
- - - - - -
-

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.)

-

Notes

-
    -
  1. I recommend to use this inside a shell script - then you can define the variables ${INPUTFILE}, ${STREAMDURATION}, ${TARGETFILE}, and ${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. -
-
-
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 4:2:0 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 as H.264
-
-c:a aac
encode output audio stream as 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 outputs, separated by a pipe (|). The first is the local file, the second is the live stream. Options for each target are given in square brackets before the target.
-
- -
- - - - - -
-

View information about a specific decoder, encoder, demuxer, muxer, or filter

-

ffmpeg -h type=name

-
-
ffmpeg
starts the command
-
-h
Call the help option
-
type=name
-
tells FFmpeg which kind of option you want, for example: -
    -
  • encoder=libx264
  • -
  • decoder=mp3
  • -
  • muxer=matroska
  • -
  • demuxer=mov
  • -
  • filter=crop
  • -
-
-
- -
- -
- - - - - - - - + +