<commit_before>open Gstreamer

let timeToString nsd =
  let msd = Int64.(to_int(div nsd (of_int 1000000))) in
  let h = msd / 3600000 in
  let m = (msd - (h * 3600000)) / 60000 in
  let s = (msd - (h * 3600000) - (m * 60000)) / 1000 in
  let ms = msd - (h * 3600000) - (m * 60000) - (s * 1000) in
  let h = if h = 0 then "" else Printf.sprintf "%d:" h in 
  let ms = if ms = 0 then "" else Printf.sprintf ".%d" ms in 
  Printf.sprintf "%s%d:%d%s" h m s ms

let printProgression bin =
  let position = timeToString(Element.position bin Format.Time) in
  let duration = timeToString(Element.duration bin Format.Time) in
  Printf.printf "Progression : %s / %s\n%!" position duration

let () =
  Gstreamer.init ();
  let pipeline = Printf.sprintf "filesrc location=\"%s\" ! decodebin ! fakesink" Sys.argv.(1) in
  let bin = Pipeline.parse_launch pipeline in

  ignore (Element.set_state bin Element.State_playing);
   (* Wait for the state to complete. *)
  ignore (Element.get_state bin);

  printProgression bin;

  Unix.sleep 1;
  
  printProgression bin;

  Unix.sleep 1;
  
  printProgression bin;

  Gc.full_major ()<commit_msg>Request duration only one time<commit_after>open Gstreamer

let timeToString nsd =
  let msd = Int64.(to_int(div nsd (of_int 1000000))) in
  let h = msd / 3600000 in
  let m = (msd - (h * 3600000)) / 60000 in
  let s = (msd - (h * 3600000) - (m * 60000)) / 1000 in
  let ms = msd - (h * 3600000) - (m * 60000) - (s * 1000) in
  let h = if h = 0 then "" else Printf.sprintf "%d:" h in 
  let ms = if ms = 0 then "" else Printf.sprintf ".%d" ms in 
  Printf.sprintf "%s%d:%d%s" h m s ms

let printProgression bin duration =
  let position = timeToString(Element.position bin Format.Time) in
  Printf.printf "Progression : %s / %s\n%!" position duration

let () =
  Gstreamer.init ();
  let pipeline = Printf.sprintf "filesrc location=\"%s\" ! decodebin ! fakesink" Sys.argv.(1) in
  let bin = Pipeline.parse_launch pipeline in

  ignore (Element.set_state bin Element.State_paused);
   (* Wait for the state to complete. *)
  ignore (Element.get_state bin);

  let duration = timeToString(Element.duration bin Format.Time) in
  Printf.printf "Duration : %s\n%!" duration;

  ignore (Element.set_state bin Element.State_playing);
  ignore (Element.get_state bin);

  printProgression bin duration;

  Unix.sleep 1;

  printProgression bin duration;

  Unix.sleep 1;

  printProgression bin duration;

  Gc.full_major ()
{'fraction_non_alphanumeric': 0.12428454619787407, 'fraction_numerical': 0.053147996729354045, 'mean_word_length': 3.277972027972028, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686422', 'n_tokens_mistral': 981, 'n_tokens_neox': 851, 'n_words': 283}