calamari__

eta -- Report x264 encoding progress and completion ETA

Jul 16th, 2012
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Report x264 video encoding progress and estimated time of completion
  3. # Programmed by Jeffry Johnston, 2012. Released to the public domain.
  4. import sys, time
  5. if len(sys.argv) != 4: print "Usage: eta VIDEO_LENGTH_IN_SECONDS VIDEO_FPS X264_LOG_FILENAME\nExample: eta 5781.835 24000/1001 video.xlog"; sys.exit(1)
  6. fps_s = sys.argv[2]
  7. i = fps_s.find("/")
  8. if i == -1: i = fps_s.find(":")
  9. if i != -1: video_fps = float(fps_s[:i]) / float(fps_s[i + 1:])
  10. else: video_fps = float(fps_s)
  11. video_frames = int(round(float(sys.argv[1]) * video_fps))
  12. while 1:
  13.   f = open(sys.argv[3], "r"); l = f.read().split("\r")[-2].split(); f.close()
  14.   frames_done = int(l[0])
  15.   average_fps = float(l[2])
  16.   print "Progress: " + str(int(10000 * (float(frames_done) / video_frames)) / 100.0) + "% (" + str(frames_done) + "/" + str(video_frames) + " frames),",
  17.   print "ETA: " + time.strftime("%a %b %d, %I:%M:%S %p", time.localtime(time.time() + ((video_frames - frames_done) / average_fps))) + " (" + str(average_fps) + " fps)."
  18.   try: time.sleep(15 * 60) # wait 15 minutes before reporting again
  19.   except KeyboardInterrupt: print; sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment