        (map (comp #(Integer/parseInt %) name video-size :width))
        sort first str keyword))
 
+(defn- largest-size
+  [video]
+  (->> (:containers video)
+       (map (comp #(Integer/parseInt %) name video-size :width))
+       sort last str keyword))
+
 (defn- next-encode-size
   "Returns the next size for the default encoding."
   [video fmt size]

  (and (not-any? #(= (:mimetype %) "text/vtt") (:subtitles video))
       (some #(not= (:mimetype %) "text/vtt") (:subtitles video))))

(defn- encode
  "Creates an encoding spec and queues it for processing."
  [folder video fmt size minimize?]

  (log/debug "processing video" (str video))
  (when (should-encode-subtitles? video)
    (encode-subtitles folder video))
  (let [size (largest-encode-size video size)
        [fmt size minimize?] (next-encoding video fmt size apple? download min-download?)]
    (if (and size fmt)
      (encode folder video fmt (encode-size video size) minimize?)
      (when-not *fake-encode*
