darklinkpower / PlayniteExtensionsCollection

Collection of extensions made for Playnite.
MIT License
331 stars 29 forks source link

[Extra Metadata Loader] YouTube video quality / FFMPEG not used #563

Open Goeny opened 4 months ago

Goeny commented 4 months ago

Extension name

Extra Metadata

Bug Description

When using the download video from Youtube method, the quality of the video's is very poor. I suspect ffmpeg is not being used.

When ffmpeg is not installed globally (system wide), it will prompt you that ffmpeg is not installed and quality is poor. The downloaded file is indeed poor. After installing ffmpeg system wide and run the yt-dlp.exe manually again, the downloaded file is high quality. However, when using the option from Playnite, the quality is still poor.

To Reproduce

Once use the "download from Youtube" function in Playnite, and once manually yt-dlp.exe command from cmd or powershell. Try both methods with ffmpeg installed, and not installed system-wide. When not installed system-wide it will download low quality on both methods. When installed system wide, it will download low quality from Playnite but high quality from command line.

Logs

13-07 17:13:33.321|DEBUG|ExtraMetadataLoader#ProcessStarter:Starting process: C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\yt-dlp.exe, -v --force-overwrites -o "C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4" --cookies "C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\cookies.txt" -f "mp4" "https://www.youtube.com/watch?v=M_XwzBMTJaM", C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\bin 13-07 17:13:37.320|DEBUG|ExtraMetadataLoader#VideosDownloader:Obtaining video information: C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4 13-07 17:13:37.320|DEBUG|ExtraMetadataLoader#ProcessStarter:Starting process: C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\bin\ffprobe.exe, -v error -select_streams v:0 -show_entries stream=width,height,codec_name_name,pix_fmt,duration -of json "C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4", C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\bin 13-07 17:13:37.345|DEBUG|ExtraMetadataLoader#FileSystem:Moving file C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4 to C:\Users\goeny\AppData\Roaming\Playnite\ExtraMetadata\games\bd00b0e8-1046-4e56-9094-87bc98b30652\VideoTrailer.mp4 13-07 17:14:45.162|DEBUG|ExtraMetadataLoader#ProcessStarter:Starting process: C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\yt-dlp.exe, -v --force-overwrites -o "C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4" --cookies "C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\cookies.txt" -f "mp4" "https://www.youtube.com/watch?v=M_XwzBMTJaM", C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\bin 13-07 17:14:49.081|DEBUG|ExtraMetadataLoader#VideosDownloader:Obtaining video information: C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4 13-07 17:14:49.081|DEBUG|ExtraMetadataLoader#ProcessStarter:Starting process: C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\bin\ffprobe.exe, -v error -select_streams v:0 -show_entries stream=width,height,codec_name_name,pix_fmt,duration -of json "C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4", C:\Users\goeny\AppData\Local\Playnite\ffmpeg-7.0.1-essentials_build\bin 13-07 17:14:49.101|DEBUG|ExtraMetadataLoader#FileSystem:Moving file C:\Users\goeny\AppData\Local\Temp\VideoTemp.mp4 to C:\Users\goeny\AppData\Roaming\Playnite\ExtraMetadata\games\bd00b0e8-1046-4e56-9094-87bc98b30652\VideoTrailer.mp4

Screenshots

Manually downloaded with ffmpeg globally installed image image

Downloaded from Playnite wih ffmpeg globally installed image image

Goeny commented 4 months ago

After some fiddling around i have to conclude this is not a bug. It's a limitation of the conversion to mp4.

Video's are downloaded in highest quality but because of using the mp4 video format the quality goes down. I have tried some different option flags for yt-dlp.

--remux-video mp4 seems to keep the quality but looses the audio when opus codec is not availble. --recode-video mp4 keeps the quality and the audio but take a long time and heavy cpu load.

Best option i found is to use the following flags -S vcodec:h264,res,acodex:m4a

Where can i find the yt-dlp.conf file which is used by Extra Metadata Loader so i can alter it manually?

Perhaps there is an option to add to the add-on, so that users can add their own options to the yt-dlp command. If nothing is used, the default will be used (and you get low quality)

felipecustodio commented 4 months ago

Hi @Goeny, facing the same issue here, video quality is very, very poor. Are the videos downloaded in the highest possible quality by default? Also, could you please share a before/after of your new flags? Let's see if we can get this some attention, unfortunately I'm not experienced with C# to contribute with a PR but we can try to find where these are defined.

felipecustodio commented 4 months ago

@Goeny I believe these are where the arguments we might need to change are set:

For the video downloader: https://github.com/darklinkpower/PlayniteExtensionsCollection/blob/6ed1af21528a4349c53e0495556ef85b3509615b/source/Generic/ExtraMetadataLoader/Services/VideosDownloader.cs#L130

For the micro video generation: https://github.com/darklinkpower/PlayniteExtensionsCollection/blob/6ed1af21528a4349c53e0495556ef85b3509615b/source/Generic/ExtraMetadataLoader/Services/VideosDownloader.cs#L255

felipecustodio commented 3 months ago

Hi @darklinkpower, Would you prefer a PR on this matter or is this something that you'd need to investigate on your end? Let us know, would love to help the project.