                            "-crf" 51 "-preset" "ultrafast" "/dev/null"))]
     (when-let [crop (-> (re-seq #"crop=[0-9:]*" output) distinct sort last)]
       (when-not (.endsWith crop ":0:0") crop))))
+
+(defn deinterlace
+  [spec]
+  (merge spec
+         (when (detect-interlace (:input spec))
+           {:deinterlace "pullup,dejudder,idet,yadif=deint=interlaced:mode=1"})))
 
 (defn crop
   "Returns an updated spec with crop information."

      ["-map" (str "0:" (:index video-stream)) "-c:v" "libx264" "-crf" quality "-profile:v" "high" "-level" 41]
      ["-map" (str "0:" (:index video-stream)) "-c:v" "copy"])))

(defn crop-resize-options
  "Returns the ffmpeg options for cropping and/or resizing the video."
  [{:keys [crop scale]}]
  (let [args (str/join "," (remove str/blank? [crop scale]))]
    (when-not (str/blank? args)
      ["-vf" args])))


  [spec]
  ["ffmpeg" "-i" (:input spec)
   (video-options spec)
   (video-filter-options spec)
   (audio-options spec)
   (subtitle-options spec)
   "-f" (ffmpeg-format (:format spec))
