Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
12.92k stars 1.48k forks source link

YouTube import fail for some videos (vp9?) #5423

Open fenarinarsa opened 1 year ago

fenarinarsa commented 1 year ago

Describe the current behavior

Youtube import fails for some videos. It looks like yt-dlp is downloading the webm/vp9 version of the video.

Steps to reproduce

  1. Try to import the following video https://www.youtube.com/watch?v=FZ5BKKAkGsU
  2. Check import logs

Describe the expected behavior

yt-dlp should download the mp4 video instead of the webm version.

Additional information

Import log:

Error: Command failed with exit code 1: /usr/bin/python3 /var/www/peertube/storage/bin/yt-dlp --merge-output-format mp4 -f bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best -o /var/www/peertube/storage/tmp/73a10de371839b5c1236493b1eeb85fda1c7e8e13245791c894e11b3d0a3a1eb-import https://www.youtube.com/watch?v=FZ5BKKAkGsU
ERROR: Postprocessing: Conversion failed!
[youtube] FZ5BKKAkGsU: Downloading webpage
[youtube] FZ5BKKAkGsU: Downloading android player API JSON
[youtube] FZ5BKKAkGsU: Downloading MPD manifest
[youtube] FZ5BKKAkGsU: Downloading MPD manifest
[info] FZ5BKKAkGsU: Downloading 1 format(s): 244+251
[dashsegments] Total fragments: 54
[download] Destination: /var/www/peertube/storage/tmp/73a10de371839b5c1236493b1eeb85fda1c7e8e13245791c894e11b3d0a3a1eb-import.f244.webm

...
[download] 100% of   13.00MiB in 00:00:13 at 969.14KiB/s               
[download] Destination: /var/www/peertube/storage/tmp/73a10de371839b5c1236493b1eeb85fda1c7e8e13245791c894e11b3d0a3a1eb-import.f251.webm

...
[download] 100% of    5.17MiB in 00:00:00 at 24.90MiB/s  
[Merger] Merging formats into "/var/www/peertube/storage/tmp/73a10de371839b5c1236493b1eeb85fda1c7e8e13245791c894e11b3d0a3a1eb-import.mp4"
    at makeError (/var/www/peertube/versions/peertube-v4.3.0/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/var/www/peertube/versions/peertube-v4.3.0/node_modules/execa/index.js:118:26)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
fenarinarsa commented 1 year ago

It looks like the filter in yt-dlp should better be something like this to avoid vp9/vp9.2/opus codecs:

-f bestvideo*[vcodec!=av01][vcodec!=vp9.2][vcodec!=vp9]+bestaudio[acodec!=opus]/best[vcodec!=av01][vcodec!=vp9][vcodec!=vp9.2][acodec!=opus]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best

Chocobozzz commented 1 year ago

Hi,

Unfortunately 4k videos on youtube use vp9 and are not available in avc1. Then we can't exclude vp9 from the query.

I suggest to upgrade ffmpeg to 5.1, it should fix this issue

fenarinarsa commented 1 year ago

ffmpeg 5.1 is not available for debian bullseye, even in backports, so for now I'll stick with my patch.

SimplyCorbett commented 1 year ago

ffmpeg 5.1 is not available for debian bullseye, even in backports, so for now I'll stick with my patch.

You can get ffmpeg static builds from here - https://johnvansickle.com/ffmpeg/

drzraf commented 1 year ago

Could the the docker image be updated with such a ffmpeg version to take that into account. I'm encountering the problem for approx 2% of my videos.