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

[Bug] Doesn't convert vp9 to AV1 #66

Closed
Hello-World-Traveler opened this issue Nov 7, 2024 · 8 comments
Closed

[Bug] Doesn't convert vp9 to AV1 #66

Hello-World-Traveler opened this issue Nov 7, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@Hello-World-Traveler
Copy link

Describe the bug
Not converting the video to av1.

Steps To Reproduce
Select av1 and opus in trailer settings.

Actual behavior
AV1 option is selected but never converts. Codec: Google/On2's VP9 Video (VP90).

Expected behavior
Converts video to av1

Screenshots
N/A

App Information (please complete the following information):
docker

Additional context
TrailersDownloader: 'Trailers': [CopyStream] Done converting in 0:00:36.199472!

@Hello-World-Traveler Hello-World-Traveler added the bug Something isn't working label Nov 7, 2024
@nandyalu
Copy link
Owner

nandyalu commented Dec 6, 2024

Can you enable debug logging and share some logs for a trailer download where this issue happens?

@Hello-World-Traveler
Copy link
Author

Nothing about AV1

[DEBUG|video|L037]: TrailersDownloader: [Ol475b54NcY] Download completed in 0:00:44.464771! Size:   22.58MiB Filepath: "/tmp/869-trailer.f616.mp4"
 [DEBUG|video|L028]: TrailersDownloader: [Ol475b54NcY] Downloading   0.1% of    1.63MiB
 [DEBUG|video|L037]: TrailersDownloader: [Ol475b54NcY] Download completed in 0:00:02.265992! Size:    1.63MiB Filepath: "/tmp/869-trailer.f251.webm"
 [DEBUG|video|L064]: TrailersDownloader: [Ol475b54NcY][Merger] Converting downloaded file...
 [DEBUG|video|L071]: TrailersDownloader: [Ol475b54NcY][Merger] Done converting in 0:00:00.055918!
 [DEBUG|video|L076]: TrailersDownloader: [Ol475b54NcY][Merger] Filepath: "/tmp/869-trailer.mp4"
 [DEBUG|video|L064]: TrailersDownloader: [Ol475b54NcY][ModifyChapters] Converting downloaded file...
 [DEBUG|video|L071]: TrailersDownloader: [Ol475b54NcY][ModifyChapters] Done converting in 0:00:00.000214!
 [DEBUG|video|L076]: TrailersDownloader: [Ol475b54NcY][ModifyChapters] Filepath: "/tmp/869-trailer.mp4"
 [DEBUG|video|L064]: TrailersDownloader: [Ol475b54NcY][CopyStream] Converting downloaded file...
 [DEBUG|video|L064]: TrailersDownloader: [Ol475b54NcY][MoveFiles] Converting downloaded file...
 [DEBUG|video|L071]: TrailersDownloader: [Ol475b54NcY][MoveFiles] Done converting in 0:00:00.000249!
 [DEBUG|video|L076]: TrailersDownloader: [Ol475b54NcY][MoveFiles] Filepath: "/tmp/869-trailer.mp4"
 [DEBUG|video_analysis|L113]: VideoAnalysis: Verifying trailer streams for: /tmp/869-trailer.mp4
 [DEBUG|video_analysis|L063]: VideoAnalysis: Running media analysis for: /tmp/869-trailer.mp4
 [DEBUG|video_analysis|L139]: VideoAnalysis: Trailer streams verified for: /tmp/869-trailer.mp4
 [INFO|trailer|L398]: TrailersDownloader: Downloaded trailers for 1 movies
 [DEBUG|download_trailers|L123]: TrailerDownloadTasks: Updating trailer status in database
 [INFO|base|L156]: Job "Download Trailer for Take Cover (trigger: date[2024-12-07 09:45:16 AEDT], next run at: 2024-12-07 09:45:16 AEDT)" executed successfully
[DEBUG|base|L1151]: Tasks: Looking for jobs to run
[INFO|base|L129]: Running job "Docker Update Check (trigger: interval[1 day, 0:00:00], next run at: 2024-12-08 09:46:56 AEDT)" (scheduled at 2024-12-07 09:46:56.295624+11:00)
[DEBUG|base|L1258]: Tasks: Next wakeup is due at 2024-12-07 09:47:56.295882+11:00 (in 59.995905 seconds)
[ERROR|docker_check|L091]: UpdateChecker: Error: Could not update details from Docker Hub.
[INFO|base|L156]: Job "Docker Update Check (trigger: interval[1 day, 0:00:00], next run at: 2024-12-08 09:46:56 AEDT)" executed successfully
[DEBUG|base|L1151]: Tasks: Looking for jobs to run
[INFO|base|L129]: Running job "Trailer Cleanup (trigger: interval[1:00:00], next run at: 2024-12-07 10:47:56 AEDT)" (scheduled at 2024-12-07 09:47:56.295882+11:00)
[INFO|cleanup|L042]: CleanupTasks: Running trailer cleanup task...
[DEBUG|base|L1258]: Tasks: Next wakeup is due at 2024-12-07 09:52:56.295810+11:00 (in 299.995343 seconds)

