change to over.core.text.ProgressBar2
change bytes to octets
This commit is contained in:
parent
09483b6c7c
commit
d2bc68885e
1 changed files with 45 additions and 13 deletions
|
@ -129,7 +129,8 @@ if __name__ == '__main__':
|
||||||
main.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
|
||||||
|
|
||||||
main.print('processing §B%s§/' %(tgt), prefix.start)
|
original_filesize = over.core.text.Unit(files.infile.stat().st_size, 'o')
|
||||||
|
main.print('processing §B%s§/ (%s)' %(tgt, original_filesize), prefix.start)
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
# identify the input file
|
# identify the input file
|
||||||
|
@ -156,9 +157,7 @@ if __name__ == '__main__':
|
||||||
amount_as = len(audio_streams)
|
amount_as = len(audio_streams)
|
||||||
|
|
||||||
if amount_vs > 1:
|
if amount_vs > 1:
|
||||||
main.print('detected §r%d§/ video streams' %(amount_vs), prefix.fail)
|
main.print('detected §r%d§/ video streams, picking the "best" one (see man 1 ffmpeg, section STREAM SELECTION)' %(amount_vs), prefix.warn)
|
||||||
print(video_streams)
|
|
||||||
main.exit(1)
|
|
||||||
|
|
||||||
if amount_as > 1:
|
if amount_as > 1:
|
||||||
main.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)
|
||||||
|
@ -218,8 +217,21 @@ if __name__ == '__main__':
|
||||||
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.text.ProgressBar(120, info.duration, 's')
|
pb = over.core.text.ProgressBar2(
|
||||||
|
"§%a [§=a>§ A] §sa (Trem=§TA)",
|
||||||
|
{
|
||||||
|
"a": {
|
||||||
|
"unit": "s",
|
||||||
|
"top": info.duration,
|
||||||
|
"precision": 1,
|
||||||
|
"min_width_raw": 0,
|
||||||
|
"min_width_rate": 0,
|
||||||
|
"min_width_time": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
pb.render()
|
||||||
output_buffer = []
|
output_buffer = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -232,7 +244,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if b'frame=' in out:
|
if b'frame=' in out:
|
||||||
frame_id = re.findall(b'frame= *(\d+) ', out)[0]
|
frame_id = re.findall(b'frame= *(\d+) ', out)[0]
|
||||||
pb.update(int(frame_id) / info.video_fps.value)
|
pb.set("a", int(frame_id) / info.video_fps.value)
|
||||||
|
pb.render()
|
||||||
|
|
||||||
elif out is None:
|
elif out is None:
|
||||||
break
|
break
|
||||||
|
@ -247,7 +260,7 @@ if __name__ == '__main__':
|
||||||
print(output.decode('utf-8'))
|
print(output.decode('utf-8'))
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
pb.blank()
|
pb.end()
|
||||||
main.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:
|
||||||
|
@ -326,7 +339,7 @@ if __name__ == '__main__':
|
||||||
encode_cmd.VIDEO = command.sub_x265
|
encode_cmd.VIDEO = command.sub_x265
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
# run the command if armed
|
# run the command iff armed
|
||||||
|
|
||||||
if main.cfg.dump_commands or main.cfg.armed:
|
if main.cfg.dump_commands or main.cfg.armed:
|
||||||
cmd = ' '.join(encode_cmd.dump(pretty=True))
|
cmd = ' '.join(encode_cmd.dump(pretty=True))
|
||||||
|
@ -339,7 +352,24 @@ if __name__ == '__main__':
|
||||||
main.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.text.ProgressBar(120, int(info.video_fps.value * info.duration), 'frames')
|
pb = over.core.text.ProgressBar2(
|
||||||
|
"§%f §rs [§=f>§ F] §sf (§ss) (Sest=§zs, Trem=§TF)",
|
||||||
|
{
|
||||||
|
"f": {
|
||||||
|
"unit": "f",
|
||||||
|
"top": int(info.video_fps.value * info.duration),
|
||||||
|
"precision": 1,
|
||||||
|
"min_width_rate": 9
|
||||||
|
},
|
||||||
|
"s": {
|
||||||
|
"unit": "o", # octets are cool
|
||||||
|
"top": None, # size is unknown at the start but will be estimated during updates
|
||||||
|
"precision": 1,
|
||||||
|
"min_width_raw": 9,
|
||||||
|
"min_width_rate": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
encode_cmd.run(stderr=True)
|
encode_cmd.run(stderr=True)
|
||||||
|
|
||||||
|
@ -351,15 +381,17 @@ if __name__ == '__main__':
|
||||||
if out:
|
if out:
|
||||||
if b'frame=' in out:
|
if b'frame=' in out:
|
||||||
frame_id = re.findall(b'frame= *(\d+) ', out)[0]
|
frame_id = re.findall(b'frame= *(\d+) ', out)[0]
|
||||||
pb.update(int(frame_id))
|
pb.set("f", int(frame_id))
|
||||||
|
|
||||||
elif out is None:
|
elif out is None:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
pb.set("s", files.tmpfile.stat().st_size)
|
||||||
|
pb.render()
|
||||||
|
|
||||||
original_filesize = over.core.text.Unit(files.infile.stat().st_size, 'B')
|
new_filesize = over.core.text.Unit(files.tmpfile.stat().st_size, 'o')
|
||||||
new_filesize = over.core.text.Unit(files.tmpfile.stat().st_size, 'B')
|
|
||||||
|
|
||||||
pb.blank()
|
pb.end()
|
||||||
|
|
||||||
if encode_cmd.returncode == 0:
|
if encode_cmd.returncode == 0:
|
||||||
main.print('encoding finished: %s -> %s' %(original_filesize, new_filesize), prefix.done)
|
main.print('encoding finished: %s -> %s' %(original_filesize, new_filesize), prefix.done)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue