alexta69 / metube

Self-hosted YouTube downloader (web UI for youtube-dl / yt-dlp)
GNU Affero General Public License v3.0
3.96k stars 259 forks source link

Mkv Format To Download #403

Closed PitchAbyss closed 2 months ago

PitchAbyss commented 3 months ago

hi Dev Can you please add mkv format please

image

PikuZheng commented 3 months ago

set YTDL_OPTIONS = {'merge_output_format': 'mkv'} ?

PitchAbyss commented 3 months ago

set YTDL_OPTIONS = {'merge_output_format': 'mkv'} ?

How and where to add this sir

Doomnometron commented 3 months ago

set YTDL_OPTIONS = {'merge_output_format': 'mkv'} ?

Doesn't work for me. I've added the option in different spellings as an environment variable in the Docker container but the videos are not downloaded in mkv format. I was also unsuccessful with 'remux-video mkv'.

PikuZheng commented 3 months ago

sorry to hear that :( but mkv format will never be downloaded by yt-dlp, all formats are converted by ffmpeg after downloading.

Doomnometron commented 3 months ago

Thanks, I'll have a look at it later. I was just looking at the file extension.

PitchAbyss commented 3 months ago

Thanks, I'll have a look at it later. I was just looking at the file extension.

Thankyou it would be great if there is a fix

jakejackson commented 3 months ago

@PitchAbyss & @Doomnometron :

Here's my docker-compose for MeTube-- all videos are processed into MKV containers, and I have all audio-only downloads going into M4A containers:

version: "3"
services:
  metube:
    image: ghcr.io/alexta69/metube
    container_name: metube
    restart: unless-stopped
    ports:
      - "8083:8081"
    volumes:
      - /mnt/metube:/downloads
    network_mode: bridge
    ulimits:
        nofile:
            soft: 200  # Soft limit for open file descriptors
            hard: 400  # Hard limit for open file descriptors
    environment:
      YTDL_OPTIONS: '{"format": "bestvideo+bestaudio", "merge_output_format": "mkv", "writesubtitles": true, "subtitleslangs": ["en"], "postprocessors": [{"key": "FFmpegEmbedSubtitle", "already_have_subtitle": false}, {"key": "FFmpegMetadata", "add_chapters": true}], "outtmpl": "/downloads/%(title)s.%(ext)s", "cachedir": false}'
      YTDL_AUDIO_ONLY_OPTIONS: '{"format": "bestaudio", "merge_output_format": "m4a", "outtmpl": "/downloads/%(title)s.%(ext)s"}'
    labels:
      - com.centurylinklabs.watchtower.enable=true

Pay specific attention to the YTDL_OPTIONS and YTDL_AUDIO_ONLY_OPTIONS environment variables, that's where instructions related to file formats, containers, etc. are passed to FFmpeg.

Beyond MKV containers, there are obviously a number of other options / audio only options that have been customized to how I want things downloaded and post-processed, but the above will hopefully put you on the path to making it work for your requirements.

PitchAbyss commented 3 months ago

@PitchAbyss & @Doomnometron :

Here's my docker-compose for MeTube-- all videos are processed into MKV containers, and I have all audio-only downloads going into M4A containers:

version: "3"
services:
  metube:
    image: ghcr.io/alexta69/metube
    container_name: metube
    restart: unless-stopped
    ports:
      - "8083:8081"
    volumes:
      - /mnt/metube:/downloads
    network_mode: bridge
    ulimits:
        nofile:
            soft: 200  # Soft limit for open file descriptors
            hard: 400  # Hard limit for open file descriptors
    environment:
      YTDL_OPTIONS: '{"format": "bestvideo+bestaudio", "merge_output_format": "mkv", "writesubtitles": true, "subtitleslangs": ["en"], "postprocessors": [{"key": "FFmpegEmbedSubtitle", "already_have_subtitle": false}, {"key": "FFmpegMetadata", "add_chapters": true}], "outtmpl": "/downloads/%(title)s.%(ext)s", "cachedir": false}'
      YTDL_AUDIO_ONLY_OPTIONS: '{"format": "bestaudio", "merge_output_format": "m4a", "outtmpl": "/downloads/%(title)s.%(ext)s"}'
    labels:
      - com.centurylinklabs.watchtower.enable=true

Pay specific attention to the YTDL_OPTIONS and YTDL_AUDIO_ONLY_OPTIONS environment variables, that's where instructions related to file formats, containers, etc. are passed to FFmpeg.

Beyond MKV containers, there are obviously a number of other options / audio only options that have been customized to how I want things downloaded and post-processed, but the above will hopefully put you on the path to making it work for your requirements.

thankyou so much sir , il surely try this today and update and hopefully this is all il want sir :)

