Commit 8df9a3c9 authored by Łukasz Jernaś's avatar Łukasz Jernaś

Whitespace cleanup.

parent fd0a83d3
......@@ -50,16 +50,16 @@ codecmap = { 'vorbis' : "audio/x-vorbis", 'flac' : "audio/x-flac", 'mp3' : "
#for each. It also creates a python dictionary mapping the caps strings
#to concrete element names.
#####
def available_muxers():
""" return all available muxers except the broken ffmpeg ones """
flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
res = []
for fact in flist:
if list_compat(["Codec", "Muxer"], fact.get_klass().split('/')) and not fact.get_name().startswith('ffmux'):
if list_compat(["Codec", "Muxer"], fact.get_klass().split('/')) and not fact.get_name().startswith('ffmux'):
res.append(fact.get_name())
return res
def get_muxer_element(containercaps):
"""
Check all muxers for their caps and create a dictionary mapping caps
......@@ -72,19 +72,19 @@ def get_muxer_element(containercaps):
sinkcaps = [x.get_caps() for x in factory.get_static_pad_templates() if x.direction == gst.PAD_SRC]
for caps in sinkcaps:
stringcaps.append(caps[0].get_name())
print stringcaps
print stringcaps
muxerchoice = dict(zip(stringcaps, muxers))
if muxerchoice.has_key(containercaps):
elementname = muxerchoice[containercaps]
else:
elementname = False
elementname = False
return elementname
######
# This code checks for available audio encoders and return a unique caps string for each.
# It also creates a python dictionary mapping the caps strings to concrete element
# names.
#####
# This code checks for available audio encoders and return a unique caps string for each.
# It also creates a python dictionary mapping the caps strings to concrete element
# names.
#####
def available_audio_encoders():
""" returns all available audio encoders """
flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
......@@ -128,9 +128,9 @@ def get_audio_encoder_element(audioencodercaps):
#######
# This code checks for available video encoders and return a unique caps
# string for each. It also creates a python dictionary mapping the caps
# strings to concrete element names.
# strings to concrete element names.
#######
def available_video_encoders():
""" returns all available video encoders """
flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
......@@ -165,7 +165,7 @@ def get_video_encoder_element(videoencodercaps):
if attr not in blacklist:
result += ","+attr+"="+str(caps[0][attr])
videocaps.append(result)
# print videocaps
# print videocaps
videoencoderchoice = dict(zip(videocaps, encoders))
print videoencoderchoice
if videoencoderchoice.has_key(videoencodercaps):
......
......@@ -23,7 +23,7 @@ import os
import datetime
import codecfinder
try:
try:
import gobject; gobject.threads_init()
import gobject
import pygst
......@@ -66,7 +66,7 @@ class Transcoder(gobject.GObject):
CheckDir = os.path.isdir(self.VideoDirectory)
if CheckDir == (False):
os.mkdir(self.VideoDirectory)
# elif CheckDir == (True):
# elif CheckDir == (True):
# print "Videos directory exist"
# print self.VideoDirectory
......@@ -77,7 +77,7 @@ class Transcoder(gobject.GObject):
self.pipeline = gst.Pipeline("TranscodingPipeline")
self.pipeline.set_state(gst.STATE_PAUSED)
self.uridecoder = gst.element_factory_make("uridecodebin", "uridecoder")
self.uridecoder.set_property("uri", FILECHOSEN)
# print "File loaded " + FILECHOSEN
......@@ -91,15 +91,13 @@ class Transcoder(gobject.GObject):
self.transcodefileoutput.set_property("location", (self.VideoDirectory+self.FileNameOnly+self.timestamp+self.ContainerFormatSuffix))
self.pipeline.add(self.transcodefileoutput)
self.containermuxer.link(self.transcodefileoutput)
self.containermuxer.link(self.transcodefileoutput)
self.uridecoder.set_state(gst.STATE_PAUSED)
self.BusMessages = self.BusWatcher()
self.uridecoder.connect("no-more-pads", self.noMorePads) # we need to wait on this one before going further
self.uridecoder.connect("no-more-pads", self.noMorePads) # we need to wait on this one before going further
def noMorePads(self, dbin):
self.transcodefileoutput.set_state(gst.STATE_PAUSED)
......@@ -109,7 +107,7 @@ class Transcoder(gobject.GObject):
def idlePlay(self):
self.Pipeline("playing")
# print "gone to playing"
# print "gone to playing"
return False
def BusWatcher(self):
......@@ -130,15 +128,15 @@ class Transcoder(gobject.GObject):
# print "emiting 'ready' signal"
elif mtype == gst.MESSAGE_EOS:
self.emit('got-eos')
# print "Emiting 'got-eos' signal"
# print "Emiting 'got-eos' signal"
return True
def OnDynamicPad(self, dbin, sink_pad):
# print "OnDynamicPad for Audio and Video Called!"
c = sink_pad.get_caps().to_string()
# print "we got caps " + c
if c.startswith("audio/"):
#print "Got an audio cap"
#print "Got an audio cap"
self.audioconverter = gst.element_factory_make("audioconvert")
self.pipeline.add(self.audioconverter)
......@@ -155,9 +153,9 @@ class Transcoder(gobject.GObject):
self.audioencoder.set_state(gst.STATE_PAUSED)
self.gstaudioqueue.set_state(gst.STATE_PAUSED)
self.gstaudioqueue.link(self.containermuxer)
elif c.startswith("video/"):
# print "Got an video cap"
# print "Got an video cap"
self.colorspaceconverter = gst.element_factory_make("ffmpegcolorspace")
self.pipeline.add(self.colorspaceconverter)
......@@ -176,11 +174,11 @@ class Transcoder(gobject.GObject):
self.gstvideoqueue.link(self.containermuxer)
else:
raise Exception("Got a non-A/V pad!")
# print "Got a non-A/V pad!"
raise Exception("Got a non-A/V pad!")
# print "Got a non-A/V pad!"
def Pipeline (self, state):
if state == ("playing"):
self.pipeline.set_state(gst.STATE_PLAYING)
self.pipeline.set_state(gst.STATE_PLAYING)
elif state == ("null"):
self.pipeline.set_state(gst.STATE_NULL)
......@@ -31,7 +31,7 @@ import codecfinder
from gettext import gettext as _
import gettext
try:
try:
import pygtk
pygtk.require("2.0")
import gobject
......@@ -54,8 +54,8 @@ class TransmageddonUI (gtk.glade.XML):
module.textdomain("transmageddon")
#Set the Glade file
self.gladefile = "transmageddon.glade"
gtk.glade.XML.__init__ (self, self.gladefile)
self.gladefile = "transmageddon.glade"
gtk.glade.XML.__init__ (self, self.gladefile)
#Define functionality of our button and main window
self.TopWindow = self.get_widget("TopWindow")
......@@ -93,22 +93,22 @@ class TransmageddonUI (gtk.glade.XML):
if CheckDir == (False):
os.mkdir(self.VideoDirectory)
self.FileChooser.set_current_folder(self.VideoDirectory)
# Setting AppIcon
FileExist = os.path.isfile("../../share/pixmaps/transmageddon.png")
if FileExist:
if FileExist:
self.TopWindow.set_icon_from_file("../../share/pixmaps/transmageddon.png")
else:
try:
self.TopWindow.set_icon_from_file("transmageddon.png")
except:
print "failed to find appicon"
print "failed to find appicon"
# default all but top box to insensitive by default
self.ContainerChoice.set_sensitive(False)
self.CodecBox.set_sensitive(False)
self.TranscodeButton.set_sensitive(False)
self.cancelbutton.set_sensitive(False)
self.cancelbutton.set_sensitive(False)
# set default values for various variables
self.AudioCodec = "vorbis"
......@@ -120,7 +120,7 @@ class TransmageddonUI (gtk.glade.XML):
# Populate the Container format combobox
containers = gtk.ListStore(gobject.TYPE_STRING)
self.lst = [ "Ogg", "Matroska", "AVI", "MPEG TS", "FLV", "Quicktime", "MPEG4", "3GPP", "MXF" ]
self.lst = [ "Ogg", "Matroska", "AVI", "MPEG TS", "FLV", "Quicktime", "MPEG4", "3GPP", "MXF" ]
for i in self.lst:
self.ContainerChoice.append_text(i)
......@@ -146,7 +146,7 @@ class TransmageddonUI (gtk.glade.XML):
self.ProgressBar.set_fraction(value)
return True
else:
self.ProgressBar.set_fraction(1.0)
self.ProgressBar.set_fraction(1.0)
return False
# Call gobject.timeout_add with a value of 500millisecond to regularly poll for position so we can
......@@ -237,7 +237,7 @@ class TransmageddonUI (gtk.glade.XML):
else:
context_id = self.StatusBar.get_context_id("EOS")
self.StatusBar.push(context_id, _("Missing plugin installation failed: ")) + gst.pbutils.InstallPluginsReturn()
def check_for_elements(self):
ContainerChoice = self.get_widget ("ContainerChoice").get_active_text ()
containerstatus = codecfinder.get_muxer_element(codecfinder.containermap[ContainerChoice])
......@@ -263,7 +263,7 @@ class TransmageddonUI (gtk.glade.XML):
else:
print "ended up true"
self._start_transcoding()
# The Transcodebutton is the one that calls the Transcoder class and thus starts the transcoding
def on_TranscodeButton_clicked(self, widget):
self.FileChooser.set_sensitive(False)
......@@ -274,7 +274,7 @@ class TransmageddonUI (gtk.glade.XML):
self.ProgressBar.set_fraction(0.0)
self.ProgressBar.set_text(_("Transcoding Progress"))
self.check_for_elements()
def on_cancelbutton_clicked(self, widget):
self.FileChooser.set_sensitive(True)
self.ContainerChoice.set_sensitive(True)
......@@ -298,7 +298,7 @@ class TransmageddonUI (gtk.glade.XML):
self.CodecBox.set_sensitive(True)
self.TranscodeButton.set_sensitive(True)
self.ProgressBar.set_fraction(0.0)
self.ProgressBar.set_text(_("Transcoding Progress"))
self.ProgressBar.set_text(_("Transcoding Progress"))
ContainerChoice = self.get_widget ("ContainerChoice").get_active_text ()
if ContainerChoice == "Ogg":
self.vorbisbutton.set_sensitive(True)
......@@ -479,13 +479,13 @@ class TransmageddonUI (gtk.glade.XML):
self.AudioCodec = "mp3"
self.h264button.set_active(True)
self.VideoCodec = "h264"
def on_vorbisbutton_pressed(self, widget):
self.AudioCodec = "vorbis"
def on_flacbutton_pressed(self, widget):
self.AudioCodec = "flac"
def on_mp3button_pressed(self, widget):
self.AudioCodec = "mp3"
print "setting audio codec to mp3"
......@@ -508,22 +508,22 @@ class TransmageddonUI (gtk.glade.XML):
def on_wma2button_pressed(self, widget):
self.AudioCodec = "wma2"
def on_theorabutton_pressed(self, widget):
self.VideoCodec = "theora"
def on_diracbutton_pressed(self, widget):
self.VideoCodec = "dirac"
def on_h264button_pressed(self, widget):
self.VideoCodec = "h264"
def on_mpeg2button_pressed(self, widget):
self.VideoCodec = "mpeg2"
def on_mpeg4button_pressed(self, widget):
self.VideoCodec = "mpeg4"
def on_wmv2button_pressed(self, widget):
self.VideoCodec = "wmv2"
......@@ -534,9 +534,9 @@ class TransmageddonUI (gtk.glade.XML):
def on_MainWindow_destroy(self, widget):
gtk.main_quit()
if __name__ == "__main__":
hwg = TransmageddonUI()
gtk.main()
hwg = TransmageddonUI()
gtk.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment