Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

Commit

Permalink
Fix #614 Add video scaling options
Browse files Browse the repository at this point in the history
Freeseer now supports converting video signals from one display
resolution to another. Technically we already supported this, but there
were no scaling options so it wasn't very useful.

The following scaling options are now available when recording video:

- No scaling
- 240p (320x240)
- 360p (480x360)
- 480p (640x480)
- 720p (1280x720)
- 1080p (1920x1080)
  • Loading branch information
Cryspia authored and dideler committed Nov 5, 2014
1 parent 66b9e43 commit d93c4b0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
23 changes: 20 additions & 3 deletions src/freeseer/plugins/videomixer/videopassthrough/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import pygst
pygst.require("0.10")
import gst
import logging

# PyQt modules
from PyQt4.QtCore import SIGNAL
Expand All @@ -45,13 +46,15 @@
# .freeseer-plugin custom modules
import widget

log = logging.getLogger(__name__)


class VideoPassthroughConfig(Config):
"""Configuration class for VideoPassthrough plugin."""
input = options.StringOption("Video Test Source")
input_type = options.StringOption("video/x-raw-rgb")
framerate = options.IntegerOption(30)
resolution = options.StringOption("NOSCALE")
resolution = options.ChoiceOption(widget.resmap.keys(), "No Scaling")


class VideoPassthrough(IVideoMixer):
Expand All @@ -78,9 +81,15 @@ def get_videomixer_bin(self):
bin.add(videoscale)
videoscale_cap = gst.element_factory_make("capsfilter",
"videoscale_cap")
if self.config.resolution != "NOSCALE":

# Change the resolution of the source video.
log.debug("Record Resolution: %s", self.config.resolution)
if self.config.resolution != "No Scaling":
width, height = widget.resmap[self.config.resolution]
videoscale_cap.set_property('caps',
gst.caps_from_string('%s, width=640, height=480' % (self.config.input_type)))
gst.caps_from_string("{}, width={}, height={}"
.format(self.config.input_type, width, height)))

bin.add(videoscale_cap)
# --- End Video Scaler

Expand Down Expand Up @@ -127,6 +136,7 @@ def __enable_connections(self):
self.widget.connect(self.widget.framerateSlider, SIGNAL("valueChanged(int)"), self.set_framerate)
self.widget.connect(self.widget.framerateSpinBox, SIGNAL("valueChanged(int)"), self.set_framerate)
self.widget.connect(self.widget.inputSettingsToolButton, SIGNAL('clicked()'), self.source1_setup)
self.widget.connect(self.widget.videoscaleComboBox, SIGNAL("currentIndexChanged(const QString&)"), self.set_videoscale)

def widget_load_config(self, plugman):
self.load_config(plugman)
Expand All @@ -149,6 +159,9 @@ def widget_load_config(self, plugman):
vcolour_index = self.widget.videocolourComboBox.findText(self.config.input_type)
self.widget.videocolourComboBox.setCurrentIndex(vcolour_index)

vscale_index = self.widget.videoscaleComboBox.findText(self.config.resolution)
self.widget.videoscaleComboBox.setCurrentIndex(vscale_index)

# Need to set both the Slider and Spingbox since connections
# are not yet loaded at this point
self.widget.framerateSlider.setValue(self.config.framerate)
Expand Down Expand Up @@ -182,6 +195,10 @@ def set_framerate(self, framerate):
self.config.framerate = framerate
self.config.save()

def set_videoscale(self, resolution):
self.config.resolution = resolution
self.config.save()

###
### Translations
###
Expand Down
15 changes: 14 additions & 1 deletion src/freeseer/plugins/videomixer/videopassthrough/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
@author: Thanh Ha
'''

from collections import OrderedDict

from PyQt4.QtCore import Qt
from PyQt4.QtGui import QComboBox
from PyQt4.QtGui import QFormLayout
Expand All @@ -40,6 +42,16 @@
from PyQt4.QtGui import QWidget


resmap = OrderedDict([
('No Scaling', (0, 0)),
('240p', (320, 240)),
('360p', (480, 360)),
('480p', (640, 480)),
('720p', (1280, 720)),
('1080p', (1920, 1080)),
])


class ConfigWidget(QWidget):

def __init__(self, parent=None):
Expand Down Expand Up @@ -87,6 +99,7 @@ def __init__(self, parent=None):

self.videoscaleLabel = QLabel("Video Scale")
self.videoscaleComboBox = QComboBox()
self.videoscaleComboBox.addItem("NOSCALE")
for scale in resmap:
self.videoscaleComboBox.addItem(scale)
self.videoscaleComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum)
layout.addRow(self.videoscaleLabel, self.videoscaleComboBox)
13 changes: 0 additions & 13 deletions src/freeseer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,8 @@
class FreeseerConfig(Config):
"""General Freeseer profile settings."""

resmap = {
# No Scaling
'default': '0x0',

# Scaling
'240p': '320x240',
'360p': '480x360',
'480p': '640x480',
'720p': '1280x720',
'1080p': '1920x1080'
}

videodir = options.FolderOption('~/Videos', auto_create=True)
auto_hide = options.BooleanOption(False)
resolution = options.ChoiceOption(resmap.keys(), 'default')
enable_audio_recording = options.BooleanOption(True)
enable_video_recording = options.BooleanOption(True)
videomixer = options.StringOption('Video Passthrough')
Expand Down

0 comments on commit d93c4b0

Please sign in to comment.