InterN0te commented 3 weeks ago

Does the option "YTDL_AUDIO_ONLY_OPTIONS" really exist ?

I tried to add YTDL_OPTIONS & YTDL_AUDIO_ONLY_OPTIONS to my Docker but everything is downloaded as a video, even if I choose "Audio only" as Quality

jakejackson commented 3 weeks ago

Does the option "YTDL_AUDIO_ONLY_OPTIONS" really exist ?

I tried to add YTDL_OPTIONS & YTDL_AUDIO_ONLY_OPTIONS to my Docker but everything is downloaded as a video, even if I choose "Audio only" as Quality

I believe you're correct. I don't think there's any purpose whatsoever in using the YTDL_AUDIO_ONLY_OPTIONS environment variable.

My YTDL_OPTIONS environment variables ("format": "bestvideo+bestaudio", "merge_output_format": "mkv") -- which solves the lack of an MKV format/container drop-down option in the GUI -- force the download & encapsulation in an MKV container of the video stream elements that seem to accompany everything on YouTube -- even when it's just audio and an album cover, or similar, from music.youtube.com.

Not a great solution, but, if you absolutely want to keep getting all of your videos in an MKV container (and I certainly do,) and also want to be able to download audio-only (plus metadata) so that your audio downloads aren't pointlessly bloated (or forced into an MKV container as opposed to being able to select M4A, MP3, OPUS, etc.), then I believe your options are:

  1. run a secondary MeTube container WITHOUT any YTDL_OPTIONS / YTDL_AUDIO_ONLY_OPTIONS environment variables, which will make the Quality and Format toggles actually relevant again, allowing you to select Audio Only / M4A containers, etc.
  2. fork MeTube and write/integrate a conditional logic script to handle downloads differently when it's www.youtube.com vs music.youtube.com (or whatever other parameters you'd want to define) -- to be clear, I am nowhere near capable of doing this
  3. hope/pray that @alexta69 sees this thread again and has thoughts more clever and well-informed than my own on how to crack this particular nut

For now at least, the only quick/dirty/guaranteed solution that I see is to run "MeTube1" and "MeTube2" containers where 1 has YTDL_OPTIONS to enforce MKV containerization of downloads and where 2 does not.

Appreciate you pointing this out, @InterN0te -- I knocked my head against the wall trying to solve this and failed, but still learned something in the process.

PitchAbyss commented 3 weeks ago

Does the option "YTDL_AUDIO_ONLY_OPTIONS" really exist ? I tried to add YTDL_OPTIONS & YTDL_AUDIO_ONLY_OPTIONS to my Docker but everything is downloaded as a video, even if I choose "Audio only" as Quality

I believe you're correct. I don't think there's any purpose whatsoever in using the YTDL_AUDIO_ONLY_OPTIONS environment variable.

My YTDL_OPTIONS environment variables ("format": "bestvideo+bestaudio", "merge_output_format": "mkv") -- which solves the lack of an MKV format/container drop-down option in the GUI -- force the download & encapsulation in an MKV container of the video stream elements that seem to accompany everything on YouTube -- even when it's just audio and an album cover, or similar, from music.youtube.com.

Not a great solution, but, if you absolutely want to keep getting all of your videos in an MKV container (and I certainly do,) and also want to be able to download audio-only (plus metadata) so that your audio downloads aren't pointlessly bloated (or forced into an MKV container as opposed to being able to select M4A, MP3, OPUS, etc.), then I believe your options are:

  1. run a secondary MeTube container WITHOUT any YTDL_OPTIONS / YTDL_AUDIO_ONLY_OPTIONS environment variables, which will make the Quality and Format toggles actually relevant again, allowing you to select Audio Only / M4A containers, etc.
  2. fork MeTube and write/integrate a conditional logic script to handle downloads differently when it's www.youtube.com vs music.youtube.com (or whatever other parameters you'd want to define) -- to be clear, I am nowhere near capable of doing this
  3. hope/pray that @alexta69 sees this thread again and has thoughts more clever and well-informed than my own on how to crack this particular nut

For now at least, the only quick/dirty/guaranteed solution that I see is to run "MeTube1" and "MeTube2" containers where 1 has YTDL_OPTIONS to enforce MKV containerization of downloads and where 2 does not.

Appreciate you pointing this out, @InterN0te -- I knocked my head against the wall trying to solve this and failed, but still learned something in the process.

sir if possible please share corrected compose