fix interpreter path
update to current over
This commit is contained in:
parent
fd46dc9590
commit
5ffb173513
5 changed files with 51 additions and 51 deletions
2
aux.py
2
aux.py
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/env python3
|
#! /usr/bin/env python3
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/env python
|
#! /usr/bin/env python2
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# Res Tranceliī
|
# Res Tranceliī
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/env python
|
#! /usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os, pickle, re, sys, time, traceback
|
import os, pickle, re, sys, time, traceback
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/env python3
|
#! /usr/bin/env python3
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -8,16 +8,12 @@ import pathlib
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import version
|
||||||
|
|
||||||
from aux import parse_fps, to_Path
|
from aux import parse_fps, to_Path
|
||||||
from version import _version
|
|
||||||
|
|
||||||
Command = over.core.cmd.Command
|
Command = over.core.cmd.Command
|
||||||
|
prefix = over.core.text.prefix
|
||||||
# --------------------------------------------------
|
|
||||||
|
|
||||||
prefix = over.core.textui.prefix
|
|
||||||
_print = over.core.textui.Output('over.video')
|
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
|
@ -38,7 +34,7 @@ command.sub_copy_video = Command('-codec:v', 'copy')
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main = over.core.app.Main('Over-Video', '%d (%s)' %_version, 'AWARE-Overwatch Joint Software License', '~/.over/video.cfg')
|
main = over.core.app.Main('over-video', 'Overwatch Video', version.str, 'AO-JSL', use_cfg_file=True)
|
||||||
main.add_option('audio', 'str', 'vorbis', 'Audio codec to use, either §mvorbis§/, §mpcm§/, §mcopy§/ or §mdrop§/.', short_name='a')
|
main.add_option('audio', 'str', 'vorbis', 'Audio codec to use, either §mvorbis§/, §mpcm§/, §mcopy§/ or §mdrop§/.', short_name='a')
|
||||||
main.add_option('audio-quality', 'float', 2, 'Audio encoding quality with -1 being the worst and 10 being the best.', short_name='q')
|
main.add_option('audio-quality', 'float', 2, 'Audio encoding quality with -1 being the worst and 10 being the best.', short_name='q')
|
||||||
main.add_option('video', 'str', 'x264', 'Video codec to use, either §mx264§/, §mtheora§/, §mcopy§/ or §mdrop§/.', short_name='v')
|
main.add_option('video', 'str', 'x264', 'Video codec to use, either §mx264§/, §mtheora§/, §mcopy§/ or §mdrop§/.', short_name='v')
|
||||||
|
@ -92,24 +88,24 @@ if __name__ == '__main__':
|
||||||
elif main.cfg.audio == 'vorbis':
|
elif main.cfg.audio == 'vorbis':
|
||||||
files.container = 'ogg'
|
files.container = 'ogg'
|
||||||
|
|
||||||
_print('settings', prefix.start, suffix=':\n')
|
main.print('settings', prefix.start, suffix=':\n')
|
||||||
_print('audio: %s' %(', '.join(audio_words)))
|
main.print('audio: %s' %(', '.join(audio_words)))
|
||||||
_print('video: %s' %(', '.join(video_words)))
|
main.print('video: %s' %(', '.join(video_words)))
|
||||||
_print('container: §gtype§/=§m%s§/' %(files.container))
|
main.print('container: §gtype§/=§m%s§/' %(files.container))
|
||||||
|
|
||||||
if main.cfg.move_source:
|
if main.cfg.move_source:
|
||||||
_print('move source files to §B%s§//' %(main.cfg.move_source))
|
main.print('move source files to §B%s§//' %(main.cfg.move_source))
|
||||||
|
|
||||||
if main.cfg.audio not in ('drop', 'copy', 'pcm', 'vorbis'):
|
if main.cfg.audio not in ('drop', 'copy', 'pcm', 'vorbis'):
|
||||||
_print('unknown audio codec', prefix.fail)
|
main.print('unknown audio codec', prefix.fail)
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if main.cfg.video not in ('drop', 'copy', 'theora', 'x264'):
|
if main.cfg.video not in ('drop', 'copy', 'theora', 'x264'):
|
||||||
_print('unknown video codec', prefix.fail)
|
main.print('unknown video codec', prefix.fail)
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if not main.targets:
|
if not main.targets:
|
||||||
_print('no files specified', prefix.warn)
|
main.print('no files specified', prefix.warn)
|
||||||
|
|
||||||
for tgt in main.targets:
|
for tgt in main.targets:
|
||||||
print()
|
print()
|
||||||
|
@ -120,10 +116,10 @@ if __name__ == '__main__':
|
||||||
files.move_infile_to = to_Path(main.cfg.move_source) / files.infile.name if main.cfg.move_source else None
|
files.move_infile_to = to_Path(main.cfg.move_source) / files.infile.name if main.cfg.move_source else None
|
||||||
|
|
||||||
if not os.path.exists(tgt) or os.path.isdir(tgt):
|
if not os.path.exists(tgt) or os.path.isdir(tgt):
|
||||||
_print('target §y%s§/ §ris not a readable file§/, skipping' %(tgt), prefix.fail)
|
main.print('target §y%s§/ §ris not a readable file§/, skipping' %(tgt), prefix.fail)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_print('processing §B%s§/' %(tgt), prefix.start)
|
main.print('processing §B%s§/' %(tgt), prefix.start)
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
# identify the input file
|
# identify the input file
|
||||||
|
@ -146,54 +142,54 @@ if __name__ == '__main__':
|
||||||
amount_as = len(audio_streams)
|
amount_as = len(audio_streams)
|
||||||
|
|
||||||
if amount_vs != 1:
|
if amount_vs != 1:
|
||||||
_print('detected §r%d§/ video streams' %(amount_vs), prefix.fail)
|
main.print('detected §r%d§/ video streams' %(amount_vs), prefix.fail)
|
||||||
print(video_streams)
|
print(video_streams)
|
||||||
main.exit(1)
|
main.exit(1)
|
||||||
|
|
||||||
if amount_as > 1:
|
if amount_as > 1:
|
||||||
_print('detected §y%d§/ audio streams, picking the "best" one (see man 1 ffmpeg, section STREAM SELECTION)' %(amount_as), prefix.warn)
|
main.print('detected §y%d§/ audio streams, picking the "best" one (see man 1 ffmpeg, section STREAM SELECTION)' %(amount_as), prefix.warn)
|
||||||
|
|
||||||
video = video_streams[0]
|
video = video_streams[0]
|
||||||
|
|
||||||
info.video_codec = video['codec_name']
|
info.video_codec = video['codec_name']
|
||||||
info.video_size_x = video['width']
|
info.video_size_x = video['width']
|
||||||
info.video_size_y = video['height']
|
info.video_size_y = video['height']
|
||||||
info.video_fps = over.core.textui.Unit(parse_fps(video['r_frame_rate']), 'Hz')
|
info.video_fps = over.core.text.Unit(parse_fps(video['r_frame_rate']), 'Hz')
|
||||||
info.video_bitrate = over.core.textui.Unit(video['bit_rate'], 'b/s') if 'bit_rate' in video else '§r??§/'
|
info.video_bitrate = over.core.text.Unit(video['bit_rate'], 'b/s') if 'bit_rate' in video else '§r??§/'
|
||||||
|
|
||||||
if audio_streams:
|
if audio_streams:
|
||||||
audio = audio_streams[0]
|
audio = audio_streams[0]
|
||||||
info.audio_codec = audio['codec_name']
|
info.audio_codec = audio['codec_name']
|
||||||
info.audio_channels = audio['channels']
|
info.audio_channels = audio['channels']
|
||||||
info.audio_samplerate = over.core.textui.Unit(audio['sample_rate'], 'Hz')
|
info.audio_samplerate = over.core.text.Unit(audio['sample_rate'], 'Hz')
|
||||||
info.audio_language = audio['tags']['language'] if 'tags' in audio and 'language' in audio['tags'] else 'und'
|
info.audio_language = audio['tags']['language'] if 'tags' in audio and 'language' in audio['tags'] else 'und'
|
||||||
info.audio_bitrate = over.core.textui.Unit(audio['bit_rate'], 'b/s') if 'bit_rate' in audio else '§r??§/'
|
info.audio_bitrate = over.core.text.Unit(audio['bit_rate'], 'b/s') if 'bit_rate' in audio else '§r??§/'
|
||||||
|
|
||||||
except:
|
except:
|
||||||
_print('exception while reading identify_dict, dump follows', prefix.fail)
|
main.print('exception while reading identify_dict, dump follows', prefix.fail)
|
||||||
print(identify_dict)
|
print(identify_dict)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# TODO wordify :-)
|
# TODO wordify :-)
|
||||||
_print('§mvideo§/: size=§b%d§/x§b%d§/ px, framerate=%s, codec=%s, bitrate=%s' %(info.video_size_x, info.video_size_y, info.video_fps, info.video_codec, info.video_bitrate))
|
main.print('§mvideo§/: size=§b%d§/x§b%d§/ px, framerate=%s, codec=%s, bitrate=%s' %(info.video_size_x, info.video_size_y, info.video_fps, info.video_codec, info.video_bitrate))
|
||||||
|
|
||||||
if audio_streams:
|
if audio_streams:
|
||||||
_print('§caudio§/: channels=§b%d§/, samplerate=%s, codec=%s, bitrate=%s, language=%s' %(info.audio_channels, info.audio_samplerate, info.audio_codec, info.audio_bitrate, info.audio_language))
|
main.print('§caudio§/: channels=§b%d§/, samplerate=%s, codec=%s, bitrate=%s, language=%s' %(info.audio_channels, info.audio_samplerate, info.audio_codec, info.audio_bitrate, info.audio_language))
|
||||||
else:
|
else:
|
||||||
_print('§caudio§/: §yNone§/', prefix.warn)
|
main.print('§caudio§/: §yNone§/', prefix.warn)
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
# normalization pre-pass
|
# normalization pre-pass
|
||||||
|
|
||||||
if audio_streams and main.cfg.normalize and (main.cfg.armed or main.cfg.dump_commands) and (not main.cfg.audio == 'drop'):
|
if audio_streams and main.cfg.normalize and (main.cfg.armed or main.cfg.dump_commands) and (not main.cfg.audio == 'drop'):
|
||||||
if main.cfg.normalize_override == 0.0:
|
if main.cfg.normalize_override == 0.0:
|
||||||
_print('running normalization pre-pass')
|
main.print('running normalization pre-pass')
|
||||||
|
|
||||||
command.normalize_prepass.reset()
|
command.normalize_prepass.reset()
|
||||||
command.normalize_prepass.INFILE = 'file:' + str(files.infile)
|
command.normalize_prepass.INFILE = 'file:' + str(files.infile)
|
||||||
command.normalize_prepass.run(stderr=True)
|
command.normalize_prepass.run(stderr=True)
|
||||||
|
|
||||||
pb = over.core.textui.ProgressBar(60, int(info.video_fps.value * info.duration), 'frames')
|
pb = over.core.text.ProgressBar(60, int(info.video_fps.value * info.duration), 'frames')
|
||||||
|
|
||||||
output_buffer = []
|
output_buffer = []
|
||||||
|
|
||||||
|
@ -218,16 +214,16 @@ if __name__ == '__main__':
|
||||||
info.mean_volume = float(re.findall(b'mean_volume: (-\d+\.\d+) dB', output)[0])
|
info.mean_volume = float(re.findall(b'mean_volume: (-\d+\.\d+) dB', output)[0])
|
||||||
info.volume_correction = main.cfg.normalize_target - info.mean_volume
|
info.volume_correction = main.cfg.normalize_target - info.mean_volume
|
||||||
else:
|
else:
|
||||||
_print('§runexpected ffmpeg output§/, dump follows', prefix.fail, suffix=':\n')
|
main.print('§runexpected ffmpeg output§/, dump follows', prefix.fail, suffix=':\n')
|
||||||
print(output.decode('utf-8'))
|
print(output.decode('utf-8'))
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
pb.blank()
|
pb.blank()
|
||||||
_print('detected volume %.1f dB, correction %.1f dB' %(info.mean_volume, info.volume_correction))
|
main.print('detected volume %.1f dB, correction %.1f dB' %(info.mean_volume, info.volume_correction))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
info.volume_correction = main.cfg.normalize_override
|
info.volume_correction = main.cfg.normalize_override
|
||||||
_print('using user-supplied volume correction §m%.1f dB§/' %(info.volume_correction))
|
main.print('using user-supplied volume correction §m%.1f dB§/' %(info.volume_correction))
|
||||||
|
|
||||||
info.normalize_command = command.sub_normalize
|
info.normalize_command = command.sub_normalize
|
||||||
info.normalize_command.reset()
|
info.normalize_command.reset()
|
||||||
|
@ -292,14 +288,14 @@ if __name__ == '__main__':
|
||||||
cmd = ' '.join(encode_cmd.dump(pretty=True))
|
cmd = ' '.join(encode_cmd.dump(pretty=True))
|
||||||
|
|
||||||
if main.cfg.armed:
|
if main.cfg.armed:
|
||||||
_print('executing §B%s§/' %(cmd), prefix.start)
|
main.print('executing §B%s§/' %(cmd), prefix.start)
|
||||||
else:
|
else:
|
||||||
_print('will execute §B%s§/' %(cmd))
|
main.print('will execute §B%s§/' %(cmd))
|
||||||
else:
|
else:
|
||||||
_print('will encode into §B%s§/' %(files.tmpfile))
|
main.print('will encode into §B%s§/' %(files.tmpfile))
|
||||||
|
|
||||||
if main.cfg.armed:
|
if main.cfg.armed:
|
||||||
pb = over.core.textui.ProgressBar(60, int(info.video_fps.value * info.duration), 'frames')
|
pb = over.core.text.ProgressBar(60, int(info.video_fps.value * info.duration), 'frames')
|
||||||
|
|
||||||
encode_cmd.run(stderr=True)
|
encode_cmd.run(stderr=True)
|
||||||
|
|
||||||
|
@ -316,15 +312,15 @@ if __name__ == '__main__':
|
||||||
elif out is None:
|
elif out is None:
|
||||||
break
|
break
|
||||||
|
|
||||||
original_filesize = over.core.textui.Unit(files.infile.stat().st_size, 'B')
|
original_filesize = over.core.text.Unit(files.infile.stat().st_size, 'B')
|
||||||
new_filesize = over.core.textui.Unit(files.tmpfile.stat().st_size, 'B')
|
new_filesize = over.core.text.Unit(files.tmpfile.stat().st_size, 'B')
|
||||||
|
|
||||||
pb.blank()
|
pb.blank()
|
||||||
|
|
||||||
if encode_cmd.returncode == 0:
|
if encode_cmd.returncode == 0:
|
||||||
_print('encoding finished: %s -> %s' %(original_filesize, new_filesize), prefix.done)
|
main.print('encoding finished: %s -> %s' %(original_filesize, new_filesize), prefix.done)
|
||||||
else:
|
else:
|
||||||
_print('§rencoding failed§/, ffmpeg returned §y%d§/' %(encode_cmd.returncode), prefix.fail)
|
main.print('§rencoding failed§/, ffmpeg returned §y%d§/' %(encode_cmd.returncode), prefix.fail)
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
@ -335,20 +331,20 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if not move_to_dir.is_dir():
|
if not move_to_dir.is_dir():
|
||||||
if main.cfg.armed:
|
if main.cfg.armed:
|
||||||
_print('creating directory §B%s§/' %(move_to_dir), prefix.start)
|
main.print('creating directory §B%s§/' %(move_to_dir), prefix.start)
|
||||||
move_to_dir.mkdir()
|
move_to_dir.mkdir()
|
||||||
else:
|
else:
|
||||||
_print('will create directory §B%s§/' %(move_to_dir))
|
main.print('will create directory §B%s§/' %(move_to_dir))
|
||||||
|
|
||||||
if files.move_infile_to:
|
if files.move_infile_to:
|
||||||
if main.cfg.armed:
|
if main.cfg.armed:
|
||||||
_print('moving §B%s§/ -> §B%s§/' %(files.infile, files.move_infile_to), prefix.start)
|
main.print('moving §B%s§/ -> §B%s§/' %(files.infile, files.move_infile_to), prefix.start)
|
||||||
files.infile.rename(files.move_infile_to)
|
files.infile.rename(files.move_infile_to)
|
||||||
else:
|
else:
|
||||||
_print('will move §B%s§/ -> §B%s§/' %(files.infile, files.move_infile_to))
|
main.print('will move §B%s§/ -> §B%s§/' %(files.infile, files.move_infile_to))
|
||||||
|
|
||||||
if main.cfg.armed:
|
if main.cfg.armed:
|
||||||
_print('moving §B%s§/ -> §B%s§/' %(files.tmpfile, files.outfile), prefix.start)
|
main.print('moving §B%s§/ -> §B%s§/' %(files.tmpfile, files.outfile), prefix.start)
|
||||||
files.tmpfile.rename(files.outfile)
|
files.tmpfile.rename(files.outfile)
|
||||||
else:
|
else:
|
||||||
_print('will move §B%s§/ -> §B%s§/' %(files.tmpfile, files.outfile))
|
main.print('will move §B%s§/ -> §B%s§/' %(files.tmpfile, files.outfile))
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
#! /bin/env python3
|
#! /usr/bin/env python3
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
_version = (0, '00000000') # OVER_VERSION_IDENTIFIER
|
_version = (0, '00000000') # OVER_VERSION_IDENTIFIER
|
||||||
|
|
||||||
|
rev = _version[0]
|
||||||
|
commit = _version[1]
|
||||||
|
str = '%d (%s)' %_version
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue