2020-01-14 18:43:28 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
import logging
|
2020-02-03 23:53:27 +01:00
|
|
|
import platform
|
2020-01-14 18:43:28 +01:00
|
|
|
import sys
|
2020-01-30 18:37:08 +01:00
|
|
|
|
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
import lbry.wallet # needed to make the following line work (it's a bug):
|
2020-01-14 18:43:28 +01:00
|
|
|
from lbry.conf import TranscodeConfig
|
|
|
|
from lbry.file_analysis import VideoFileAnalyzer
|
|
|
|
|
|
|
|
|
|
|
|
def enable_logging():
|
|
|
|
root = logging.getLogger()
|
|
|
|
root.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
handler = logging.StreamHandler(sys.stdout)
|
|
|
|
handler.setLevel(logging.DEBUG)
|
2020-03-17 20:43:44 +01:00
|
|
|
formatter = logging.Formatter('%(message)s')
|
2020-01-14 18:43:28 +01:00
|
|
|
handler.setFormatter(formatter)
|
|
|
|
root.addHandler(handler)
|
|
|
|
|
|
|
|
|
2020-01-30 18:37:08 +01:00
|
|
|
async def process_video(analyzer, video_file):
|
2020-01-14 18:43:28 +01:00
|
|
|
try:
|
|
|
|
await analyzer.verify_or_repair(True, False, video_file)
|
|
|
|
print("No concerns. Ship it!")
|
2020-02-11 20:23:19 +01:00
|
|
|
except (FileNotFoundError, ValueError) as e:
|
|
|
|
print("Analysis failed.", str(e))
|
2020-01-14 18:43:28 +01:00
|
|
|
except Exception as e:
|
|
|
|
print(str(e))
|
2020-01-30 18:37:08 +01:00
|
|
|
transcode = input("Would you like to make a repaired clone now? [y/N] ")
|
2020-01-14 18:43:28 +01:00
|
|
|
if transcode == "y":
|
|
|
|
try:
|
|
|
|
new_video_file = await analyzer.verify_or_repair(True, True, video_file)
|
|
|
|
print("Successfully created ", new_video_file)
|
|
|
|
except Exception as e:
|
|
|
|
print("Unable to complete the transcode. Message: ", str(e))
|
|
|
|
|
|
|
|
|
2020-01-30 18:37:08 +01:00
|
|
|
def main():
|
|
|
|
if len(sys.argv) < 2:
|
|
|
|
print("Usage: check_video.py <path to video file>", file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
enable_logging()
|
|
|
|
|
|
|
|
video_file = sys.argv[1]
|
|
|
|
conf = TranscodeConfig()
|
|
|
|
analyzer = VideoFileAnalyzer(conf)
|
|
|
|
try:
|
2020-02-03 23:53:27 +01:00
|
|
|
asyncio.run(process_video(analyzer, video_file))
|
2020-01-30 18:37:08 +01:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-01-14 18:43:28 +01:00
|
|
|
if __name__ == '__main__':
|
2020-01-30 18:37:08 +01:00
|
|
|
main()
|