kingstefan26 / alabamaEncoder

AlabamaEncoder is a video encoder framework, with a focus on chunked target quality encoding
MIT License
14 stars 1 forks source link

Silently fail, no logs #4

Closed Extarys closed 2 months ago

Extarys commented 3 months ago

I'm having an issue with alabamaEncoder... it simply gets stuck after scene detection. It spans workers every ~30 seconds, but nothing happens, and no frame is being encoded. I left the encoder open for 30 minutes, nothing - no logs either.

I put vmaf and svtav1 near the file and Svt is indeed firing up when I first start the program since I do see rate_probes folders created with small video files inside, but nothing else.

SvtAv1EncApp and vmaf were downloaded from GH, the x flag was added. alabamaEncoder was installed with pipx.

export SVTAV1ENCAPP_CLI_PATH="/path/to/SvtAv1EncApp"
export VMAF_CLI_PATH="/path/to/vmaf"
alabamaEncoder "Input.mkv" "./S01E01.webm" --title "Test" --vmaf_target 93 --chunk_order even -previews -stats --tune balanced --crf_limits 1,60  --log_level 1

image

five82 commented 3 months ago

I'm seeing the same behavior with the pipx install. I'll try the dev build instructions to see if there's any difference.

Extarys commented 3 months ago

@five82 Good idea ! I tried, and it compiled, but when using it there is a lib missing:

Traceback (most recent call last):
  File "/home/user/.local/bin/alabamaEncoder", line 5, in <module>
    from alabamaEncode.cli.__main__ import main
  File "/mnt/Projects/git/VideoTools/alabamaEncoder/alabamaEncode/cli/__main__.py", line 17, in <module>
    from alabamaEncode.core.job import AlabamaEncodingJob
  File "/mnt/Projects/git/VideoTools/alabamaEncoder/alabamaEncode/core/job.py", line 22, in <module>
    from alabamaEncode.core.extras.vmaf_plot import plot_vmaf
  File "/mnt/Projects/git/VideoTools/alabamaEncoder/alabamaEncode/core/extras/vmaf_plot.py", line 4, in <module>
    from matplotlib import pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'

I tried to add matplotlib in the requirements.txt for fun, but it didn't work :P I'm not that familiar with how python works, etc.

Did you manage to make it work ?

five82 commented 3 months ago

@Extarys I got past that error by installing matprotlib inside the venv. But then I ran into this:

(venv) root@63e36f3bb36d:/app/alabamaEncoder# python -m alabamaEncode.cli
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/alabamaEncoder/alabamaEncode/cli/__main__.py", line 161, in <module>
    main()
  File "/app/alabamaEncoder/alabamaEncode/cli/__main__.py", line 90, in main
    ctx, args = read_args(ctx)
                ^^^^^^^^^^^^^^
  File "/app/alabamaEncoder/alabamaEncode/cli/cli_setup/cli_args.py", line 611, in read_args
    ctx.output_file = args.output
                      ^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'output'
five82 commented 3 months ago

I was able to run it with the following command but received another error:

python -m alabamaEncode.cli encode /app/videos/input/abtest1.mkv /app/videos/output/abtest1.mkv --grain -2 --audio_params "-c:a libopus -b:a 384k -ac 6 -mapping_family 1" --vmaf_target 95
Getting source bitrate...
Input Video: 1920x1080 @ 23.98 fps, YUV420P, SDR, 22970.54 Kb/s, H264
Using SVT_AV1 version: SVT-AV1-PSY v2.1.0-A-1-g37a5609b (release)
PSY Release:
Running scene detection
  Detected: 79 | Progress: 100%|███████████████████████████████████████████████████████████████████████████████████| 7195/7195 [00:07<00:00, 965.97frames/s]
