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.

Download video and audio, convert audio only and merge previously downloaded video and converted audio

See original GitHub issue

Checklist

Question

For example, when I download this video from YouTube and select the 299+251 formats they merge into MKV because of format incompatibility (avc1.64001e+opus), but I need the video and audio to be in the MP4 container, i.e. convert from opus to aac the audio since the video codec is compatible with the container.

How can I leave the video alone (not reencode it), convert only the audio to aac and then merge the unmodified video and the converted audio? I have tried with the --audio format or -x option but I get different outputs that don’t solve my problem.

Verbose log

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
pukkandancommented, Mar 18, 2022

try this

❯ yt-dlp test:youtube -f 137+251 -v --recode mp4 --ppa "VideoConvertor:-vcodec copy"
[debug] Command-line config: ['test:youtube', '-f', '137+251', '-v', '--recode', 'mp4', '--ppa', 'VideoConvertor:-vcodec copy']
[debug] Encodings: locale cp65001, fs utf-8, out utf-8, err utf-8, pref cp65001
[debug] yt-dlp version 2022.03.08.1 [c0c2c57d3] (source)
[debug] Lazy loading extractors is disabled
[debug] Plugins: ['SamplePluginIE', 'SamplePluginPP']
[debug] Git HEAD: e4b98809c
[debug] Python version 3.10.3 (CPython 64bit) - Windows-10-10.0.22000-SP0
[debug] exe versions: ffmpeg N-105465-gbedb4bac1c-20220206 (fdk,setts), ffprobe N-105465-gbedb4bac1c-20220206, phantomjs 2.1.1
[debug] Optional libraries: brotli, Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] [TestURL] Extracting URL: test:youtube
[TestURL] Test URL: https://www.youtube.com/watch?v=BaW_jenozKc&t=1s&end=9
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=BaW_jenozKc&t=1s&end=9
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[info] BaW_jenozKc: Downloading 1 format(s): 137+251
WARNING: Requested formats are incompatible for merge and will be merged into mkv
[debug] Invoking downloader on "https://rr3---sn-gwpa-jjwe.googlevideo.com/videoplayback?expire=1647642355&ei=k7I0YsO4AbairtoPvu2A8Ac&ip=2405%3A201%3Af003%3Abaf6%3A2156%3A189f%3Ad8cf%3A3de1&id=o-AK7pVqZVSoRfCXTtLDjhnipt5Jgh4pNuMBb2Hy-a-Yin&itag=137&source=youtube&requiressl=yes&mh=Rf&mm=31%2C29&mn=sn-gwpa-jjwe%2Csn-gwpa-h55e7&ms=au%2Crdu&mv=m&mvi=3&pcm2cms=yes&pl=47&initcwndbps=170000&vprv=1&mime=video%2Fmp4&gir=yes&clen=2208750&dur=9.800&lmt=1387961822987808&mt=1647620221&fvip=1&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgBo_cb_vZSIe__R438WndEyyTp8yjPyKOfLuJgbllGyUCIQCEaPDDjGfafuUKx848WHssD4Two2vq1sDiZhI3Haz8Iw%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgIMsfTWkr12pqaCnTbCQhLwrSF8X9XFWTc1Xu9UUDZ2MCIQCWAsxdK7fKqK06V9YsPLmWNdeKyktxU_HZlhfnSdtP8g%3D%3D"
[download] Destination: youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].f137.mp4
[download] 100% of 2.11MiB in 00:00
[debug] Invoking downloader on "https://rr3---sn-gwpa-jjwe.googlevideo.com/videoplayback?expire=1647642355&ei=k7I0YsO4AbairtoPvu2A8Ac&ip=2405%3A201%3Af003%3Abaf6%3A2156%3A189f%3Ad8cf%3A3de1&id=o-AK7pVqZVSoRfCXTtLDjhnipt5Jgh4pNuMBb2Hy-a-Yin&itag=251&source=youtube&requiressl=yes&mh=Rf&mm=31%2C29&mn=sn-gwpa-jjwe%2Csn-gwpa-h55e7&ms=au%2Crdu&mv=m&mvi=3&pcm2cms=yes&pl=47&initcwndbps=170000&vprv=1&mime=audio%2Fwebm&gir=yes&clen=142292&dur=9.841&lmt=1506055557712479&mt=1647620221&fvip=1&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAIuPfjfefKuluMaXGWiSnyNYyY9eaVP_Rkp6RyPhtG-xAiAsTbomG4wy4tWvKylyCtLJV_dJj9IJKTopUA-R5PMyFA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgIMsfTWkr12pqaCnTbCQhLwrSF8X9XFWTc1Xu9UUDZ2MCIQCWAsxdK7fKqK06V9YsPLmWNdeKyktxU_HZlhfnSdtP8g%3D%3D"
[download] Destination: youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].f251.webm
[download] 100% of 138.96KiB in 00:00
[Merger] Merging formats into "youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].mkv"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].f137.mp4" -i "file:youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].f251.webm" -c copy -map "0:v:0" -map "1:a:0" -movflags "+faststart" "file:youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].temp.mkv"
Deleting original file youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].f251.webm (pass -k to keep)
Deleting original file youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].f137.mp4 (pass -k to keep)
[VideoConvertor] Converting video from mkv to mp4; Destination: youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].mp4
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].mkv" -movflags "+faststart" -vcodec copy "file:youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].mp4"
Deleting original file youtube-dl test video ''_ä↭𝕐  [BaW_jenozKc].mkv (pass -k to keep)
1reaction
megapro17commented, Mar 19, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Online Audio Converter - Сonvert audio files to MP3, WAV ...
Our converter works with over 300 different file formats including video formats, converting them to mp3, wav, m4a, flac, ogg, amr, mp2, and...
Read more >
6 Ways to Convert Video to Audio for FREE [2022]
The steps are given below explain the process of converting video to audio with Audacity: Step 1: Install Supported Tools. Assuming that Audacity...
Read more >
Media.io - Online Free Video Editor, Converter, Compressor
Use Media.io free online tools to edit, convert, or compress video/audio/image files in 3 easy steps. Its video editor comes with handy features...
Read more >
How to merge the audio and video of separate files into one ...
Yes, Cisdem Video Converter can help me merge several audios and videos into a large MP4 file easily and quickly. If the added...
Read more >
How to merge audio and video file in ffmpeg - Super User
Merging video and audio, with audio re-encoding. See this example, taken from this blog entry but updated for newer syntax. It should be...
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