Gentoo Archives: gentoo-user

From: Mick <michaelkintzios@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: youtube-dl and mpv.conf file
Date: Thu, 18 Apr 2019 11:39:33
Message-Id: 5284426.nnIdErqHG1@dell_xps
In Reply to: Re: [gentoo-user] Re: youtube-dl and mpv.conf file by Walter Dnes
1 On Thursday, 18 April 2019 03:43:05 BST Walter Dnes wrote:
2 > This thread has piqued my interest in youtube-dl. I'm trying to get
3 > best audio and video together in a 1920x1080 video for Youtube URL
4 > https://www.youtube.com/watch?v=A9tKncAdlHQ
5 >
6 > My config file is...
7 >
8 > -f bestvideo[width<=1920]+bestaudio
9 > --merge-output-format mp4
10
11 Best audio available may not be compatible with an mp4 container without some
12 manual conversion - see below.
13
14
15 > --no-mtime
16 > --no-playlist
17 > -o ~/ytdl/%(title)s.%(ext)s
18 > --restrict-filenames
19 >
20 > If I use "-f bestvideo[width<=1920]" I get a 1920x1080 video...with no
21 > sound.
22
23 Yes, because this is what you asked - video stream only.
24
25
26 > If I use "-f best[width<=1920]" I get a 1280x720 video with
27 > sound.
28
29 Yes, this will download a *single* container file which contains both video
30 and audio pre-muxed streams, with the best quality video size of less or equal
31 to 1920px in width. Youtube has a 720p single file available containing both
32 audio and video, so this is selected.
33
34
35 > That works, but I want the best of both worlds. With
36 > "-f bestvideo[width<=1920]+bestaudio", ffmpeg fails...
37 >
38 > [i660][waltdnes][~/ytdl] youtube-dl
39 > https://www.youtube.com/watch?v=A9tKncAdlHQ [youtube] A9tKncAdlHQ:
40 > Downloading webpage
41 > [youtube] Downloading just video A9tKncAdlHQ because of --no-playlist
42 > [download] Destination:
43 > /home/waltdnes/ytdl/Double_Slit_Experiment_explained_by_Jim_Al-Khalili.f137
44 > .mp4 [download] 100% of 31.55MiB in 00:17
45 > [download] Destination:
46 > /home/waltdnes/ytdl/Double_Slit_Experiment_explained_by_Jim_Al-Khalili.f251
47 > .webm [download] 100% of 6.65MiB in 00:03
48 > [ffmpeg] Merging formats into
49 > "/home/waltdnes/ytdl/Double_Slit_Experiment_explained_by_Jim_Al-Khalili.mp4
50 > " ERROR: Stream #1:0 -> #0:1 (copy)
51 >
52 > Any idea what's wrong?
53
54 Looking at the above output and also taking a look at the formats available
55 for download:
56
57 $ youtube-dl -F 'https://www.youtube.com/watch?v=A9tKncAdlHQ'
58 [youtube] A9tKncAdlHQ: Downloading webpage
59 [youtube] A9tKncAdlHQ: Downloading video info webpage
60 [info] Available formats for A9tKncAdlHQ:
61 format code extension resolution note
62 249 webm audio only DASH audio 54k , opus @ 50k, 3.24MiB
63 250 webm audio only DASH audio 71k , opus @ 70k, 3.62MiB
64 140 m4a audio only DASH audio 128k , m4a_dash container, mp4a.40.2@128k,
65 8.29MiB
66 171 webm audio only DASH audio 133k , vorbis@128k, 6.09MiB
67 251 webm audio only DASH audio 137k , opus @160k, 6.65MiB
68 278 webm 256x144 144p 96k , webm container, vp9, 25fps, video only,
69 4.42MiB
70 160 mp4 256x144 144p 112k , avc1.4d400c, 25fps, video only, 2.09MiB
71 242 webm 426x240 240p 224k , vp9, 25fps, video only, 5.26MiB
72 133 mp4 426x240 240p 268k , avc1.4d4015, 25fps, video only, 4.72MiB
73 243 webm 640x360 360p 404k , vp9, 25fps, video only, 11.51MiB
74 134 mp4 640x360 360p 616k , avc1.4d401e, 25fps, video only, 9.64MiB
75 244 webm 854x480 480p 678k , vp9, 25fps, video only, 20.51MiB
76 135 mp4 854x480 480p 1186k , avc1.4d401e, 25fps, video only, 15.17MiB
77 247 webm 1280x720 720p 1328k , vp9, 25fps, video only, 26.90MiB
78 136 mp4 1280x720 720p 2037k , avc1.4d401f, 25fps, video only, 22.90MiB
79 248 webm 1920x1080 1080p 2349k , vp9, 25fps, video only, 34.44MiB
80 137 mp4 1920x1080 1080p 2710k , avc1.640028, 25fps, video only, 31.55MiB
81 18 mp4 640x360 medium , avc1.42001E, mp4a.40.2@ 96k, 23.30MiB
82 43 webm 640x360 medium , vp8.0, vorbis@128k, 28.60MiB
83 22 mp4 1280x720 hd720 , avc1.64001F, mp4a.40.2@192k (best)
84
85 we can see you downloaded formats .f137 and .f251. The 137 file is a 1080p
86 video only file within an mp4 container. The 251 file is an opus audio file
87 within a webm container.
88
89 If you do not specify an output format for youtube-dl to transcode the video
90 and audio into, the application will use a matroska container:
91
92 [ffmpeg] Merging formats into "Double Slit Experiment explained! by Jim Al-
93 Khalili-A9tKncAdlHQ.mkv"
94
95 which will retain the best video with the size you requested as h264 *and* the
96 best audio it could find as opus. This will adhere to your request for a best
97 video and best audio.
98
99 I do not think it would be logical for youtube-dl to transcode the audio from
100 opus to aac, which is a suitable format for an mp4 container. For this you
101 would need to specify manually the bitrate to be used by m4a and potentially
102 other parameters to suit your preferences and then wait for ffmpeg to
103 transcode the audio, which on a large download would take a while. It would
104 be more logical to specify a suitable audio format for the container you
105 intend to use upfront and ytdl would fetch this without any expensive post-
106 processing. I suppose the devs could introduce a simple test to flag
107 alternative audio formats available for download, which would be compatible
108 with an mp4 container, instead of blindly downloading the opus stream and then
109 ffmpeg failing to copy it into mp4. I assume the ytdl extractor logic is not
110 linked into the post-processing ffmpeg logic (two separate stages) and this is
111 why it errors out in the fashion you experienced.
112
113 On a practical level, if the mkv container is not suitable for you, you could
114 instead restrict the audio format to m4a and then ytdl will download the .f140
115 file rather than .f251 and mux video and audio into an mp4 container - but
116 arguably this won't represent the 'best' audio.
117
118 --
119 Regards,
120 Mick

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] Re: youtube-dl and mpv.conf file Walter Dnes <waltdnes@××××××××.org>