Detected 84 scenes
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/alabamaEncoder/alabamaEncode/cli/__main__.py", line 161, in <module>
    main()
  File "/app/alabamaEncoder/alabamaEncode/cli/__main__.py", line 155, in main
    asyncio.run(job.run_pipeline())  # this runs the whole encoding process
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/app/alabamaEncoder/alabamaEncode/core/job.py", line 133, in run_pipeline
    await run_sequence_pipeline(self.ctx, sequence)
  File "/app/alabamaEncoder/alabamaEncode/conent_analysis/pipelines.py", line 141, in run_sequence_pipeline
    else func(ctx, sequence)
         ^^^^^^^^^^^^^^^^^^^
  File "/app/alabamaEncoder/alabamaEncode/conent_analysis/pipelines.py", line 30, in setup_chunk_analyze_chain
    from alabamaEncode.conent_analysis.chunk.analyze_steps.new_grain import (
  File "/app/alabamaEncoder/alabamaEncode/conent_analysis/chunk/analyze_steps/new_grain.py", line 105
    f"{common} -vf {",".join(filter_vec + [denoise_strong])} -"
                     ^
SyntaxError: f-string: expecting '}'
Current Session Runtime: 8 second(s), Runtime From Previous Sessions: 0 second(s), Total Runtime: 8 second(s)
kingstefan26 commented 3 months ago

gonna figure this out I promise, just busy atm

Extarys commented 3 months ago

@kingstefan26 Thank you Sensei!

kingstefan26 commented 3 months ago

I'm having an issue with alabamaEncoder... it simply gets stuck after scene detection. It spans workers every ~30 seconds, but nothing happens, and no frame is being encoded. I left the encoder open for 30 minutes, nothing - no logs either.

I put vmaf and svtav1 near the file and Svt is indeed firing up when I first start the program since I do see rate_probes folders created with small video files inside, but nothing else.

SvtAv1EncApp and vmaf were downloaded from GH, the x flag was added. alabamaEncoder was installed with pipx.

export SVTAV1ENCAPP_CLI_PATH="/path/to/SvtAv1EncApp"
export VMAF_CLI_PATH="/path/to/vmaf"
alabamaEncoder "Input.mkv" "./S01E01.webm" --title "Test" --vmaf_target 93 --chunk_order even -previews -stats --tune balanced --crf_limits 1,60  --log_level 1

image

the way i calc vmaf fails weird, susceptible to weird timing issues, i think thats whats going on. Some cli process is failing silently and the rest of the pipeline is waiting indefinitely

to help debug would appreciate if you would send the .alabamatemp-xxxxx folder, with the temp.mkv removed obviously; i want to know how far it got in the process to pinpoint the issue

kingstefan26 commented 3 months ago

@five82 Good idea ! I tried, and it compiled, but when using it there is a lib missing:

Traceback (most recent call last):
  File "/home/user/.local/bin/alabamaEncoder", line 5, in <module>
    from alabamaEncode.cli.__main__ import main
  File "/mnt/Projects/git/VideoTools/alabamaEncoder/alabamaEncode/cli/__main__.py", line 17, in <module>
    from alabamaEncode.core.job import AlabamaEncodingJob
  File "/mnt/Projects/git/VideoTools/alabamaEncoder/alabamaEncode/core/job.py", line 22, in <module>
    from alabamaEncode.core.extras.vmaf_plot import plot_vmaf
  File "/mnt/Projects/git/VideoTools/alabamaEncoder/alabamaEncode/core/extras/vmaf_plot.py", line 4, in <module>
    from matplotlib import pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'

I tried to add matplotlib in the requirements.txt for fun, but it didn't work :P I'm not that familiar with how python works, etc.

Did you manage to make it work ?

just also noticed matplotlib is missing from official requirements, just added it

kingstefan26 commented 3 months ago

@Extarys I got past that error by installing matprotlib inside the venv. But then I ran into this:

(venv) root@63e36f3bb36d:/app/alabamaEncoder# python -m alabamaEncode.cli
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/alabamaEncoder/alabamaEncode/cli/__main__.py", line 161, in <module>
    main()
  File "/app/alabamaEncoder/alabamaEncode/cli/__main__.py", line 90, in main
    ctx, args = read_args(ctx)
                ^^^^^^^^^^^^^^
  File "/app/alabamaEncoder/alabamaEncode/cli/cli_setup/cli_args.py", line 611, in read_args
    ctx.output_file = args.output
                      ^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'output'

also fixed this just now, just the cli parser freaking out cuz its expecting a missing option, now it displays help on empty arguments

kingstefan26 commented 3 months ago

(sorry for email spam), but also just changed the way vmaf models are downloaded to avoid weird race conditions. Before each worker would start downloading if it saw a model was missing. Now it downloads models much earlier in the process and not inside the workers. I think this should solve the original "hangs forever" issue

five82 commented 3 months ago

Thanks! I installed with pipx but I get this error when I run it:

Input Video: 1920x1080 @ 23.98 fps, YUV420P, SDR, 22970.54 Kb/s, H264
Using SVT_AV1 version: SVT-AV1-PSY v2.1.0-A-1-g37a5609b (release)
PSY Release:
Downloading VMAF model
Downloading VMAF model
Downloading VMAF model
Downloading VMAF model
Downloading VMAF model
Traceback (most recent call last):
  File "/usr/local/bin/alabamaencoder", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.local/pipx/venvs/alabamaencoder/lib/python3.11/site-packages/alabamaEncode/cli/__main__.py", line 155, in main
    asyncio.run(job.run_pipeline())  # this runs the whole encoding process
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/alabamaencoder/lib/python3.11/site-packages/alabamaEncode/core/job.py", line 135, in run_pipeline
    await run_sequence_pipeline(self.ctx, sequence)
  File "/root/.local/pipx/venvs/alabamaencoder/lib/python3.11/site-packages/alabamaEncode/conent_analysis/pipelines.py", line 141, in run_sequence_pipeline
    else func(ctx, sequence)
         ^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/alabamaencoder/lib/python3.11/site-packages/alabamaEncode/conent_analysis/pipelines.py", line 30, in setup_chunk_analyze_chain
    from alabamaEncode.conent_analysis.chunk.analyze_steps.new_grain import (
  File "/root/.local/pipx/venvs/alabamaencoder/lib/python3.11/site-packages/alabamaEncode/conent_analysis/chunk/analyze_steps/new_grain.py", line 105
    f"{common} -vf {",".join(filter_vec + [denoise_strong])} -"
                     ^
SyntaxError: f-string: expecting '}'
kingstefan26 commented 3 months ago

@five82 what python version are you running?

five82 commented 3 months ago

@kingstefan26 Python 3.11.2 running in a Debian stable Docker container.

Extarys commented 2 months ago

@kingstefan26 Hey ! Welcome back :)

I git pulled and followed the compiling instruction, and I can now compile.

Trying to start an encode also seem to work, as some frames are now encoded. I'll just need to tweak the settings a bit cause with svt directly I get 8 fps and with alabama I get 5s/frame :joy:

I'll play with the encoder today and report back any errors if any :) Thank you very much.

@five82 I'm on Python 3.12.3 with Fedora. No idea if this helps.

EDIT Small suggestion for the future: I would argue that the converted ivf files could really use their own subfolder (like "converted" or "encode" similar to av1an), as I imagine when you reach 1000 files, the logs and json files might be a bit harder to find.

five82 commented 2 months ago

Thanks @Extarys!

I switched to an Ubuntu container with python 3.12.3 and was able to encode a test video.

kingstefan26 commented 2 months ago

Trying to start an encode also seem to work, as some frames are now encoded. I'll just need to tweak the settings a bit cause with svt directly I get 8 fps and with alabama I get 5s/frame 😂

ah well, the process involves a lot of overhead, sometimes less sometimes more, altho ur case seems extreme, most likely the new grain

EDIT Small suggestion for the future: I would argue that the converted ivf files could really use their own subfolder (like "converted" or "encode" similar to av1an), as I imagine when you reach 1000 files, the logs and json files might be a bit harder to find.

i was already thinking of this change, just wasnt sure if it was really necessary, will impl soon

kingstefan26 commented 2 months ago

Thanks @Extarys!

I switched to an Ubuntu container with python 3.12.3 and was able to encode a test video.

sorry for getting back so late, i asked the python version since that kind of issue can only happen with new python versions supporting new syntax. Will add a python version guardrail to prevent this in the future

kingstefan26 commented 2 months ago

Ok now everything should be resolved, thanks!