question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add "postprocessing" section to readme

See original GitHub issue

Checklist

  • I’m reporting a bug unrelated to a specific site
  • I’ve verified that I’m running yt-dlp version 2022.02.04. (update instructions)
  • I’ve checked that all provided URLs are alive and playable in a browser
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar issues including closed ones. DO NOT post duplicates
  • I’ve read the guidelines for opening an issue

Description

I am trying to download audio only and convert that audio to PCM.

For some reason, when a format argument (in my case, -f s16le) is specified in --postprocessor-args, m4a fixup (where it apparently adjusts the file to not be a DASH one or something like that) doesn’t seem to actually happen, although it says it does and it doesn’t give an error.

I’ve omitted the --extract-audio --audio-format wav stuff as that falls over at the end as a result, but I don’t think it’s connected to this as I can see the m4a file is clearly wrong after the first command has run.

Command 1 (with -f s16le)

yt-dlp -o "%(id)s.%(ext)s" -f bestaudio/best --postprocessor-args "ffmpeg:-ac 2 -f s16le -ar 48000" --compat-options youtube-dl https://www.youtube.com/watch?v=54rwawswQpM/

Command 2 (without -f s16le)

yt-dlp -o "%(id)s.%(ext)s" -f bestaudio/best --postprocessor-args "ffmpeg:-ac 2 -ar 48000" --compat-options youtube-dl https://www.youtube.com/watch?v=54rwawswQpM/

Verbose log

Command 1 output:

[debug] Command-line config: ['-o', '%(id)s.%(ext)s', '-f', 'bestaudio/best', '--postprocessor-args', 'ffmpeg:-ac 2 -f s16le -ar 48000', '--compat-options', 'youtube-dl', 'https://www.youtube.com/watch?v=54rwawswQpM/', '-vU']
[debug] Encodings: locale cp1252, fs utf-8, out cp1252 (No ANSI), err cp1252 (No ANSI), pref cp1252
[debug] yt-dlp version 2022.02.04 [c1653e9] (win_exe)
[debug] Compatibility options: no-youtube-unavailable-videos, format-spec, seperate-video-versions, no-attach-info-json, playlist-index, no-youtube-channel-redirect, list-formats, embed-thumbnail-atomicparsley, no-clean-infojson, embed-metadata, no-direct-merge, *filename, no-playlist-metafiles, no-keep-subs, abort-on-error, format-sort, no-live-chat
[debug] Python version 3.8.10 (CPython 64bit) - Windows-8.1-6.3.9600-SP0
[debug] exe versions: ffmpeg 5.0-full_build-www.gyan.dev (setts), ffprobe 5.0-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.02.04, Current version: 2022.02.04
yt-dlp is up to date (2022.02.04)
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=54rwawswQpM/
[youtube] 54rwawswQpM: Downloading webpage
[youtube] 54rwawswQpM: Downloading android player API JSON
[debug] Sort order given by user: hasaud, lang, quality, tbr, filesize, vbr, height, width, proto, vext, abr, aext, fps, fs_approx, source, id
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, hasaud, lang, quality, tbr, filesize, vbr, height, width, proto, vext, abr, aext, fps, fs_approx, source, id, res, hdr:12(7), vcodec:vp9.2(10), acodec, asr
[info] 54rwawswQpM: Downloading 1 format(s): 140
[debug] Invoking downloader on "https://rr5---sn-aigl6nl7.googlevideo.com/videoplayback?<REDACTED>"
[download] Destination: 54rwawswQpM.m4a

[download]   0.0% of 5.29MiB at Unknown speed ETA Unknown
[download]   0.1% of 5.29MiB at Unknown speed ETA Unknown
[download]   0.1% of 5.29MiB at Unknown speed ETA Unknown
[download]   0.3% of 5.29MiB at  7.50MiB/s ETA 00:00     
[download]   0.6% of 5.29MiB at  3.87MiB/s ETA 00:01
[download]   1.2% of 5.29MiB at  4.85MiB/s ETA 00:01
[download]   2.3% of 5.29MiB at  6.05MiB/s ETA 00:00
[download]   4.7% of 5.29MiB at  7.97MiB/s ETA 00:00
[download]   9.4% of 5.29MiB at 11.61MiB/s ETA 00:00
[download]  18.9% of 5.29MiB at 15.98MiB/s ETA 00:00
[download]  37.8% of 5.29MiB at 18.95MiB/s ETA 00:00
[download]  75.6% of 5.29MiB at 18.36MiB/s ETA 00:00
[download] 100% of 5.29MiB at 18.43MiB/s ETA 00:00  
[download] 100% of 5.29MiB in 00:00               
[FixupM4a] Correcting container of "54rwawswQpM.m4a"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:54rwawswQpM.m4a" -map 0 -dn -ignore_unknown -c copy -f mp4 -movflags "+faststart" -ac 2 -f s16le -ar 48000 "file:54rwawswQpM.temp.m4a"

Command 2 output:

[debug] Command-line config: ['-o', '%(id)s.%(ext)s', '-f', 'bestaudio/best', '--postprocessor-args', 'ffmpeg:-ac 2 -ar 48000', '--compat-options', 'youtube-dl', 'https://www.youtube.com/watch?v=54rwawswQpM/', '-vU']
[debug] Encodings: locale cp1252, fs utf-8, out cp1252 (No ANSI), err cp1252 (No ANSI), pref cp1252
[debug] yt-dlp version 2022.02.04 [c1653e9] (win_exe)
[debug] Compatibility options: no-attach-info-json, embed-metadata, embed-thumbnail-atomicparsley, no-youtube-unavailable-videos, no-clean-infojson, no-direct-merge, list-formats, no-youtube-channel-redirect, no-keep-subs, *filename, no-playlist-metafiles, seperate-video-versions, playlist-index, format-spec, no-live-chat, format-sort, abort-on-error
[debug] Python version 3.8.10 (CPython 64bit) - Windows-8.1-6.3.9600-SP0
[debug] exe versions: ffmpeg 5.0-full_build-www.gyan.dev (setts), ffprobe 5.0-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.02.04, Current version: 2022.02.04
yt-dlp is up to date (2022.02.04)
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=54rwawswQpM/
[youtube] 54rwawswQpM: Downloading webpage
[youtube] 54rwawswQpM: Downloading android player API JSON
[debug] Sort order given by user: hasaud, lang, quality, tbr, filesize, vbr, height, width, proto, vext, abr, aext, fps, fs_approx, source, id
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, hasaud, lang, quality, tbr, filesize, vbr, height, width, proto, vext, abr, aext, fps, fs_approx, source, id, res, hdr:12(7), vcodec:vp9.2(10), acodec, asr
[info] 54rwawswQpM: Downloading 1 format(s): 140
[debug] Invoking downloader on "https://rr5---sn-aigzrne7.googlevideo.com/videoplayback?<REDACTED>"
[download] Destination: 54rwawswQpM.m4a

[download]   0.0% of 5.29MiB at 341.28KiB/s ETA 00:15
[download]   0.1% of 5.29MiB at 1023.83KiB/s ETA 00:05
[download]   0.1% of 5.29MiB at  2.33MiB/s ETA 00:02  
[download]   0.3% of 5.29MiB at  5.00MiB/s ETA 00:01
[download]   0.6% of 5.29MiB at  3.87MiB/s ETA 00:01
[download]   1.2% of 5.29MiB at  4.85MiB/s ETA 00:01
[download]   2.3% of 5.29MiB at  6.05MiB/s ETA 00:00
[download]   4.7% of 5.29MiB at  7.73MiB/s ETA 00:00
[download]   9.4% of 5.29MiB at 11.61MiB/s ETA 00:00
[download]  18.9% of 5.29MiB at 15.50MiB/s ETA 00:00
[download]  37.8% of 5.29MiB at 17.20MiB/s ETA 00:00
[download]  75.6% of 5.29MiB at 17.80MiB/s ETA 00:00
[download] 100% of 5.29MiB at 17.94MiB/s ETA 00:00  
[download] 100% of 5.29MiB in 00:00               
[FixupM4a] Correcting container of "54rwawswQpM.m4a"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:54rwawswQpM.m4a" -map 0 -dn -ignore_unknown -c copy -f mp4 -movflags "+faststart" -ac 2 -ar 48000 "file:54rwawswQpM.temp.m4a"

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
marcello-pietroboncommented, Jun 17, 2022

Just confirming that this thread has been very useful, and that it would be very useful to add some sections with practical examples on how to use --postprocessor-args , --use-postprocessor, and similar.

Beside that, the yt-dlp documentation is excellent.

1reaction
Zirrocommented, Feb 14, 2022

There are two postprocessors involved here - FixupM4a and ExtractAudio. I think you’ll want to use --postprocessor-args 'ExtractAudio:-ac 2 -ar 48000' to only pass the arguments to the latter instead.

I also removed the -f flag since s16le appears to be the default for WAV files, and doesn’t seem to be an accepted value for this flag either way. Perhaps what you were looking for was -c:a pcm_s16le?

Here’s the full command with these modifications:

yt-dlp -o '%(id)s.%(ext)s' -f 'bestaudio/best' --postprocessor-args 'ExtractAudio:-c:a pcm_s16le -ac 2 -ar 48000' --compat-options 'youtube-dl' 'https://www.youtube.com/watch?v=54rwawswQpM' -vU --extract-audio --audio-format wav

EDIT: -f does seem to take s16le under some circumstances, after all. This page appears to have examples for what you’re trying to achieve (using both -f and -c:a): https://trac.ffmpeg.org/wiki/audio types

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add post processing options when using youtube-dl in ...
To replicate --embed-thumbnail and --add-metadata , use the following: from __future__ import unicode_literals import youtube_dl ydl_opts ...
Read more >
Gst-nvdspostprocess in DeepStream
This section mentions the parsing functions present in postprocess library for available network architectures. Custom Parsing functions ...
Read more >
README.md · master · Water / facet · GitLab - USGS.gov
FACET provides two options for identifying stream banks in the DEM: Slope break approach using cross-sections; Wavelet curvature approach using ...
Read more >
Walkthrough Part I: Generate a Simple Documentation Website
This walkthrough uses the first one: Use docfx.exe directly. Download docfx.zip and unzip it to D:\docfx\; Add D:\docfx\ to PATH so that ...
Read more >
Conda-build recipes
Performs some necessary post-processing steps, such as shebang and rpath. Creates a conda package containing all the files in the build environment that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found