Commit e063f0ca authored by Nadir Dalla Pozza's avatar Nadir Dalla Pozza
Browse files

Update considering new working path

parent 2e8d6a4c
input/*
output/*
.idea
.DS_Store
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
<excludeFolder url="file://$MODULE_DIR$/input/IrregularityImages" />
<excludeFolder url="file://$MODULE_DIR$/input/RestoredAudioFiles" />
<excludeFolder url="file://$MODULE_DIR$/output/AccessCopyFiles" />
<excludeFolder url="file://$MODULE_DIR$/output/PreservationMasterFiles" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9 (packager)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (packager)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Packager.iml" filepath="$PROJECT_DIR$/.idea/Packager.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -22,7 +22,7 @@ PyYaml (https://pyyaml.org) is required for reading the configuration file. You
```
pip install pyyaml
```
MoviePy (https://zulko.github.io/moviepy/#) is required for replacing the audio of the Preservation Audio-Visual File. You can install it with:
MoviePy (https://zulko.github.io/moviepy/) is required for replacing the audio of the Preservation Audio-Visual File. You can install it with:
```
pip install moviepy
```
......@@ -34,7 +34,9 @@ pip install -r requirements.txt
## Usage
Once the libraries are installed, you should customise the configuration file `config.yaml`.
There are two required parameters, `INPUT_PATH` and `OUTPUT_PATH` that specifies where all input files are stored and where output files shall be saved.
There are two required parameters:
1) `WORKING_PATH` that specifies the working path where all input files are stored and where all output files will be saved;
2) `PRESERVATION_FILES_NAME` that specifies the name of the preservation files to be considered.
You can now launch the Packager from the command line with:
```
......@@ -47,10 +49,17 @@ If you have any problem you can contact us at:
- Nadir Dalla Pozza (nadir.dallapozza@unipd.it)
- Niccolò Pretto (niccolo.pretto@unipd.it)
This project was developed with the Python IDE PyCharm Community (https://www.jetbrains.com/pycharm/).
## Authors and acknowledgment
Nadir Dalla Pozza, Niccolò Pretto, Sergio Canazza.
This project was developed by:
- Nadir Dalla Pozza (Università degli Studi di Padova)
- Niccolò Pretto (Università degli Studi di Padova)
- Sergio Canazza (Università degli Studi di Padova)
This project takes advantage of with the following libraries:
- MoviePy (https://zulko.github.io/moviepy/)
- PyYaml (https://pyyaml.org)
Developed with Python IDE PyCharm Community (https://www.jetbrains.com/pycharm/).
## License
For open source projects, say how it is licensed.
This project is licensed with GNU GPL v3.0.
# Path where all input files are stored (ending '/' required)
INPUT_PATH: "./input/"
# Path where all output files will be saved (ending '/' required)
OUTPUT_PATH: "./output/"
# Working path
WORKING_PATH: "/Users/nadir/Documents/MPAI-CAE/Workflow"
# Name of the Preservation files (without extension)
PRESERVATION_FILES_NAME: "test"
......@@ -24,7 +24,7 @@ from moviepy.editor import VideoFileClip, AudioFileClip
__author__ = "Nadir Dalla Pozza"
__copyright__ = "Copyright 2022, Audio Innova S.r.l."
__credits__ = ["Niccolò Pretto", "Nadir Dalla Pozza", "Sergio Canazza"]
__license__ = "GPL" # ?
__license__ = "GPL v3.0"
__version__ = "1.0.1"
__maintainer__ = "Nadir Dalla Pozza"
__email__ = "nadir.dallapozza@unipd.it"
......@@ -50,29 +50,31 @@ if __name__ == '__main__':
config = object
try:
config = yaml.safe_load(open('./config.yaml', 'r'))
if 'INPUT_PATH' not in config:
print(ConsoleColors.RED + 'INPUT_PATH key not found in config.yaml!' + ConsoleColors.END)
if 'WORKING_PATH' not in config:
print(ConsoleColors.RED + 'WORKING_PATH key not found in config.yaml!' + ConsoleColors.END)
quit(os.EX_CONFIG)
if 'OUTPUT_PATH' not in config:
print(ConsoleColors.RED + 'OUTPUT_PATH key not found in config.yaml!' + ConsoleColors.END)
if 'PRESERVATION_FILES_NAME' not in config:
print(ConsoleColors.RED + 'PRESERVATION_FILES_NAME key not found in config.yaml!' + ConsoleColors.END)
quit(os.EX_CONFIG)
except FileNotFoundError:
print(ConsoleColors.RED + 'config.yaml file not found!' + ConsoleColors.END)
quit(os.EX_NOINPUT)
temp_path = os.path.join(config['WORKING_PATH'], 'temp/')
# Access Copy Files
print('\n' + ConsoleColors.BOLD + 'Creation of Access Copy Files...' + ConsoleColors.END)
# By default, AccessCopyFiles directory is created in the output path...
acf_dir = 'AccessCopyFiles/'
acf_path = os.path.join(config['OUTPUT_PATH'], acf_dir)
acf_dir = 'AccessCopyFiles/' + config['PRESERVATION_FILES_NAME'] + '/'
acf_path = os.path.join(config['WORKING_PATH'], acf_dir)
# ...however, if it already exists, it is possible to skip its creation
make_acf = False
if not os.path.exists(acf_path):
# Create directory
os.mkdir(acf_path)
make_acf = True
print("Directory '% s' created" % acf_dir)
print("Directory '% s' created" % acf_path)
else:
print(ConsoleColors.PURPLE + 'AccessCopyFiles directory already exists!' + ConsoleColors.END)
overwrite = input('Do you want to overwrite it? [y/n]: ')
......@@ -81,14 +83,14 @@ if __name__ == '__main__':
shutil.rmtree(acf_path)
os.mkdir(acf_path)
make_acf = True
print("Directory '% s' overwritten" % acf_dir)
print("Directory '% s' overwritten" % acf_path)
elif overwrite.casefold() != 'n':
print(ConsoleColors.RED + 'Unknown command, exiting' + ConsoleColors.END)
quit(os.EX_USAGE)
if make_acf:
# Copy RestoredAudioFiles
raf_path = os.path.join(config['INPUT_PATH'], 'RestoredAudioFiles')
raf_path = os.path.join(temp_path, 'RestoredAudioFiles')
if not os.path.exists(raf_path):
print(ConsoleColors.RED + 'RestoredAudioFiles directory not found!' + ConsoleColors.END)
quit(os.EX_NOINPUT)
......@@ -100,48 +102,51 @@ if __name__ == '__main__':
# Copy Editing List
try:
shutil.copy2(config['INPUT_PATH'] + 'EditingList.json', acf_path)
shutil.copy2(temp_path + 'EditingList.json', acf_path)
except FileNotFoundError:
print(ConsoleColors.RED + 'EditingList.json file not found!' + ConsoleColors.END)
quit(os.EX_NOINPUT)
print("Editing List copied")
# Create Irregularity Images archive
ii_path = os.path.join(config['INPUT_PATH'], 'IrregularityImages')
ii_path = os.path.join(temp_path, 'IrregularityImages')
if not os.path.exists(ii_path):
print(ConsoleColors.RED + 'IrregularityImages directory not found!' + ConsoleColors.END)
quit(os.EX_NOINPUT)
irregularity_images = os.listdir(ii_path)
if len(irregularity_images) == 1:
print(ConsoleColors.YELLOW + 'IrregularityImages directory is empty' + ConsoleColors.END)
shutil.make_archive(acf_path + 'IrregularityImages', 'zip', config['INPUT_PATH'], 'IrregularityImages')
shutil.make_archive(acf_path + 'IrregularityImages', 'zip', temp_path, 'IrregularityImages')
print("Irregularity Images archive created")
# Copy Irregularity File
try:
shutil.copy2(config['INPUT_PATH'] + 'IrregularityFile.json', acf_path)
shutil.copy2(temp_path + 'TapeIrregularityClassifier_IrregularityFileOutput2.json', acf_path + 'IrregularityFile.json')
except FileNotFoundError:
print(ConsoleColors.RED + 'IrregularityFile.json file not found!' + ConsoleColors.END)
print(ConsoleColors.RED + 'TapeIrregularityClassifier_IrregularityFileOutput2.json file not found!' + ConsoleColors.END)
quit(os.EX_NOINPUT)
print("Irregularity File copied")
# End Access Copy Files
print(ConsoleColors.GREEN + ConsoleColors.BOLD + "Success!" + ConsoleColors.END)
# Preservation Master Files
print('\n' + ConsoleColors.BOLD + 'Creation of Preservation Master Files...' + ConsoleColors.END)
# By default, PreservationMasterFiles directory is created in the output path...
pmf_dir = 'PreservationMasterFiles/'
pmf_path = os.path.join(config['OUTPUT_PATH'], pmf_dir)
pmf_dir = 'PreservationMasterFiles/' + config['PRESERVATION_FILES_NAME'] + '/'
pmf_path = os.path.join(config['WORKING_PATH'], pmf_dir)
# ...however, if it already exists, it is possible to skip its creation
if not os.path.exists(pmf_path):
os.mkdir(pmf_path)
print("Directory '% s' created" % pmf_dir)
print("Directory '% s' created" % pmf_path)
else:
print(ConsoleColors.PURPLE + 'PreservationMasterFiles directory already exists!' + ConsoleColors.END)
overwrite = input('Do you want to overwrite it? [y/n]: ')
if overwrite.casefold() == 'y':
shutil.rmtree(pmf_path)
os.mkdir(pmf_path)
print("Directory '% s' overwritten" % pmf_dir)
print("Directory '% s' overwritten" % pmf_path)
elif overwrite.casefold() == 'n':
print('Exit\n')
quit(os.EX_OK)
......@@ -150,21 +155,21 @@ if __name__ == '__main__':
quit(os.EX_USAGE)
# Copy Preservation Audio File
audio_file = 'PreservationAudioFile.wav'
audio_file = config['PRESERVATION_FILES_NAME'] + '.wav'
try:
shutil.copy2(config['INPUT_PATH'] + audio_file, pmf_path)
shutil.copy2(os.path.join(config['WORKING_PATH'], 'PreservationAudioFile/') + audio_file, pmf_path + 'PreservationAudioFile.wav')
except FileNotFoundError:
print(ConsoleColors.RED + audio_file + ' file not found!' + ConsoleColors.END)
quit(os.EX_NOINPUT)
print("Preservation Audio File copied")
# Create Preservation Audio-Visual File with substituted audio
video_file = 'PreservationAudioVisualFile.mov'
video_file = config['PRESERVATION_FILES_NAME'] + '.mov'
try:
video = VideoFileClip(config['INPUT_PATH'] + video_file)
audio = AudioFileClip(config['INPUT_PATH'] + audio_file)
video = VideoFileClip(os.path.join(config['WORKING_PATH'], 'PreservationAudioVisualFile/') + video_file)
audio = AudioFileClip(os.path.join(config['WORKING_PATH'], 'PreservationAudioFile/') + audio_file)
# Open Irregularity File to get offset
irregularity_file_json = open(config['INPUT_PATH'] + 'IrregularityFile.json')
irregularity_file_json = open(temp_path + 'TapeIrregularityClassifier_IrregularityFileOutput2.json')
irregularity_file = json.load(irregularity_file_json)
offset = irregularity_file['Offset']/1000
if offset > 0:
......@@ -179,12 +184,12 @@ if __name__ == '__main__':
quit(os.EX_NOINPUT)
# Create Irregularity Images archive (already checked)
shutil.make_archive(pmf_path + 'IrregularityImages', 'zip', config['INPUT_PATH'], 'IrregularityImages')
shutil.make_archive(pmf_path + 'IrregularityImages', 'zip', temp_path, 'IrregularityImages')
print("Irregularity Images archive created")
# Copy Irregularity File (already checked)
shutil.copy2(config['INPUT_PATH'] + 'IrregularityFile.json', pmf_path)
shutil.copy2(temp_path + 'TapeIrregularityClassifier_IrregularityFileOutput2.json', pmf_path + 'IrregularityFile.json')
print("Irregularity File copied")
# End
print('\n' + ConsoleColors.GREEN + ConsoleColors.BOLD + "Success!" + ConsoleColors.END + '\n')
# End Preservation Master Files
print(ConsoleColors.GREEN + ConsoleColors.BOLD + "Success!" + ConsoleColors.END + '\n')
Supports Markdown
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