Skip to content

Commit

Permalink
Allow presets to specify custom elements to apply transformations to …
Browse files Browse the repository at this point in the history
…the video stream. This allows you to rotate, for example, by setting "transform": "videoflip method=clockwise" in the JSON device preset. Since any element can be used and you are modifying raw video this can also be used to add effects, color balance, sharpen, etc.
  • Loading branch information
danielgtaylor committed Jun 17, 2010
1 parent 37c53c6 commit 475eff6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion arista/presets.py
Expand Up @@ -233,6 +233,7 @@ def json(self):
"passes": preset.vcodec.passes,
"width": preset.vcodec.width,
"height": preset.vcodec.height,
"transform": preset.vcodec.transform,
},
})

Expand Down Expand Up @@ -279,6 +280,7 @@ def from_json(data):
"passes": vcodec.get("passes", []),
"width": vcodec.get("width", []),
"height": vcodec.get("height", []),
"transform": vcodec.get("transform", ""),
}),
"device": device,
})
Expand Down Expand Up @@ -426,11 +428,12 @@ class VideoCodec(Codec):
"""
Settings for encoding video.
"""
def __init__(self, name=None, container=None, rate=None, passes=None, width=None, height=None):
def __init__(self, name=None, container=None, rate=None, passes=None, width=None, height=None, transform=None):
Codec.__init__(self, name=name, container=container, passes=passes)
self.rate = rate and rate or (Fraction("1"), Fraction("60"))
self.width = width and width or (2, 1920)
self.height = height and height or (2, 1080)
self.transform = transform

def load(filename):
"""
Expand Down
9 changes: 7 additions & 2 deletions arista/transcoder.py
Expand Up @@ -459,6 +459,10 @@ def _setup_pass(self):
if self.options.deinterlace:
deint = " ffdeinterlace ! "

transform = ""
if self.preset.vcodec.transform:
transform = self.preset.vcodec.transform + " ! "

sub = ""
if self.options.subfile:
# Render subtitles onto the video stream
Expand All @@ -475,9 +479,10 @@ def _setup_pass(self):
vmux += "video_%d"

cmd += " dmux. ! queue ! ffmpegcolorspace ! videorate !" \
"%s %s videoscale ! %s ! %s%s ! tee " \
"%s %s %s videoscale ! %s ! %s%s ! tee " \
"name=videotee ! queue ! %s" % \
(deint, sub, self.vcaps.to_string(), vbox, vencoder, vmux)
(deint, transform, sub, self.vcaps.to_string(), vbox,
vencoder, vmux)

if self.info.is_audio and self.preset.acodec and \
self.enc_pass == len(self.preset.vcodec.passes) - 1:
Expand Down

0 comments on commit 475eff6

Please sign in to comment.