@@ -53,8 +53,8 @@ def __getitem__(self, index):
53
53
Process the audio and video portions of a stream independently::
54
54
55
55
input = ffmpeg.input('in.mp4')
56
- audio = input[: 'a'].filter("aecho", 0.8, 0.9, 1000, 0.3)
57
- video = input[: 'v'].hflip()
56
+ audio = input['a'].filter("aecho", 0.8, 0.9, 1000, 0.3)
57
+ video = input['v'].hflip()
58
58
out = ffmpeg.output(audio, video, 'out.mp4')
59
59
"""
60
60
if self .selector is not None :
@@ -63,6 +63,56 @@ def __getitem__(self, index):
63
63
raise TypeError ("Expected string index (e.g. 'a'); got {!r}" .format (index ))
64
64
return self .node .stream (label = self .label , selector = index )
65
65
66
+ @property
67
+ def audio (self ):
68
+ """Select the audio-portion of a stream.
69
+
70
+ Some ffmpeg filters drop audio streams, and care must be taken
71
+ to preserve the audio in the final output. The ``.audio`` and
72
+ ``.video`` operators can be used to reference the audio/video
73
+ portions of a stream so that they can be processed separately
74
+ and then re-combined later in the pipeline. This dilemma is
75
+ intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the
76
+ way while users may refer to the official ffmpeg documentation
77
+ as to why certain filters drop audio.
78
+
79
+ ``stream.audio`` is a shorthand for ``stream['a']``.
80
+
81
+ Example:
82
+ Process the audio and video portions of a stream independently::
83
+
84
+ input = ffmpeg.input('in.mp4')
85
+ audio = input.audio.filter("aecho", 0.8, 0.9, 1000, 0.3)
86
+ video = input.video.hflip()
87
+ out = ffmpeg.output(audio, video, 'out.mp4')
88
+ """
89
+ return self ['a' ]
90
+
91
+ @property
92
+ def video (self ):
93
+ """Select the video-portion of a stream.
94
+
95
+ Some ffmpeg filters drop audio streams, and care must be taken
96
+ to preserve the audio in the final output. The ``.audio`` and
97
+ ``.video`` operators can be used to reference the audio/video
98
+ portions of a stream so that they can be processed separately
99
+ and then re-combined later in the pipeline. This dilemma is
100
+ intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the
101
+ way while users may refer to the official ffmpeg documentation
102
+ as to why certain filters drop audio.
103
+
104
+ ``stream.video`` is a shorthand for ``stream['v']``.
105
+
106
+ Example:
107
+ Process the audio and video portions of a stream independently::
108
+
109
+ input = ffmpeg.input('in.mp4')
110
+ audio = input.audio.filter("aecho", 0.8, 0.9, 1000, 0.3)
111
+ video = input.video.hflip()
112
+ out = ffmpeg.output(audio, video, 'out.mp4')
113
+ """
114
+ return self ['v' ]
115
+
66
116
67
117
def get_stream_map (stream_spec ):
68
118
if stream_spec is None :
0 commit comments