@nandyalu
Copy link
Owner

I also noticed this when I changed my settings to av1, opus and webm, along with some other issues in downloading trailers.

My guess is that the python implementation of yt-dlp has bugs. I might have to make the app run a cli command and manually pass arguments to ffmpeg to do post-processing. I will look into this!

@nandyalu
Copy link
Owner

I have some news regarding this...

  • Yes, there are bugs in Yt-dlp for converting video to av1
  • Also, converting a video from a different codec to av1 is not very efficient, and takes a long time unless you have a very powerful CPU.
  • With the upcoming version of Trailarr, av1 conversion will be disabled, you can still select av1 and Trailarr will try and download video in av1 directly from yt-dlp (most recent videos should have an av1 format available for download), if av1 is not available, then it will be converted to vp9

@Hello-World-Traveler
Copy link
Author

then it will be converted to vp9

Probably best to have it to auto convert to AVC (x264) as this has the best support.

If you wanted to convert outside yt-dlp

AV1
ffmpeg -i input.mp4 -c:v libsvtav1 -preset 4 -crf 30 -b:v 0 -g 240 -pix_fmt yuv420p -c:a libopus -b:a 64k output.mp4

Or if hardware supports AV1
VAAPI
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v av1_vaapi -b:v 0 -g 240 -pix_fmt yuv420p -c:a libopus -b:a 64k output.mp4

NVENC (starting from RTX 4060)
ffmpeg -hwaccel cuda -i input.mp4 -c:v av1_nvenc -preset fast -b:v 0 -g 240 -pix_fmt yuv420p -c:a libopus -b:a 64k output.mp4

AV1 could be a prefer option?

@nandyalu
Copy link
Owner

Probably best to have it to auto convert to AVC (x264) as this has the best support.

If someone wants x264, there is an option for it already... If you want to download them in av1 and it's not available, then closest to it is vp9, which will also be the video format downloaded from YT if av1 was not available.

Or if hardware supports AV1 - VAAPI

I want to make Trailarr work with VAAPI but I couldn't figure out how to get it to work in a container. If someone wants to take a stab at it, you are welcome to do so.

NVENC (starting from RTX 4060)

I tried testing this but it's a hit and miss, it works on some videos but not on others... I think we are not ready for av1 yet... maybe in future!

@Hello-World-Traveler
Copy link
Author

Privileged mode
VAAPI needs to be mapped out for container /dev/dri/renderD128:/dev/dri/renderD128

This script installs the packages and check for vaapi

#!/bin/bash

# Add non-free repository
echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware" | sudo tee -a /etc/apt/sources.list

# Update package lists
apt update

# Install VAAPI packages
apt install -y libva-dev libva-drm2 libva-x11-2 vainfo intel-media-va-driver

# Check if VAAPI device can be opened
if [ -e /dev/dri/renderD128 ]; then
    echo "VAAPI device found at /dev/dri/renderD128"
    if vainfo; then
        echo "VAAPI device opened successfully"
    else
        echo "Failed to open VAAPI device"
    fi
else
    echo "VAAPI device not found"
fi

Jellyfin ffmpeg (/usr/lib/jellyfin-ffmpeg) can be mounted to /usr/local/bin/ffmpeg or copied to config folder and mounted as ffmpeg and ffprobe.

ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v h264_vaapi output.mp4

Then hit an error

implib-gen: libva.so.2: failed to resolve symbol 'vaMapBuffer2' via dlsym: /lib/x86_64-linux-gnu/libva.so.2: undefined symbol: vaMapBuffer2
ffmpeg: libva.so.2.init.c:214: _libva_so_2_tramp_resolve: Assertion `0 && "Assertion in generated code"' failed.
Aborted (core dumped)

installing a few more packages apt-get update && apt-get install -y libva-dev libdrm-dev

implib-gen: libva-drm.so.2: failed to load library 'libva-drm.so.2' via dlopen: libva.so.2: cannot open shared object file: No such file or directory

Haven't got passed this. Hopefully someone else can point out how to make this work.

Or could use linuxserver/ffmpeg?

@nandyalu
Copy link
Owner

nandyalu commented Feb 3, 2025

Closing this as PR #115 updates video codec options and the way video conversions are handled for av1, along with hardware acceleration options for NVIDIA GPUs.

VAAPI still needs more development and testing efforts to implement.

@nandyalu nandyalu closed this as completed Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants