File: ffmpeg_audio_decoder.liq

package info (click to toggle)
liquidsoap 2.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,844 kB
  • sloc: ml: 74,136; javascript: 27,320; ansic: 505; sh: 139; xml: 114; lisp: 96; makefile: 26
file content (45 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (2)
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
log.level.set(5)
settings.frame.audio.samplerate.set(48000)
settings.audio.converter.samplerate.converters.set(["native"])
settings.decoder.decoders.set(["ffmpeg"])

fname = argv(default="", 1)
out = {"#{fname}+ffmpeg_audio_decoder-#{random.int()}.wav"}

s = single(fname)
s = once(s)

done = ref(false)

##clock.assign_new(sync='none', [s])
def on_close(filename) =
  if
    not done()
  then
    done := true

    process.run("sync")

    j =
      process.read(
        "ffprobe -v quiet -print_format json -show_streams #{
          process.quote(filename)
        }"
      )

    let json.parse (parsed :
      {streams: [{channels: int, sample_rate: string}]}
    ) = j

    let [stream] = parsed.streams
    if
      stream.channels == 1 and stream.sample_rate == "48000"
    then
      test.pass()
    else
      test.fail()
    end
  end
end

output.file(fallible=true, on_close=on_close, %wav(mono), out, s)