Documentation
¶
Index ¶
- Variables
- func BitrateToKilobit(bitrate string) int64
- func ExecutableFallback(file string) (string, error)
- func KillOnGlyphNotFoundLine(next commandline.Handler) commandline.Handler
- func KillOnNotOverwritingLine(next commandline.Handler) commandline.Handler
- func KillOnReplacedMissingFontLine(next commandline.Handler) commandline.Handler
- func KilobitToBitrate(kilobit int64) string
- func Printer() commandline.Handler
- type Filter
- type Transcoder
- func NewFragmentedMp4Transcoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
- func NewMp4Transcoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
- func NewSampleMp4Transcoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
- func NewTranscoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
- func (t *Transcoder) AttachmentCopy()
- func (t *Transcoder) AudioBitrate(b string)
- func (t *Transcoder) AudioChannels(c string)
- func (t *Transcoder) AudioCodec(c string)
- func (t *Transcoder) Duration(d time.Duration)
- func (t *Transcoder) Filter(f Filter)
- func (t Transcoder) FirstPass() *exec.Cmd
- func (t *Transcoder) HlsFlags(f string)
- func (t *Transcoder) HlsListSize(ls uint)
- func (t *Transcoder) HlsSegmentType(st string)
- func (t *Transcoder) HlsTime(d time.Duration)
- func (t *Transcoder) Map(v string)
- func (t *Transcoder) OutDir() string
- func (t *Transcoder) PixelFormat(pf string)
- func (t *Transcoder) Preset(p string)
- func (t Transcoder) SecondPass() *exec.Cmd
- func (t *Transcoder) Seek(p time.Duration)
- func (t *Transcoder) SkipSubtitleStream()
- func (t *Transcoder) SubtitleCodec(c string)
- func (t *Transcoder) Tune(tune string)
- func (t *Transcoder) VideoBitrate(b string)
- func (t *Transcoder) VideoCodec(c string)
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnknownBinary = errors.New("unknown binary name provided")
)
Functions ¶
func BitrateToKilobit ¶
func ExecutableFallback ¶
func KillOnGlyphNotFoundLine ¶
func KillOnGlyphNotFoundLine(next commandline.Handler) commandline.Handler
KillOnGlyphNotFoundLine detects Glyph not found errors in the ffmpeg output. When the error happens stops propagation.
func KillOnNotOverwritingLine ¶
func KillOnNotOverwritingLine(next commandline.Handler) commandline.Handler
KillOnNotOverwritingLine overwriting errors in the ffmpeg output. When the error happens stops propagation.
func KillOnReplacedMissingFontLine ¶
func KillOnReplacedMissingFontLine(next commandline.Handler) commandline.Handler
KillOnNotOverwritingLine overwriting errors in the ffmpeg output. When the error happens stops propagation.
func KilobitToBitrate ¶
func Printer ¶
func Printer() commandline.Handler
Types ¶
type Filter ¶
type Transcoder ¶
type Transcoder struct {
// contains filtered or unexported fields
}
func NewFragmentedMp4Transcoder ¶
func NewFragmentedMp4Transcoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
NewFragmentedMp4Transcoder builds a Transcoder for fragmented mp4 with preset data
func NewMp4Transcoder ¶
func NewMp4Transcoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
NewMp4Transcoder builds a Transcoder for mp4 with preset data
func NewSampleMp4Transcoder ¶
func NewSampleMp4Transcoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
NewSampleMp4Transcoder builds a Transcoder for fragmented mp4 with preset data
func NewTranscoder ¶
func NewTranscoder(executable, input, outDir, bitrate string, f Filter) *Transcoder
NewTranscoder builds a Transcoder for fragmented mp4 with preset data
func (*Transcoder) AttachmentCopy ¶
func (t *Transcoder) AttachmentCopy()
AttachmentCopy copies all attachment streams to the output
func (*Transcoder) AudioBitrate ¶
func (t *Transcoder) AudioBitrate(b string)
AudioBitrate sets the bitrate for all audio streams
func (*Transcoder) AudioChannels ¶
func (t *Transcoder) AudioChannels(c string)
AudioChannels downmux the output channels to the specified value.
func (*Transcoder) AudioCodec ¶
func (t *Transcoder) AudioCodec(c string)
AudioCodec sets the codec for all audio streams
func (*Transcoder) Duration ¶
func (t *Transcoder) Duration(d time.Duration)
Duration sets the `-t` option for the encoding
When used as an input option (before `-i`), limit the duration of data read from the input file.
When used as an output option (before an output url), stop writing the output after its duration reaches duration.
func (*Transcoder) Filter ¶
func (t *Transcoder) Filter(f Filter)
func (Transcoder) FirstPass ¶
func (t Transcoder) FirstPass() *exec.Cmd
func (*Transcoder) HlsFlags ¶
func (t *Transcoder) HlsFlags(f string)
HlsFlags sets the `-hls_flags` option for the encoding
Possible values:
`single_file` If this flag is set, the muxer will store all segments in a single MPEG-TS file, and will use byte ranges in the playlist. HLS playlists generated with this way will have the version number 4. For example:
``` ffmpeg -i in.nut -hls_flags single_file out.m3u8 ``` Will produce the playlist, out.m3u8, and a single segment file, out.ts.
`delete_segments` Segment files removed from the playlist are deleted after a period of time equal to the duration of the segment plus the duration of the playlist.
`append_list` Append new segments into the end of old segment list, and remove the `#EXT-X-ENDLIST` from the old segment list.
`round_durations` Round the duration info in the playlist file segment info to integer values, instead of using floating point.
`discont_start` Add the `#EXT-X-DISCONTINUITY` tag to the playlist, before the first segment`s information.
`omit_endlist` Do not append the EXT-X-ENDLIST tag at the end of the playlist.
`periodic_rekey` The file specified by hls_key_info_file will be checked periodically and detect updates to the encryption info. Be sure to replace this file atomically, including the file containing the AES encryption key.
`independent_segments` Add the `#EXT-X-INDEPENDENT-SEGMENTS` to playlists that has video segments and when all the segments of that playlist are guaranteed to start with a Key frame.
`iframes_only` Add the `#EXT-X-I-FRAMES-ONLY` to playlists that has video segments and can play only I-frames in the `#EXT-X-BYTERANGE` mode.
`split_by_time` Allow segments to start on frames other than keyframes. This improves behavior on some players when the time between keyframes is inconsistent, but may make things worse on others, and can cause some oddities during seeking. This flag should be used with the hls_time option.
`program_date_time` Generate EXT-X-PROGRAM-DATE-TIME tags.
`second_level_segment_index` Makes it possible to use segment indexes as %%d in hls_segment_filename expression besides date/time values when strftime is on. To get fixed width numbers with trailing zeroes, %%0xd format is available where x is the required width.
`second_level_segment_size` Makes it possible to use segment sizes (counted in bytes) as %%s in hls_segment_filename expression besides date/time values when strftime is on. To get fixed width numbers with trailing zeroes, %%0xs format is available where x is the required width.
`second_level_segment_duration` Makes it possible to use segment duration (calculated in microseconds) as %%t in hls_segment_filename expression besides date/time values when strftime is on. To get fixed width numbers with trailing zeroes, %%0xt format is available where x is the required width.
```
ffmpeg -i sample.mpeg \ -f hls -hls_time 3 -hls_list_size 5 \ -hls_flags second_level_segment_index+second_level_segment_size+second_level_segment_duration \ -strftime 1 -strftime_mkdir 1 -hls_segment_filename "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8
``` This will produce segments like this: segment_20170102194334_0003_00122200_0000003000000.ts, segment_20170102194334_0004_00120072_0000003000000.ts etc.
`temp_file` Write segment data to filename.tmp and rename to filename only once the segment is complete. A webserver serving up segments can be configured to reject requests to *.tmp to prevent access to in-progress segments before they have been added to the m3u8 playlist. This flag also affects how m3u8 playlist files are created. If this flag is set, all playlist files will written into temporary file and renamed after they are complete, similarly as segments are handled. But playlists with file protocol and with type (hls_playlist_type) other than vod are always written into temporary file regardless of this flag. Master playlist files (master_pl_name), if any, with file protocol, are always written into temporary file regardless of this flag if master_pl_publish_rate value is other than zero.
func (*Transcoder) HlsListSize ¶
func (t *Transcoder) HlsListSize(ls uint)
HlsListSize sets the `-hls_list_size` option for the encoding
Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. Default value is 5.
func (*Transcoder) HlsSegmentType ¶
func (t *Transcoder) HlsSegmentType(st string)
HlsSegmentType sets the `-hls_segment` option for the encoding
Possible values:
`mpegts` Output segment files in MPEG-2 Transport Stream format. This is compatible with all HLS versions.
`fmp4` Output segment files in fragmented MP4 format, similar to MPEG-DASH. fmp4 files may be used in HLS version 7 and above.
func (*Transcoder) HlsTime ¶
func (t *Transcoder) HlsTime(d time.Duration)
HlsTime sets the `-hls_time` option for the encoding
Set the target segment length. Default value is 2. Segment will be cut on the next key frame after this time has passed.
func (*Transcoder) Map ¶
func (t *Transcoder) Map(v string)
Map maps specific streams to the target file
func (*Transcoder) OutDir ¶
func (t *Transcoder) OutDir() string
OutDir is the target directory of the output
func (*Transcoder) PixelFormat ¶
func (t *Transcoder) PixelFormat(pf string)
PixelFormat sets the pixel format for the encoding
func (*Transcoder) Preset ¶
func (t *Transcoder) Preset(p string)
Preset sets the preset value for the encoding
func (Transcoder) SecondPass ¶
func (t Transcoder) SecondPass() *exec.Cmd
func (*Transcoder) Seek ¶
func (t *Transcoder) Seek(p time.Duration)
Seek sets the `-ss` option for the encoding
When used as an input option (before `-i`), seeks in this input file to position. Note that in most formats it is not possible to seek exactly, so `ffmpeg` will seek to the closest seek point before position. When transcoding and -accurate_seek is enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when -noaccurate_seek is used, it will be preserved.
When used as an output option (before an output url), decodes but discards input until the timestamps reach position.
func (*Transcoder) SkipSubtitleStream ¶
func (t *Transcoder) SkipSubtitleStream()
SkipSubtitleStream sets a flag to skip inclusion of subtitle streams
func (*Transcoder) SubtitleCodec ¶
func (t *Transcoder) SubtitleCodec(c string)
SubtitleCodec sets the codec for all subtitle streams
func (*Transcoder) Tune ¶
func (t *Transcoder) Tune(tune string)
Tune sets the tune settings for the encoding
func (*Transcoder) VideoBitrate ¶
func (t *Transcoder) VideoBitrate(b string)
VideoBitrate sets the bitrate for all video streams
func (*Transcoder) VideoCodec ¶
func (t *Transcoder) VideoCodec(c string)
VideoCodec sets the codec for all video streams