Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test new version FFMPEG #418

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ jobs:
with:
version: ${{ matrix.julia-version }}
- uses: julia-actions/cache@v1
- name: Configure new FFMPEG version environment
shell: julia --project="." --color=yes {0}
run: |
using Pkg
Pkg.add(PackageSpec(url="https://github.com/theogf/FFMPEG.jl", rev="tgf/update-FFMPEG"))
Pkg.instantiate()
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Scratch = "6c6a2e73-6563-6170-7368-637461726353"
[compat]
ColorTypes = "0.9, 0.10, 0.11"
Downloads = "1.3"
FFMPEG = "0.3, 0.4"
FFMPEG_jll = "4.1"
FFMPEG = "0.3, 0.4, 1"
FFMPEG_jll = "4.1, 6.1"
theogf marked this conversation as resolved.
Show resolved Hide resolved
FileIO = "1.6"
Glob = "1.2"
ImageCore = "0.8, 0.9, 0.10"
Expand Down
4 changes: 2 additions & 2 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
FFMPEG_jll = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
Match = "7eb4fadd-790c-5f42-8a69-bfa0b872bfbf"
Vulkan_Headers_jll = "8d446b21-f3ad-5576-a034-752265b9b6f9"

[compat]
Clang = "0.14.0"
Clang = "0.14, 0.15, 0.16, 0.17"
theogf marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 2 additions & 3 deletions gen/generate.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Clang.Generators
using FFMPEG
using FFMPEG.FFMPEG_jll
using FFMPEG_jll
using Vulkan_Headers_jll
using LibGit2
include("rewriter.jl")
Expand All @@ -9,7 +8,7 @@ cd(@__DIR__)

# Ideally I could have loaded all headers, but it turns out to be too hard

include_dir = joinpath(FFMPEG.FFMPEG_jll.artifact_dir, "include") |> normpath
include_dir = joinpath(FFMPEG_jll.artifact_dir, "include") |> normpath

vulkan_dir = joinpath(Vulkan_Headers_jll.artifact_dir, "include") |> normpath

Expand Down
3 changes: 2 additions & 1 deletion gen/generate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ printer_blacklist = [
"AVPROBE_SCORE_MAX",
"Picture",
"AV_BPRINT_SIZE_UNLIMITED",
"FF_CEIL_RSHIFT"
"FF_CEIL_RSHIFT",
"AV_CHANNEL_LAYOUT_.*"
]
extract_c_comment_style = "doxygen"
[codegen]
Expand Down
12,746 changes: 6,849 additions & 5,897 deletions lib/libffmpeg.jl

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/VideoIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ function __init__()

read_packet[] = @cfunction(_read_packet, Cint, (Ptr{AVInput}, Ptr{UInt8}, Cint))

av_register_all()

libffmpeg.avdevice_register_all()

@require GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" begin
Expand Down
8 changes: 4 additions & 4 deletions src/avio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -832,10 +832,10 @@ get_frame_presentation_time(stream, frame) = convert(Rational, stream.time_base)
function get_frame_period_timebase(r::VideoReader)
# This is probably not valid for many codecs, frame period in timebase
# units
stream = get_stream(s)
stream = get_stream(r)
theogf marked this conversation as resolved.
Show resolved Hide resolved
time_base = convert(Rational, stream.time_base)
time_base == 0 && return nothing
frame_rate = convert(Rational, av_stream_get_r_frame_rate(stream))
frame_rate = convert(Rational, stream.r_frame_rate)
frame_period_timebase = round(Int64, 1 / (frame_rate * time_base))
return frame_period_timebase
end
Expand All @@ -858,7 +858,7 @@ function seek_trim(r::VideoReader, seconds::Number)
time_base = convert(Rational, stream.time_base)
time_base == 0 && error("No time base")
target_pts = seconds_to_timestamp(seconds, time_base)
frame_rate = convert(Rational, av_stream_get_r_frame_rate(stream))
frame_rate = convert(Rational, stream.r_frame_rate)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing so I can only assume that this is not the solution?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like the correct change based on https://patchwork.ffmpeg.org/project/ffmpeg/patch/20171023160821.6384-2-jamrial@gmail.com/

And the test failures could be rounding assumptions. Not looked deeper into it

Encoding with frame rate 29.5: Test Failed at /home/runner/work/VideoIO.jl/VideoIO.jl/test/writing.jl:196
  Expression: parse(Float64, measured_dur_str[1]) == target_dur
   Evaluated: 3.389831 == 3.39
Encoding with frame rate 29.5: Test Failed at /home/runner/work/VideoIO.jl/VideoIO.jl/test/writing.jl:214
  Expression: parse(Float64, measured_dur_str[1]) == target_dur
   Evaluated: 3.389831 == 3.39

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're a bit far from rounding error? Maybe it's a difference of 1 frame?

frame_period_timebase = round(Int64, 1 / (frame_rate * time_base))
gotframe = pump_until_frame(r, false)
# If advancing another frame would still leave us before the target
Expand Down Expand Up @@ -1005,7 +1005,7 @@ function position(r::VideoReader)
time_base == 0 && return nothing
nqueued = n_queued_frames(r)
nqueued == 0 && return last_pts * time_base
frame_rate = convert(Rational, av_stream_get_r_frame_rate(stream))
frame_rate = convert(Rational, stream.r_frame_rate)
last_returned_pts = last_pts - round(Int, nqueued / (frame_rate * time_base))
return last_returned_pts * time_base
end
Expand Down
Loading