diff --git a/JlSonic/api.jl b/JlSonic/api.jl index 6786c50..c9e088c 100644 --- a/JlSonic/api.jl +++ b/JlSonic/api.jl @@ -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