0

Jump to d.1 to see the work-around command I am using.

Why am I doing this?

It is SOMETIMES best to just do -f ba[ext=m4a] then change the extension to .mp4, my concern being that it will sometimes fail (or that it can be done more concisely)!

OTHER TIMES: I need the lowest quality file, must be video, that can still give a general idea of what's visually occurring (usually 144p or 360p). I don't want to sacrifice audio quality if at all possible. I always have to compress and re-format things: sometimes it takes an hour--I really want to cut steps down.

My goal is:

  • Understand how yt-dlp and ffmpeg work better.
  • Download the highest audio quality and a specific video quality.
  • Use the fewest commands possible to handle all potential inputs.
  • Get an mp4 output (not webm, not raw audio), consistently; ideally, without use of ffmpeg, if possible; alternatively, to use a single command that includes the yt-dlp string and the ffmpeg string on one line (such as yt-dlp -flags && ffmpeg -flags).

Known problems:

Best guesses did not work:

a.

  1. yt-dlp https://url.com/uri -f wv+ba* -o "./my/location/filename.mp4" where wv means worst-audio and ba means best-audio and the the * should mean "somehow make best-audio the priority!" Sadly, I get mixed results: usually a worst-video file with no audio.
  2. yt-dlp https://url.com/uri -f wv+ba -o "./my/location/filename.mp4". Give the wrong extension.

b.

  1. yt-dlp https://url.com/uri -f ba[ext=m4a] -o "./my/location/filename.m4a" This gives me an m4a file and then I need to do a rename command [ext=mp4] is not an option. This also does not give video, which is NOT IDEAL.

c.

  1. yt-dlp https://url.com/uri -f 134+ba -o "./my/location/filename.mp4" --merge-output-format mp4, where id 134 is 360p video. This gives ERROR: Postprocessing: Stream #1:0 -> #0:1 (copy), and there is no merged output file (only two tmp files with audio-only and video-only).
  2. yt-dlp https://url.com/uri -f 134+ba -o "./my/location/filename.mp4" --merge-output-format mkv && rename filename.mkv filename mp4, where id 134 is 360p video. This gives a file that is an mp4 file, but it is seen by the system as an mkv file (and cannot be used for the desired purpose).

d.

  1. yt-dlp https://url.com/uri -f 134 -o "./my/location/filename.webm && yt-dlp https://url.com/uri -f ba -o "./my/location/filename.m4a" && ffmpeg -i .\relativePath\inputFilename.f251.webm -i .\relativePath\inputFilename.f248.webm -c:v mpeg4 -q:v 0 -q:a 0 -c:v copy .\relativePath\outputFilename.mp4". Note: the audio/video can be input in any order, but the -i flag should come first.

About workaround d.1:

If I use -q:a 100, the output file will be 10 times larger than the input files; so, I think I am not getting lossless audio....

Note: the audio/video can be input in any order, but the -i flag should come first.

Also, it is important to not use asterisks bv*+ba because that will prioritize the best video quality with combined audio, and you need separate files: you can guarantee separate files by excluding the asterisk.

Wolfpack'08
  • 1,155
  • 2
  • 14
  • 37
  • 1
    Have you tried JDownloader yet? After your last similar question I'd assume you have... – Tetsujin Oct 26 '22 at 10:51
  • 1
    `ba` selects a format that contains only audio. `ba*` selects a format that *may* contain a video stream. I'm not sure `wv+ba*` make sense (you can just try...) – PierU Oct 26 '22 at 10:57
  • @PierU It doesn't work, wv+ba* gives me a lq video with no sound. And wv+ba gives me an .mkv file. So I think the best solution is to get worstvideo and bestaudio and then either convert or manually merge? – Wolfpack'08 Oct 27 '22 at 06:13
  • 1
    Check about the `--remux-video` and `--merge-output-format ` options – PierU Oct 27 '22 at 06:39
  • i tried --merge-output-format for example, and it turns out no sound. --remux-video gives me a corrupt file. – Wolfpack'08 Oct 27 '22 at 13:10
  • What I am trying to achieve is specifically not allowed (I found the info in a "codec" section of the yt-dlp manual). The best way to go about this, as far as what I've found in-practice, is with the --merge-output-format option and **be careful of typos**. Because this isn't possible, I continued working and wrote a bash script. The bash script is just section d as a bash function, where the URL, downloaded filename, and output filename are the arguments; finally, I use rm downloadfilename to delete the file. If nobody answers, I'll post the script on 11/11/2022. – Wolfpack'08 Nov 09 '22 at 07:27
  • With ffmpeg and a bash script you can do everything you want. But it does no longer meet your own initial requirement *"ideally, without use of ffmpeg, if possible; alternatively, to use a single command "* – PierU Nov 09 '22 at 07:50
  • @PierU Ultimately, only one bash command is used, but yt-dlp does not have the functionality to obtain the desired result. It cannot remux or recode into h.264 format; so, there is no way to achieve the desired result. I will often get v9 format, which is useless to me. Thank you for your comment. – Wolfpack'08 Nov 10 '22 at 08:07

0 Answers0