Stream while converting!
This commit is contained in:
parent
93dbe08fcf
commit
019d06b084
|
@ -514,19 +514,21 @@ function getCoverArt(req::Dict)
|
|||
end
|
||||
|
||||
function giveconverted(file, bitrate, format)
|
||||
data = convert(file, bitrate = bitrate, format = format)
|
||||
iodata = convert(file, bitrate = bitrate, format = format)
|
||||
headers = Dict{String,String}()
|
||||
suffix = format
|
||||
mime = suffix in keys(Mux.mimetypes) ? Mux.mimetypes[suffix] : suffix
|
||||
headers["Content-Type"] = mime
|
||||
headers["Content-Length"] = string(length(data))
|
||||
return Dict(:body => data, :headers => headers)
|
||||
# headers["Content-Length"] = string(length(data))
|
||||
return Dict(:body => take!(iodata), :headers => headers)
|
||||
end
|
||||
|
||||
function convert(infile; bitrate = 64, format = "oga")
|
||||
global ffmpeg_threads
|
||||
pipeline(`ffmpeg -i $infile -y -c:a libvorbis -b:a $(bitrate)k -threads $(ffmpeg_threads) -f $format pipe:1`,
|
||||
stderr=devnull) |> read
|
||||
io = IOBuffer()
|
||||
run(pipeline(`ffmpeg -i $infile -y -c:a libvorbis -b:a $(bitrate)k -threads $(ffmpeg_threads) -f $format pipe:1`,
|
||||
stderr=devnull, stdout=io), wait = false)
|
||||
io
|
||||
end
|
||||
|
||||
canstream(u::User) = u.stream
|
||||
|
|
Loading…
Reference in New Issue