JuliaIO / VideoIO.jl

Reading and writing of video files in Julia via ffmpeg
https://juliaio.github.io/VideoIO.jl/stable
Other
125 stars 53 forks source link

Documentation says you can use (crf=0, preset="ultraslow") for lossless, but doesn't work #362

Closed BioTurboNick closed 2 years ago

BioTurboNick commented 2 years ago

See: https://juliaio.github.io/VideoIO.jl/stable/writing/#Lossless-Encoding

encoder_options = (crf=0, preset="ultraslow")
VideoIO.save("video.mp4", eachframe(imgstack), framerate=30, encoder_options=encoder_options)

# printed at terminal
x264 [error]: invalid preset 'ultraslow'

# error
Could not open codec: Return code -22

error(::String)@error.jl:35
var"#VideoWriter#29"(::Nothing, ::Int64, ::Bool, ::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::NamedTuple{(:crf, :preset), Tuple{Int64, String}}, ::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::Nothing, ::Int64, ::Nothing, ::Bool, ::NamedTuple{(), Tuple{}}, ::Nothing, ::Type{VideoIO.VideoWriter}, ::String, ::Type{UInt16}, ::Tuple{Int64, Int64})@encoding.jl:332
#VideoWriter#30@encoding.jl:379[inlined]
#open_video_out#31@encoding.jl:473[inlined]
var"#open_video_out#32"(::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:framerate, :encoder_options), Tuple{Int64, NamedTuple{(:crf, :preset), Tuple{Int64, String}}}}}, ::typeof(VideoIO.open_video_out), ::VideoIO.var"#34#35"{Base.Generator{Base.OneTo{Int64}, Base.var"#245#246"{Base.ReinterpretArray{UInt16, 3, ColorTypes.Gray{FixedPointNumbers.N0f16}, TiffImages.DenseTaggedImage{ColorTypes.Gray{FixedPointNumbers.N0f16}, 3, UInt32, Array{ColorTypes.Gray{FixedPointNumbers.N0f16}, 3}}, false}, Tuple{}, Tuple{Colon, Colon}}}}, ::String, ::SubArray{UInt16, 2, Base.ReinterpretArray{UInt16, 3, ColorTypes.Gray{FixedPointNumbers.N0f16}, TiffImages.DenseTaggedImage{ColorTypes.Gray{FixedPointNumbers.N0f16}, 3, UInt32, Array{ColorTypes.Gray{FixedPointNumbers.N0f16}, 3}}, false}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, Int64}, false})@encoding.jl:476
#save#33@encoding.jl:501[inlined]
top-level scope@[Local: 3](http://localhost:1234/edit?id=a2a47340-e414-11ec-18fe-7bff5e71591b#)[inlined]

The documented ultrafast seems to work.

IanButterworth commented 2 years ago

Ah true. From https://trac.ffmpeg.org/wiki/Encode/H.264

ultrafast
superfast
veryfast
faster
fast
medium – default preset
slow
slower
veryslow