diff --git a/over-video.py b/over-video.py index 29e2c4e..76f9b22 100755 --- a/over-video.py +++ b/over-video.py @@ -129,7 +129,8 @@ if __name__ == '__main__': main.print('target §y%s§/ §ris not a readable file§/, skipping' %(tgt), prefix.fail) 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 @@ -156,9 +157,7 @@ if __name__ == '__main__': amount_as = len(audio_streams) if amount_vs > 1: - main.print('detected §r%d§/ video streams' %(amount_vs), prefix.fail) - print(video_streams) - main.exit(1) + main.print('detected §r%d§/ video streams, picking the "best" one (see man 1 ffmpeg, section STREAM SELECTION)' %(amount_vs), prefix.warn) 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) @@ -218,8 +217,21 @@ if __name__ == '__main__': command.normalize_prepass.INFILE = 'file:' + str(files.infile) 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 = [] while True: @@ -232,7 +244,8 @@ if __name__ == '__main__': if b'frame=' in out: 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: break @@ -247,7 +260,7 @@ if __name__ == '__main__': print(output.decode('utf-8')) raise RuntimeError - pb.blank() + pb.end() main.print('detected volume %.1f dB, correction %.1f dB' %(info.mean_volume, info.volume_correction)) else: @@ -326,7 +339,7 @@ if __name__ == '__main__': 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: cmd = ' '.join(encode_cmd.dump(pretty=True)) @@ -339,7 +352,24 @@ if __name__ == '__main__': main.print('will encode into §B%s§/' %(files.tmpfile)) 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) @@ -351,15 +381,17 @@ if __name__ == '__main__': if out: if b'frame=' in out: frame_id = re.findall(b'frame= *(\d+) ', out)[0] - pb.update(int(frame_id)) + pb.set("f", int(frame_id)) elif out is None: 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, 'B') + new_filesize = over.core.text.Unit(files.tmpfile.stat().st_size, 'o') - pb.blank() + pb.end() if encode_cmd.returncode == 0: main.print('encoding finished: %s -> %s' %(original_filesize, new_filesize), prefix.done)