diff --git a/data/interface/wmain.ui b/data/interface/wmain.ui
index 6ea3b84..3625d7a 100644
--- a/data/interface/wmain.ui
+++ b/data/interface/wmain.ui
@@ -429,6 +429,7 @@
disc_size_list
1
0
+
diff --git a/src/devede/avconv_converter.py b/src/devede/avconv_converter.py
index 30f4f5a..a6a0f7b 100644
--- a/src/devede/avconv_converter.py
+++ b/src/devede/avconv_converter.py
@@ -266,7 +266,7 @@ class avconv_converter(devede.executor.executor):
- def create_menu_mpeg(self,n_page,background_music,sound_length,pal,output_path):
+ def create_menu_mpeg(self,n_page,background_music,sound_length,pal,video_rate, audio_rate,output_path):
self.n_page = n_page
self.final_length = float(sound_length)
@@ -301,9 +301,9 @@ class avconv_converter(devede.executor.executor):
self.command_var.append("-g")
self.command_var.append("12")
self.command_var.append("-b:v")
- self.command_var.append("2500k")
+ self.command_var.append(str(video_rate)+"k")
self.command_var.append("-b:a")
- self.command_var.append("192k")
+ self.command_var.append(str(audio_rate)+"k")
self.command_var.append("-aspect")
self.command_var.append("4:3")
diff --git a/src/devede/dvd_menu.py b/src/devede/dvd_menu.py
index ccf76e6..942e830 100644
--- a/src/devede/dvd_menu.py
+++ b/src/devede/dvd_menu.py
@@ -64,6 +64,14 @@ class dvd_menu(devede.interface_manager.interface_manager):
self.cached_menu_font = None
self.cached_menu_size = 0
self.sound_length = 30
+ self.video_rate = 2500
+ self.audio_rate = 224
+
+
+ def get_estimated_size(self):
+
+ estimated_size = ((self.video_rate + self.audio_rate) * self.sound_length) / 8
+ return estimated_size
def update_music(self,b=None):
@@ -556,7 +564,7 @@ class dvd_menu(devede.interface_manager.interface_manager):
self.sf.write_to_png(os.path.join(menu_folder,"menu_"+str(n_page)+"_active_bg.png"))
entry_data = self.create_menu_stream(menu_folder, n_page, coordinates)
converter = menu_converter()
- final_path = converter.create_menu_mpeg(n_page,self.background_music,self.sound_length,self.config.PAL,menu_folder)
+ final_path = converter.create_menu_mpeg(n_page,self.background_music,self.sound_length,self.config.PAL,self.video_rate,self.audio_rate,menu_folder)
entry_data["filename"] = final_path
menu_entries.append(entry_data)
# add this process without dependencies
diff --git a/src/devede/file_movie.py b/src/devede/file_movie.py
index 4c37de3..4aaadc1 100644
--- a/src/devede/file_movie.py
+++ b/src/devede/file_movie.py
@@ -135,18 +135,50 @@ class file_movie(devede.interface_manager.interface_manager):
self.original_audiorate = film_analizer.original_audiorate
self.original_audiorate_uncompressed = film_analizer.original_audiorate_uncompressed
self.original_fps = film_analizer.original_fps
+ self.original_file_size = film_analizer.original_file_size
self.error = False
self.width_midle = -1
self.height_midle = -1
self.width_final = -1
self.height_final = -1
+ self.video_rate_auto = self.video_rate
+ self.audio_rate_auto = self.audio_rate
self.video_rate_final = self.video_rate
self.audio_rate_final = self.audio_rate
self.aspect_ratio_final = None
self.converted_filename = None
+ def get_estimated_size(self):
+ """ Returns the estimated final file size, in kBytes, based on the final audio and video rate, and the subtitles """
+
+ self.set_final_rates()
+ self.set_final_size_aspect()
+
+ if self.is_mpeg_ps:
+ estimated_size = self.original_file_size / 1000
+ #fixed_size = True
+ #sub_rate = 0
+ else:
+ #fixed_size = False
+ # let's asume 8kbps for each subtitle
+ sub_rate = 8 * len(self.subtitles_list)
+ estimated_size = ((self.video_rate_final + self.audio_rate_final + sub_rate) * self.original_length) / 8
+
+ #fixed_video = 0
+ #fixed_audio = 0
+
+# if self.no_reencode_audio_video:
+# fixed_video = self.original_videorate
+# fixed_audio = self.original_audiorate
+#
+# if self.copy_sound:
+# fixed_audio = self.original_audiorate
+
+ return estimated_size
+
+
def get_max_resolution(self,rx,ry,aspect):
tmpx = ry*aspect
@@ -156,6 +188,27 @@ class file_movie(devede.interface_manager.interface_manager):
else:
return rx,tmpy
+
+ def set_final_rates(self):
+
+ if self.is_mpeg_ps or self.no_reencode_audio_video:
+ self.video_rate_final = self.original_videorate
+ self.audio_rate_final = self.original_audiorate
+ else:
+ if self.video_rate_automatic:
+ self.video_rate_final = self.video_rate_auto
+ else:
+ self.video_rate_final = self.video_rate
+
+ if self.copy_sound:
+ self.audio_rate_final = self.original_audiorate
+ else:
+ if self.audio_rate_automatic:
+ self.audio_rate_final = self.audio_rate_auto
+ else:
+ self.audio_rate_final = self.audio_rate
+
+
def set_final_size_aspect(self):
if self.is_mpeg_ps:
@@ -422,14 +475,18 @@ class file_movie(devede.interface_manager.interface_manager):
self.wcut_picture_pic.set_from_file(os.path.join(self.config.pic_path,"to_wide_cut.png"))
self.wscale_picture_pic.set_from_file(os.path.join(self.config.pic_path,"to_wide_scale.png"))
+
def on_button_accept_clicked(self,b):
self.store_ui(self.builder)
+ self.set_final_rates()
+ self.set_final_size_aspect()
self.emit('title_changed',self.title_name)
self.wfile_properties.destroy()
self.wfile_properties = None
self.builder = None
+
def on_button_cancel_clicked(self,b):
self.restore_ui()
@@ -437,12 +494,14 @@ class file_movie(devede.interface_manager.interface_manager):
self.wfile_properties = None
self.builder = None
+
def on_add_subtitles_clicked(self,b):
subt = devede.ask_subtitles.ask_subtitles()
if (subt.run()):
self.wsubtitles_list.append([subt.filename, subt.encoding, subt.language, subt.put_upper])
+
def get_selected_subtitle(self):
selection = self.wtreview_subtitles.get_selection()
@@ -453,12 +512,14 @@ class file_movie(devede.interface_manager.interface_manager):
else:
return ( (None, None) )
+
def on_del_subtitles_clicked(self,b):
model, treeiter = self.get_selected_subtitle()
if (model != None):
model.remove(treeiter)
+
def on_treeview_subtitles_cursor_changed(self,b):
model, treeiter = self.get_selected_subtitle()
@@ -475,16 +536,20 @@ class file_movie(devede.interface_manager.interface_manager):
converter = devede.file_copy.file_copy(self.file_name,output_path)
else:
self.set_final_size_aspect()
+ self.set_final_rates()
+
cv = devede.converter.converter.get_converter()
disc_converter = cv.get_disc_converter()
converter = disc_converter()
converter.convert_file(self,output_path,duration)
return converter
+
def on_button_preview_clicked(self,b):
self.store_ui(self.builder)
self.do_preview()
+
def do_preview(self):
wpreview = devede.preview.preview_window()
@@ -497,6 +562,7 @@ class file_movie(devede.interface_manager.interface_manager):
run_window.connect("done",self.preview_done)
run_window.run()
+
def preview_done(self,o,retval):
if (retval == 0):
diff --git a/src/devede/mplayer_detector.py b/src/devede/mplayer_detector.py
index d804506..dc86bad 100644
--- a/src/devede/mplayer_detector.py
+++ b/src/devede/mplayer_detector.py
@@ -18,6 +18,7 @@
import subprocess
import devede.configuration_data
import devede.executor
+import os
class mplayer_detector(devede.executor.executor):
@@ -59,6 +60,7 @@ class mplayer_detector(devede.executor.executor):
""" processes a file, refered by the FILE_MOVIE movie object, and fills its
main data (resolution, FPS, length...) """
+ self.original_file_size = os.path.getsize(file_name)
(video, audio, length) = self.analize_film_data(file_name, True)
if (video != 0):
diff --git a/src/devede/project.py b/src/devede/project.py
index 681adcd..87e3f74 100644
--- a/src/devede/project.py
+++ b/src/devede/project.py
@@ -30,6 +30,7 @@ import devede.settings
import devede.dvdauthor_converter
import devede.mkisofs
import devede.end_job
+import devede.vcdimager_converter
class devede_project:
@@ -191,6 +192,7 @@ class devede_project:
element = item.model[item.iter][0]
if element == obj:
item.model.set_value(item.iter,1,new_title)
+ self.refresh_disc_usage()
def on_add_file_clicked(self,b):
@@ -208,6 +210,7 @@ class devede_project:
if (len(error_list)!=0):
devede.message.message_window(_("The following files could not be added:"),_("Error while adding files"),error_list)
self.set_interface_status(None)
+ self.refresh_disc_usage()
def on_delete_file_clicked(self,b):
@@ -242,23 +245,103 @@ class devede_project:
self.wfiles.get_model().swap(last_element.iter,treeiter)
self.set_interface_status(None)
+
def on_properties_file_clicked(self,b):
(element, position, model, treeiter) = self.get_current_file()
if (element == None):
return
element.properties()
+
def on_create_menu_toggled(self,b):
self.set_interface_status(None)
+ self.refresh_disc_usage()
+
def on_adjust_disc_usage_clicked(self,b):
pass
+
def on_menu_options_clicked(self,b):
self.menu.show_configuration(self.get_all_files())
+
+ def get_dvd_size(self):
+
+ """ Returns the size for the currently selected disk type, and the minimum and maximum
+ videorate for the current video disk """
+
+ active = self.wdisc_size.get_active()
+
+ # here we choose the size in Mbytes for the media
+ if 5==active:
+ size=170.0
+ elif 4==active:
+ size=700.0
+ elif 3==active:
+ size=750.0
+ elif 2==active:
+ size=1100.0
+ elif 1==active:
+ size=4200.0
+ else:
+ size=8000.0
+
+ if self.disc_type=="vcd":
+ minvrate=1152
+ maxvrate=1152
+ elif (self.disc_type == "svcd") or (self.disc_type == "cvd"):
+ minvrate=400
+ maxvrate=2300
+ elif (self.disc_type == "dvd"):
+ minvrate=400
+ maxvrate=8500
+ elif (self.disc_type == "divx") or (self.disc_type == "mkv"):
+ minvrate=300
+ maxvrate=6000
+ else:
+ minvrate = 0
+ maxvrate = 8000
+
+ size*=0.90 # a safe margin of 10% to ensure that it never will be bigger
+ # (it's important to have in mind the space needed by disk structures like
+ # directories, file entries, and so on)
+
+ return size,minvrate,maxvrate
+
+
+ def refresh_disc_usage(self):
+
+ used = 0.0
+
+ for f in self.get_all_files():
+ estimated_size = f.get_estimated_size()
+ used += float(estimated_size)
+
+ if self.wcreate_menu.get_active():
+ used += float(self.menu.get_estimated_size())
+
+ used /= 1000.0
+
+ disc_size,minvrate,maxvrate = self.get_dvd_size()
+
+ if used > disc_size:
+ self.wdisc_fill_level.set_fraction(1.0)
+ addv=1
+ else:
+ self.wdisc_fill_level.set_fraction(used / disc_size)
+ addv=0
+ self.wdisc_fill_level.set_text(str(addv+int((used / disc_size)*100))+"%")
+ self.wdisc_fill_level.set_show_text(True)
+
+
+ def on_disc_size_changed(self,c):
+
+ self.refresh_disc_usage()
+
+
def on_create_disc_clicked(self,b):
data = devede.create_disk_window.create_disk_window()
@@ -270,7 +353,7 @@ class devede_project:
final_dependencies = []
- if (self.wcreate_menu.get_active()):
+ if (self.disc_type == "dvd") and (self.wcreate_menu.get_active()):
processes,menu_entries = self.menu.create_dvd_menus(file_movies, data.path)
for p in processes:
run_window.add_process(p)
@@ -305,6 +388,12 @@ class devede_project:
isocreator.create_iso(data.path, data.name)
isocreator.add_dependency(dvdauthor)
run_window.add_process(isocreator)
+ elif (self.disc_type == "vcd") or (self.disc_type == "svcd") or (self.disc_type == "cvd"):
+ vcdcreator = devede.vcdimager_converter.vcdimager_converter()
+ vcdcreator.create_cd_project(data.path, data.name, file_movies)
+ for element in final_dependencies:
+ vcdcreator.add_dependency(element)
+ run_window.add_process(vcdcreator)
run_window.connect("done",self.disc_done)
self.wmain_window.hide()
diff --git a/src/devede/vcdimager_converter.py b/src/devede/vcdimager_converter.py
new file mode 100644
index 0000000..089741a
--- /dev/null
+++ b/src/devede/vcdimager_converter.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+
+# Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
+#
+# This file is part of DeVeDe-NG
+#
+# DeVeDe-NG is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# DeVeDe-NG is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+
+import os
+import devede.configuration_data
+import devede.executor
+
+class vcdimager_converter(devede.executor.executor):
+
+ def __init__(self):
+
+ devede.executor.executor.__init__(self)
+ self.config = devede.configuration_data.configuration.get_config()
+
+ def create_cd_project (self, path, name, file_movies):
+
+ self.command_var=[]
+ self.command_var.append("vcdimager")
+ self.command_var.append("-c")
+ self.command_var.append(os.path.join(path,name+".cue"))
+ self.command_var.append("-b")
+ self.command_var.append(os.path.join(path,name+".bin"))
+ self.command_var.append("-t")
+ if self.config.disc_type == "vcd":
+ self.command_var.append("vcd2")
+ else:
+ self.command_var.append("svcd")
+ for element in file_movies:
+ self.command_var.append(element.converted_filename)
+ self.text = _("Creating CD image")
+
+
+ def process_stdout(self,data):
+ print("Stdout: "+str(data))
+ return
+
+ def process_stderr(self,data):
+ print("Stderr: "+str(data))
+ return