Update.
This commit is contained in:
parent
e67c7e29c7
commit
d2d782f4fe
@ -1,5 +1,13 @@
|
||||
#!/bin/bash
|
||||
tmp_dir=$1
|
||||
audio=$2
|
||||
number_of_files=$2
|
||||
audio=$3
|
||||
audio2=$4
|
||||
|
||||
ffmpeg -i $tmp_dir/video/video.mp4 -i $audio -ac 1 -tune stillimage ./out/video-and-audio.mp4 -y
|
||||
if [ $number_of_files != "2" ]
|
||||
then
|
||||
ffmpeg -i $tmp_dir/video/video.mp4 -i $audio -ac 1 -tune stillimage ./out/video-and-audio.mp4 -y
|
||||
else
|
||||
ffmpeg -i $tmp_dir/video/video.mp4 -i $audio -ac 1 -tune stillimage $tmp_dir/video/video_sound_one.mp4 -y
|
||||
ffmpeg -i $tmp_dir/video/video_sound_one.mp4 -i $audio2 -ac 1 -tune stillimage ./out/video-and-audio.mp4 -y
|
||||
fi
|
||||
|
@ -1,5 +1,14 @@
|
||||
#!/bin/bash
|
||||
tmp_dir=$1
|
||||
both_channels=$2
|
||||
number_of_files=$2
|
||||
file_1=$3
|
||||
file_2=$4
|
||||
|
||||
if [ $number_of_files != "2" ]
|
||||
then
|
||||
ffmpeg -i $file_1 -map_channel 0.0.0 $tmp_dir/left.wav -map_channel 0.0.1 $tmp_dir/right.wav
|
||||
else
|
||||
ffmpeg -i $file_1 -map_channel 0.0.0 $tmp_dir/left.wav
|
||||
ffmpeg -i $file_2 -map_channel 0.0.1 $tmp_dir/right.wav
|
||||
fi
|
||||
|
||||
ffmpeg -i $both_channels -map_channel 0.0.0 $tmp_dir/left.wav -map_channel 0.0.1 $tmp_dir/right.wav
|
@ -1,5 +1,4 @@
|
||||
import math
|
||||
|
||||
from find_loudness import process_find_loudness
|
||||
|
||||
graph_density = 8000
|
||||
@ -53,11 +52,11 @@ def new_mode(m, s):
|
||||
|
||||
def mode_to_string(mode):
|
||||
"""Convert mode type to string"""
|
||||
if mode['left'] and mode['right']:
|
||||
if mode['left'] is True and mode['right'] is True:
|
||||
return 'both'
|
||||
elif mode['left']:
|
||||
elif mode['left'] is True:
|
||||
return 'left'
|
||||
elif mode['right']:
|
||||
elif mode['right'] is True:
|
||||
return 'right'
|
||||
else:
|
||||
return "none"
|
||||
@ -75,16 +74,19 @@ def run(tmp_dir):
|
||||
threshold_at_point=threshold_at_point,
|
||||
inertia_samples=inertia_samples,
|
||||
label="left")
|
||||
print("LEFT:", left_loudness)
|
||||
|
||||
right_loudness = process_find_loudness(
|
||||
tmp_dir + "/audio/rightraw",
|
||||
threshold_at_point=threshold_at_point,
|
||||
inertia_samples=inertia_samples,
|
||||
label="right")
|
||||
print("RIGHT:", right_loudness)
|
||||
|
||||
merged = [*left_loudness, *right_loudness]
|
||||
print(merged)
|
||||
sorted_list = sorted(merged, key=lambda x: x['position_start'])
|
||||
|
||||
print(sorted_list)
|
||||
demuxer.write(F"file {tmp_dir}/pics/none.png\n")
|
||||
|
||||
last_point = 0
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>554</width>
|
||||
<height>745</height>
|
||||
<height>807</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -621,6 +621,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="log_label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>h_line</zorder>
|
||||
<zorder>h_line_2</zorder>
|
||||
@ -629,6 +636,7 @@
|
||||
<zorder>v_spacer_1</zorder>
|
||||
<zorder>check_box_connected_channels</zorder>
|
||||
<zorder>progress_bar</zorder>
|
||||
<zorder>log_label</zorder>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menu_bar">
|
||||
<property name="geometry">
|
||||
|
@ -5,6 +5,7 @@ import tempfile
|
||||
|
||||
from pathlib import Path
|
||||
from pydub.utils import mediainfo
|
||||
from pydub.audio_segment import AudioSegment
|
||||
|
||||
# import resources_rc
|
||||
from PyQt5.QtCore import Qt
|
||||
@ -47,7 +48,9 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
||||
title='Process generowania podcastu',
|
||||
msg='Sprawdzanie poprawności danych'
|
||||
)
|
||||
self.test_data()
|
||||
self.log_label.hide()
|
||||
|
||||
self.test_data(option=2)
|
||||
|
||||
def setup_logic(self):
|
||||
"""Connect ui elements with methods."""
|
||||
@ -82,8 +85,13 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
||||
self.line_edit_name_1.setDisabled(True)
|
||||
self.line_edit_name_2.setDisabled(True)
|
||||
|
||||
def test_data(self):
|
||||
def test_data(self, option=1):
|
||||
"""Test data."""
|
||||
if option == 2:
|
||||
self.check_box_connected_channels.setChecked(False)
|
||||
self.line_edit_audio_1.setText('./src/sounds/lewy_kanal.mp3')
|
||||
self.line_edit_audio_2.setText('./src/sounds/prawy_kanal.mp3')
|
||||
else:
|
||||
self.line_edit_audio_1.setText('./src/sounds/oba_kanały.mp3')
|
||||
pixmap1 = QPixmap('./src/gui/images/both.png')
|
||||
scaled_pixmap1 = pixmap1.scaled(pixmap1.size(), Qt.KeepAspectRatio)
|
||||
@ -282,8 +290,9 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
||||
self.progress_bar.setValue(0)
|
||||
threshold_value = int(self.threshold_lcd.value())
|
||||
generate_demuxer.set_up_threshold(threshold_value)
|
||||
connected_channels = self.check_box_connected_channels.isChecked()
|
||||
|
||||
connected_channels = self.check_box_connected_channels.isChecked()
|
||||
print(F"Channels connected: {connected_channels}")
|
||||
# Setup images
|
||||
image_files = {
|
||||
'both': self.preview_label_avatar_1.property('path'),
|
||||
@ -317,44 +326,50 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
||||
|
||||
self.progress_bar.setValue(10)
|
||||
with tempfile.TemporaryDirectory() as tmp_dir_name:
|
||||
|
||||
print(tmp_dir_name)
|
||||
print(f'[*] Create temporary directory: {tmp_dir_name}')
|
||||
tmp_dir_name = './tmp_dir' + tmp_dir_name
|
||||
#os.mkdir('./tmp_dir/tmp')
|
||||
os.mkdir(tmp_dir_name)
|
||||
self.log_label.show()
|
||||
self.log_label.setText(f'[*] Create temporary directory: {tmp_dir_name}')
|
||||
tmp_out_dir = tmp_dir_name + "/out"
|
||||
pics_dir = tmp_dir_name + "/pics"
|
||||
audio_dir = tmp_dir_name + "/audio"
|
||||
video_dir = tmp_dir_name + "/video"
|
||||
|
||||
self.progress_bar.setValue(15)
|
||||
print(F"[!] Create tmp out dir: {tmp_out_dir}")
|
||||
self.log_label.setText(f"[!] Create tmp out dir: {tmp_out_dir}")
|
||||
os.mkdir(tmp_out_dir)
|
||||
|
||||
print(f'[*] Create pics dir: {pics_dir}')
|
||||
self.log_label.setText(f"[*] Create pics dir: {pics_dir}")
|
||||
os.mkdir(pics_dir)
|
||||
|
||||
print(f'[*] Create audio dir: {audio_dir}')
|
||||
self.log_label.setText(f"[*] Create audio dir: {audio_dir}")
|
||||
os.mkdir(audio_dir)
|
||||
|
||||
print(f'[*] Create video dir: {video_dir}\n')
|
||||
self.log_label.setText(f"[*] Create video dir: {video_dir}")
|
||||
os.mkdir(video_dir)
|
||||
|
||||
print(f'[*] Copy images to {pics_dir}')
|
||||
self.log_label.setText(f"[*] Copy images to {pics_dir}")
|
||||
shutil.copy(image_files['both'], pics_dir + "/both.png")
|
||||
shutil.copy(image_files['none'], pics_dir + "/none.png")
|
||||
shutil.copy(image_files['left'], pics_dir + "/left.png")
|
||||
shutil.copy(image_files['right'], pics_dir + "/right.png")
|
||||
|
||||
self.progress_bar.setValue(20)
|
||||
print(f'[*] Copy audio to {audio_dir}\n')
|
||||
if not self.check_box_connected_channels.isChecked():
|
||||
self.log_label.setText(f"[*] Copy audio to {audio_dir}")
|
||||
if not connected_channels:
|
||||
audio_files[0]['tmp'] = audio_dir + "/left_channel" + "." + audio_files[0]['ext']
|
||||
audio_files[1]['tmp'] = audio_dir + "/right_channel" + "." + audio_files[1]['ext']
|
||||
|
||||
audio_files[0]['duration'] = mediainfo(audio_files[0]['file'])['duration']
|
||||
audio_files[1]['duration'] = mediainfo(audio_files[1]['file'])['duration']
|
||||
|
||||
shutil.copy(audio_files[0]['file'], audio_files[0]['tmp'])
|
||||
shutil.copy(audio_files[1]['file'], audio_files[1]['tmp'])
|
||||
|
||||
else:
|
||||
audio_files[0]['tmp'] = audio_dir + "/both_channel" + "." + audio_files[0]['ext']
|
||||
audio_files[0]['duration'] = mediainfo(audio_files[0]['file'])['duration']
|
||||
shutil.copy(audio_files[0]['file'], audio_files[0]['tmp'])
|
||||
|
||||
print(f'[*] Images in {pics_dir}: {os.listdir(pics_dir)}')
|
||||
@ -365,38 +380,56 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
||||
|
||||
if connected_channels:
|
||||
# Split channels
|
||||
print("[-] Split channels - start:")
|
||||
subprocess.check_output(["bash",
|
||||
"bash_commands/split_channels_to_two_ways.sh",
|
||||
audio_dir,
|
||||
audio_files[0]['tmp']])
|
||||
print("[+] Split channels - done")
|
||||
number_of_files = "1"
|
||||
self.log_label.setText("Split audio file 1/5")
|
||||
print(subprocess.check_output([
|
||||
"bash", "bash_commands/split_channels_to_two_ways.sh",
|
||||
audio_dir, number_of_files, audio_files[0]['tmp']
|
||||
]))
|
||||
else:
|
||||
print(F"DUARTION {audio_files[0]['duration'], audio_files[1]['duration']}")
|
||||
if float(audio_files[0]['duration']) > float(audio_files[1]['duration']):
|
||||
print("LEFT")
|
||||
|
||||
else:
|
||||
print("RIGHT")
|
||||
|
||||
number_of_files = "2"
|
||||
self.log_label.setText("Copy audio files 1/5")
|
||||
print(subprocess.check_output([
|
||||
"bash", "bash_commands/split_channels_to_two_ways.sh",
|
||||
audio_dir, number_of_files, audio_files[0]['tmp'], audio_files[1]['tmp']
|
||||
]))
|
||||
|
||||
self.progress_bar.setValue(30)
|
||||
print("[-] Create raw files - start:")
|
||||
self.log_label.setText(f"Create raw files 2/5")
|
||||
subprocess.check_output(['bash',
|
||||
'bash_commands/create_raw_files.sh',
|
||||
audio_dir, self.aresample])
|
||||
print("[+] Create raw files - done")
|
||||
|
||||
self.progress_bar.setValue(60)
|
||||
print("[-] Create demuxer - start:")
|
||||
self.log_label.setText(f"Create demuxer 3/5")
|
||||
generate_demuxer.run(tmp_dir=tmp_dir_name)
|
||||
print("[+] Create demuxer - done")
|
||||
|
||||
print('[-] Create video - start:')
|
||||
self.log_label.setText(f"Create video 4/5")
|
||||
subprocess.check_output(
|
||||
['bash', 'bash_commands/generate_video_by_demuxer.sh', tmp_dir_name, video_dir])
|
||||
print('[+] Create video - done')
|
||||
|
||||
self.progress_bar.setValue(75)
|
||||
# while True: pass
|
||||
print('[-] Create final podcast - start:')
|
||||
self.log_label.setText(f"Create final podcast 5/5")
|
||||
if connected_channels:
|
||||
subprocess.check_output(
|
||||
['bash', 'bash_commands/connect_sound.sh', tmp_dir_name, audio_files[0]['file']])
|
||||
print('[+] Create final podcast - done')
|
||||
['bash', 'bash_commands/connect_sound.sh', tmp_dir_name, "1", audio_files[0]['file']])
|
||||
self.progress_bar.setValue(100)
|
||||
else:
|
||||
print("IAM HEEEEERERERERERER")
|
||||
subprocess.check_output(
|
||||
['bash', 'bash_commands/connect_sound.sh', tmp_dir_name, "2", audio_files[0]['file'], audio_files[1]['file']])
|
||||
self.progress_bar.setValue(100)
|
||||
|
||||
dialog_done = self.create_custom_dialog(title="Informacja", msg="Zakończono generowanie podcastu.")
|
||||
dialog_done.exec_()
|
||||
self.progress_bar.setValue(0)
|
||||
self.log_label.setText("")
|
||||
self.log_label.hide()
|
||||
|
||||
|
@ -4,6 +4,7 @@ from PyQt5.QtWidgets import QApplication, QAbstractSlider, QSizePolicy, QSlider,
|
||||
|
||||
|
||||
class Communicate(QObject):
|
||||
"""Class to connect classes by signals"""
|
||||
range_changed = pyqtSignal(int, int)
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName("MainWindow")
|
||||
MainWindow.resize(554, 745)
|
||||
MainWindow.resize(554, 807)
|
||||
self.central_widget = QtWidgets.QWidget(MainWindow)
|
||||
self.central_widget.setMinimumSize(QtCore.QSize(0, 0))
|
||||
self.central_widget.setObjectName("central_widget")
|
||||
@ -265,12 +265,17 @@ class Ui_MainWindow(object):
|
||||
self.progress_bar.setProperty("value", 24)
|
||||
self.progress_bar.setObjectName("progress_bar")
|
||||
self.verticalLayout.addWidget(self.progress_bar)
|
||||
self.log_label = QtWidgets.QLabel(self.central_widget)
|
||||
self.log_label.setText("")
|
||||
self.log_label.setObjectName("log_label")
|
||||
self.verticalLayout.addWidget(self.log_label)
|
||||
self.h_line.raise_()
|
||||
self.h_line_2.raise_()
|
||||
self.threshold_slider.raise_()
|
||||
self.h_line_3.raise_()
|
||||
self.check_box_connected_channels.raise_()
|
||||
self.progress_bar.raise_()
|
||||
self.log_label.raise_()
|
||||
MainWindow.setCentralWidget(self.central_widget)
|
||||
self.menu_bar = QtWidgets.QMenuBar(MainWindow)
|
||||
self.menu_bar.setGeometry(QtCore.QRect(0, 0, 554, 32))
|
||||
|
Loading…
Reference in New Issue
Block a user