@@ -13,12 +13,12 @@ import (
1313 "github.com/aws/aws-sdk-go/service/s3/s3manager"
1414)
1515
16- // Input file URL (ffmpeg ``-i`` option)
16+ // Input file URL (ffmpeg “-i“ option)
1717//
18- // Any supplied kwargs are passed to ffmpeg verbatim (e.g. `` t=20`` ,
19- // `` f='mp4'``, `` acodec='pcm'`` , etc.).
18+ // Any supplied kwargs are passed to ffmpeg verbatim (e.g. “ t=20“ ,
19+ // “ f='mp4'“, “ acodec='pcm'“ , etc.).
2020//
21- // To tell ffmpeg to read from stdin, use `` pipe:`` as the filename.
21+ // To tell ffmpeg to read from stdin, use “ pipe:“ as the filename.
2222//
2323// Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`__
2424func Input (filename string , kwargs ... KwArgs ) * Stream {
@@ -33,15 +33,15 @@ func Input(filename string, kwargs ...KwArgs) *Stream {
3333 return NewInputNode ("input" , nil , args ).Stream ("" , "" )
3434}
3535
36- // Add extra global command-line argument(s), e.g. `` -progress`` .
36+ // Add extra global command-line argument(s), e.g. “ -progress“ .
3737func (s * Stream ) GlobalArgs (args ... string ) * Stream {
3838 if s .Type != "OutputStream" {
3939 panic ("cannot overwrite outputs on non-OutputStream" )
4040 }
4141 return NewGlobalNode ("global_args" , []* Stream {s }, args , nil ).Stream ("" , "" )
4242}
4343
44- // Overwrite output files without asking (ffmpeg ``-y`` option)
44+ // Overwrite output files without asking (ffmpeg “-y“ option)
4545//
4646// Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`_
4747func (s * Stream ) OverwriteOutput (stream * Stream ) * Stream {
@@ -56,28 +56,28 @@ func MergeOutputs(streams ...*Stream) *Stream {
5656 return NewMergeOutputsNode ("merge_output" , streams ).Stream ("" , "" )
5757}
5858
59- //Output file URL
59+ // Output file URL
6060//
61- // Syntax:
62- // `ffmpeg.Output([]*Stream{stream1, stream2, stream3...}, filename, kwargs)`
61+ // Syntax:
62+ // `ffmpeg.Output([]*Stream{stream1, stream2, stream3...}, filename, kwargs)`
6363//
64- // Any supplied keyword arguments are passed to ffmpeg verbatim (e.g.
65- // ``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``,
66- // etc.). Some keyword-arguments are handled specially, as shown below.
64+ // Any supplied keyword arguments are passed to ffmpeg verbatim (e.g.
65+ // ``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``,
66+ // etc.). Some keyword-arguments are handled specially, as shown below.
6767//
68- // Args:
69- // video_bitrate: parameter for ``-b:v``, e.g. ``video_bitrate=1000``.
70- // audio_bitrate: parameter for ``-b:a``, e.g. ``audio_bitrate=200``.
71- // format: alias for ``-f`` parameter, e.g. ``format='mp4'``
72- // (equivalent to ``f='mp4'``).
68+ // Args:
69+ // video_bitrate: parameter for ``-b:v``, e.g. ``video_bitrate=1000``.
70+ // audio_bitrate: parameter for ``-b:a``, e.g. ``audio_bitrate=200``.
71+ // format: alias for ``-f`` parameter, e.g. ``format='mp4'``
72+ // (equivalent to ``f='mp4'``).
7373//
74- // If multiple streams are provided, they are mapped to the same
75- // output.
74+ // If multiple streams are provided, they are mapped to the same
75+ // output.
7676//
77- // To tell ffmpeg to write to stdout, use ``pipe:`` as the filename.
77+ // To tell ffmpeg to write to stdout, use ``pipe:`` as the filename.
7878//
79- // Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__
80- // """
79+ // Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__
80+ // """
8181func Output (streams []* Stream , fileName string , kwargs ... KwArgs ) * Stream {
8282 args := MergeKwArgs (kwargs )
8383 if ! args .HasKey ("filename" ) {
@@ -90,14 +90,42 @@ func Output(streams []*Stream, fileName string, kwargs ...KwArgs) *Stream {
9090 return NewOutputNode ("output" , streams , nil , args ).Stream ("" , "" )
9191}
9292
93+ // Output file URL
94+ //
95+ // Syntax:
96+ // `ffmpeg.Output(ctx, []*Stream{stream1, stream2, stream3...}, filename, kwargs)`
97+ //
98+ // Any supplied keyword arguments are passed to ffmpeg verbatim (e.g.
99+ // ``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``,
100+ // etc.). Some keyword-arguments are handled specially, as shown below.
101+ //
102+ // Args:
103+ // video_bitrate: parameter for ``-b:v``, e.g. ``video_bitrate=1000``.
104+ // audio_bitrate: parameter for ``-b:a``, e.g. ``audio_bitrate=200``.
105+ // format: alias for ``-f`` parameter, e.g. ``format='mp4'``
106+ // (equivalent to ``f='mp4'``).
107+ //
108+ // If multiple streams are provided, they are mapped to the same
109+ // output.
110+ //
111+ // To tell ffmpeg to write to stdout, use ``pipe:`` as the filename.
112+ //
113+ // Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__
114+ // """
115+ func OutputContext (ctx context.Context , streams []* Stream , fileName string , kwargs ... KwArgs ) * Stream {
116+ output := Output (streams , fileName , kwargs ... )
117+ output .Context = ctx
118+ return output
119+ }
120+
93121func (s * Stream ) Output (fileName string , kwargs ... KwArgs ) * Stream {
94122 if s .Type != "FilterableStream" {
95123 log .Panic ("cannot output on non-FilterableStream" )
96124 }
97125 if strings .HasPrefix (fileName , "s3://" ) {
98126 return s .outputS3Stream (fileName , kwargs ... )
99127 }
100- return Output ( []* Stream {s }, fileName , kwargs ... )
128+ return OutputContext ( s . Context , []* Stream {s }, fileName , kwargs ... )
101129}
102130
103131func (s * Stream ) outputS3Stream (fileName string , kwargs ... KwArgs ) * Stream {
0 commit comments