<commit_before>open Gstreamer

let width = 320
let height = 240

let src = "videotestsrc"

let () =
  Gstreamer.init ();
  Printf.printf "%s\n%!" (version_string ());
  let bin =  Pipeline.parse_launch (src ^ " ! ffmpegcolorspace ! videoscale ! appsink name=sink caps=\"video/x-raw-rgb,width=320,height=240,pixel-aspect-ratio=1/1,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)0xff0000, green_mask=(int)0x00ff00, blue_mask=(int)0x0000ff\"") in

  let sink = Bin.get_by_name (Bin.of_element bin) "sink" in

  let sdl = new MMSDL.writer_to_screen width height in
  let vid = Video.create 1 in

  ignore (Element.set_state bin State_playing);
  while true do
    let b = App_sink.pull_buffer (App_sink.of_element sink) in
    let blen = Bigarray.Array1.dim b in
    Printf.printf "%d\n%!" (blen / (width * height));
    let img = Image.Generic.make_rgb Image.Generic.Pixel.RGB24 width height b in
    let out = Image.RGBA8.create width height in
    Image.Generic.convert ~copy:true ~proportional:true img (Image.Generic.of_RGBA8 out);
    vid.(0) <- out;
    sdl#write vid 0 1
  done;
  ignore (Element.set_state bin State_null)<commit_msg>Playing my webcam with gstreamer.<commit_after>open Gstreamer

let width = 320
let height = 240
let fps = 10

let src = "videotestsrc"
let src = "v4l2src device=/dev/video0"

let pipeline = Printf.sprintf "%s ! ffmpegcolorspace ! videoscale ! appsink drop=true name=sink caps=\"video/x-raw-rgb,width=%d,height=%d,pixel-aspect-ratio=1/1,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)0xff0000,green_mask=(int)0x00ff00,blue_mask=(int)0x0000ff,framerate=(fraction)10/1\"" src width height

let () =
  Gstreamer.init ();
  Printf.printf "%s\n%!" (version_string ());
  Printf.printf "%s\n%!" pipeline;
  let bin =  Pipeline.parse_launch pipeline in

  let sink = Bin.get_by_name (Bin.of_element bin) "sink" in

  let sdl = new MMSDL.writer_to_screen width height in
  let vid = Video.create 1 in

  ignore (Element.set_state bin State_playing);
  while true do
    let b = App_sink.pull_buffer (App_sink.of_element sink) in
    let blen = Bigarray.Array1.dim b in
    let img = Image.Generic.make_rgb Image.Generic.Pixel.RGB24 width height b in
    let out = Image.RGBA8.create width height in
    Image.Generic.convert ~copy:true ~proportional:true img (Image.Generic.of_RGBA8 out);
    vid.(0) <- out;
    sdl#write vid 0 1
  done;
  ignore (Element.set_state bin State_null)
{'fraction_non_alphanumeric': 0.12464124641246413, 'fraction_numerical': 0.03854038540385404, 'mean_word_length': 4.327510917030568, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6862739', 'n_tokens_mistral': 962, 'n_tokens_neox': 891, 'n_words': 216}