File: info.ml

package info (click to toggle)
ocaml-ffmpeg 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 908 kB
  • sloc: ansic: 6,412; ml: 6,166; makefile: 3
file content (54 lines) | stat: -rw-r--r-- 2,465 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
open Avutil
open Printf

let test () =
  Sys.argv |> Array.to_list |> List.tl
  |> List.iter (fun url ->
         let input = Av.open_input url in
         printf "%s (%s s) :\n" url
           (match Av.get_input_duration input with
             | None -> "N/A"
             | Some d -> Int64.to_string d);
         Av.get_input_metadata input
         |> List.iter (fun (k, v) -> printf "\t%s : %s\n" k v);
         Av.get_audio_streams input
         |> List.iter (fun (idx, stm, cd) ->
                Av.get_metadata stm
                |> List.iter (fun (k, v) -> printf "\t%s : %s\n" k v);
                Avcodec.Audio.(
                  printf
                    "\tAudio stream %d : %s %s, %s %s, %s %d, %s %d, %s %d, %s \
                     %Ld\n"
                    idx "codec"
                    (get_params_id cd |> string_of_id)
                    "sample format"
                    ( get_sample_format cd |> fun p ->
                      Option.get (Sample_format.get_name p) )
                    "channels" (get_nb_channels cd) "bit rate" (get_bit_rate cd)
                    "sample rate" (get_sample_rate cd) "duration (ms)"
                    (Av.get_duration ~format:`Millisecond stm)));
         Av.get_video_streams input
         |> List.iter (fun (idx, stm, cd) ->
                Av.get_metadata stm
                |> List.iter (fun (k, v) -> printf "\t%s : %s\n" k v);
                Avcodec.Video.(
                  let sar = get_sample_aspect_ratio cd in
                  printf
                    "\tVideo stream %d : %s %s, %s %d, %s %d, %s %d / %d, %s \
                     %d, %s %Ld\n"
                    idx "codec"
                    (get_params_id cd |> string_of_id)
                    "width" (get_width cd) "height" (get_height cd)
                    "sample aspect ratio" sar.num sar.den "bit rate"
                    (get_bit_rate cd) "duration (ns)"
                    (Av.get_duration ~format:`Nanosecond stm)));
         Av.get_subtitle_streams input
         |> List.iter (fun (idx, stm, cd) ->
                Av.get_metadata stm
                |> List.iter (fun (k, v) -> printf "\t%s : %s\n" k v);
                Avcodec.Subtitle.(
                  printf "\tSubtitle stream %d : %s %s, %s %Ld\n" idx "codec"
                    (get_params_id cd |> string_of_id)
                    "duration (µs)"
                    (Av.get_duration ~format:`Microsecond stm)));
         printf "\n")