Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change container of opus audio #22490

Open
victordesfe opened this issue Sep 23, 2019 · 16 comments
Open

Change container of opus audio #22490

victordesfe opened this issue Sep 23, 2019 · 16 comments
Labels

Comments

@victordesfe
Copy link

@victordesfe victordesfe commented Sep 23, 2019

Checklist

  • [x ] I'm reporting a feature request
  • [ x] I've verified that I'm running youtube-dl version 2019.09.12.1
  • [x ] I've searched the bugtracker for similar feature requests including closed ones

Description

Hi, with yt-dl i can download the audio from any video, which is great. The thing is, youtube stores opus audio in the webm container.

Is there any function to change the container within the yt-dl process? I tried:
youtube-dl.exe -f "bestaudio[ext=webm]" --batch-file "youtube-dl.txt" --merge-output-format ogg -v
but does nothing, it'll still give you the webm container file.
I believe it's not implemented or something, is there any known workaround?
thanks

@victordesfe victordesfe added the request label Sep 23, 2019
@victordesfe
Copy link
Author

@victordesfe victordesfe commented Sep 23, 2019

also wanted to note, adding .mka (matroska audio container) support would be great, but the main one i'm looking for is the ogg container with .opus extension, as it's the recommended by the original opus specification, and it's also the one with the best compatibility.

@victordesfe
Copy link
Author

@victordesfe victordesfe commented Sep 23, 2019

I've found a way to do this with ffmpeg:
ffmpeg -i input.webm -vn -acodec copy out.opus
however i still think it would be great to get it integrated with yt-dl

@nao20010128nao
Copy link
Contributor

@nao20010128nao nao20010128nao commented Sep 29, 2019

You might want

youtube-dl --audio-format=opus -x

It gives an audio file with .opus extension.

@mcepl
Copy link
Contributor

@mcepl mcepl commented Nov 20, 2019

You might want

youtube-dl --audio-format=opus -x

It gives an audio file with .opus extension.

That's helpful, but not what the original issue was about. --merge-output-format ogg should create file in the ogg container, which is widely more recognized than .opus files. For example, many Android phones can play Opus-encoded files, but they don’t recognize .opus files, only .ogg ones.

Here are my logs:

~@stitny$ youtube-dl -v --merge-output-format ogg https://youtu.be/KNMoYJhicEY
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--merge-output-format', 'ogg', 'https://youtu.be/KNMoYJhicEY']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.11.05
[debug] Python version 3.7.3 (CPython) - Linux-5.3.9-1-default-x86_64-with-glibc2.2.5
[debug] exe versions: ffmpeg 4.2.1, ffprobe 4.2.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] KNMoYJhicEY: Downloading webpage
[youtube] KNMoYJhicEY: Downloading video info webpage
[youtube] {18} signature length 108, html5 player vflss95Jx
[youtube] {43} signature length 104, html5 player vflss95Jx
[youtube] {133} signature length 108, html5 player vflss95Jx
[youtube] {242} signature length 104, html5 player vflss95Jx
[youtube] {160} signature length 108, html5 player vflss95Jx
[youtube] {278} signature length 104, html5 player vflss95Jx
[youtube] {140} signature length 104, html5 player vflss95Jx
[youtube] {249} signature length 108, html5 player vflss95Jx
[youtube] {250} signature length 104, html5 player vflss95Jx
[youtube] {251} signature length 108, html5 player vflss95Jx
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on 'https://r7---sn-vufvj1-2gbl.googlevideo.com/videoplayback?expire=1574268664&ei=mBrVXbyNJdCW8gPC156wDw&ip=83.208.252.159&id=o-APnypPQjYyaZz0goKofwLmqArkJ4euMOe7ztdGh8a5s7&itag=242&aitags=133%2C160%2C242%2C278&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-vufvj1-2gbl%2Csn-2gb7sn7r&ms=au%2Crdu&mv=m&mvi=6&pl=16&initcwndbps=1056250&mime=video%2Fwebm&gir=yes&clen=565256&dur=171.920&lmt=1558258393969535&mt=1574246932&fvip=4&keepalive=yes&fexp=23842630&c=WEB&txp=5432432&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRQIhALKj9NAH2o5C0_LvdnZNWV7meC9ElWmcUCuMX9BdTgHvAiA2EiefypgsUr70Rc5ZVPE3KwPEL6_FIK1BlcpSuQJAWQ%3D%3D&sig=ALgxI2wwRAIgVc-eHSb9Ofj2LOA18DqOjQueq17Rt5inFGGHY_i0SckCIFdPJZ8FSBoE71zP6IB-727U44z56AAbtAQXyOtVC-bS&ratebypass=yes'
[download] Destination: Dick Walters - Hot Liquorice-KNMoYJhicEY.f242.webm
[download] 100% of 552.01KiB in 00:00
[debug] Invoking downloader on 'https://r7---sn-vufvj1-2gbl.googlevideo.com/videoplayback?expire=1574268664&ei=mBrVXbyNJdCW8gPC156wDw&ip=83.208.252.159&id=o-APnypPQjYyaZz0goKofwLmqArkJ4euMOe7ztdGh8a5s7&itag=251&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-vufvj1-2gbl%2Csn-2gb7sn7r&ms=au%2Crdu&mv=m&mvi=6&pl=16&initcwndbps=1056250&mime=audio%2Fwebm&gir=yes&clen=3029551&dur=172.441&lmt=1558258373628919&mt=1574246932&fvip=4&keepalive=yes&fexp=23842630&c=WEB&txp=5432432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRQIhALKj9NAH2o5C0_LvdnZNWV7meC9ElWmcUCuMX9BdTgHvAiA2EiefypgsUr70Rc5ZVPE3KwPEL6_FIK1BlcpSuQJAWQ%3D%3D&sig=ALgxI2wwRQIhAMuWxQAViiJsmbMvFvF6Klaq1zVkVrOp1mJPvVpQfFBNAiBDSEsvgqYtrwNuXsZJZNOuhMlhfluNeoIRZumlfqpkVg==&ratebypass=yes'
[download] Destination: Dick Walters - Hot Liquorice-KNMoYJhicEY.f251.webm
[download] 100% of 2.89MiB in 00:01
[ffmpeg] Merging formats into "Dick Walters - Hot Liquorice-KNMoYJhicEY.ogg"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Dick Walters - Hot Liquorice-KNMoYJhicEY.f242.webm' -i 'file:Dick Walters - Hot Liquorice-KNMoYJhicEY.f251.webm' -c copy -map 0:v:0 -map 1:a:0 'file:Dick Walters - Hot Liquorice-KNMoYJhicEY.temp.ogg'
ERROR:   Stream #1:0 -> #0:1 (copy)
Traceback (most recent call last):
  File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2064, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 512, in run
    self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
  File "/usr/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 235, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError:   Stream #1:0 -> #0:1 (copy)

~@stitny$ youtube-dl -v -x --merge-output-format ogg https://youtu.be/KNMoYJhicEY
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-x', '--merge-output-format', 'ogg', 'https://youtu.be/KNMoYJhicEY']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.11.05
[debug] Python version 3.7.3 (CPython) - Linux-5.3.9-1-default-x86_64-with-glibc2.2.5
[debug] exe versions: ffmpeg 4.2.1, ffprobe 4.2.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] KNMoYJhicEY: Downloading webpage
[youtube] KNMoYJhicEY: Downloading video info webpage
[youtube] {18} signature length 104, html5 player vflss95Jx
[youtube] {43} signature length 104, html5 player vflss95Jx
[youtube] {133} signature length 108, html5 player vflss95Jx
[youtube] {242} signature length 104, html5 player vflss95Jx
[youtube] {160} signature length 104, html5 player vflss95Jx
[youtube] {278} signature length 108, html5 player vflss95Jx
[youtube] {140} signature length 108, html5 player vflss95Jx
[youtube] {249} signature length 104, html5 player vflss95Jx
[youtube] {250} signature length 104, html5 player vflss95Jx
[youtube] {251} signature length 104, html5 player vflss95Jx
[debug] Invoking downloader on 'https://r7---sn-vufvj1-2gbl.googlevideo.com/videoplayback?expire=1574268704&ei=wBrVXY7OJoSP1gKr0L_QCQ&ip=83.208.252.159&id=o-ANdt4qiWgaFUsQFXOVTGNVr55jSXuNXObw-OSw5F3i7G&itag=251&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-vufvj1-2gbl%2Csn-2gb7sn7r&ms=au%2Crdu&mv=m&mvi=6&pcm2cms=yes&pl=16&initcwndbps=1056250&mime=audio%2Fwebm&gir=yes&clen=3029551&dur=172.441&lmt=1558258373628919&mt=1574247032&fvip=4&keepalive=yes&fexp=23842630&c=WEB&txp=5432432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgDl13Cm7nw1xkFZN-XZbimtBmYamwqZh3BF4qbyDEDWQCIAQFlY9IiUyKBx4m29sDN8KlMSQRRPhZ8rj1T0IpURrr&sig=ALgxI2wwRAIgbv-WVcWsHfpImd8r5VgvkYJAMv6KIuyAglK0NFDg39QCIBtl1LmlMohdTKPfl0gwREoZj1CR3QLc38D9BATC6cv2&ratebypass=yes'
[download] Destination: Dick Walters - Hot Liquorice-KNMoYJhicEY.webm
[download] 100% of 2.89MiB in 00:01
[debug] ffmpeg command line: ffprobe -show_streams 'file:Dick Walters - Hot Liquorice-KNMoYJhicEY.webm'
[ffmpeg] Destination: Dick Walters - Hot Liquorice-KNMoYJhicEY.opus
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Dick Walters - Hot Liquorice-KNMoYJhicEY.webm' -vn -acodec copy 'file:Dick Walters - Hot Liquorice-KNMoYJhicEY.opus'
Deleting original file Dick Walters - Hot Liquorice-KNMoYJhicEY.webm (pass -k to keep)
~@stitny$
@mcepl
Copy link
Contributor

@mcepl mcepl commented Nov 24, 2019

What’s actually interesting is that apparently the files IS in Ogg container, just the extension is wrong. See

~@stitny$ ffplay -stats Dick\ Walters\ -\ Hot\ Liquorice-KNMoYJhicEY.opus 
ffplay version 4.2.1 Copyright (c) 2003-2019 the FFmpeg developers
  built with gcc 9 (SUSE Linux)
[...]
Input #0, ogg, from 'Dick Walters - Hot Liquorice-KNMoYJhicEY.opus':
  Duration: 00:02:52.45, start: 0.007500, bitrate: 138 kb/s
    Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp
    Metadata:
      encoder         : Lavf58.29.100
  16.14 M-A: -0.000 fd=   0 aq=   22KB vq=    0KB sq=    0B f=0/0   
~@stitny$
@bitraid
Copy link
Contributor

@bitraid bitraid commented Nov 24, 2019

The extension is not wrong because an .opus file is actually an ogg container with opus audio (opus is a codec and not a conainer).

@mcepl
Copy link
Contributor

@mcepl mcepl commented Nov 24, 2019

The extension is not wrong because an .opus file is actually an ogg container with opus audio (opus is a codec and not a conainer).

Exactly, so if youtube-dl named the generated file .ogg this ticket would be resolved.

@bitraid
Copy link
Contributor

@bitraid bitraid commented Nov 25, 2019

This ticket is about the container and not the extension.

@mcepl
Copy link
Contributor

@mcepl mcepl commented Nov 25, 2019

This ticket is about the container and not the extension.

My point was that this ticket is NOTABUG with regards to the container. Output is already in OGG.

@icheyne
Copy link

@icheyne icheyne commented Jan 7, 2020

I have exactly this problem too. I can download an opus file but I can't play it in Android without renaming it manually to file.ogg. Would be good to know how to get youtube-dl to rename it automatically or just convert it to ogg with FFMPEG.

@mcepl
Copy link
Contributor

@mcepl mcepl commented Jan 7, 2020

Would be good to know how to get youtube-dl to rename it automatically or just convert it to ogg with FFMPEG.

You don’t have to use ffmpeg. mv filename.opus filename.ogg is enough.

@icheyne
Copy link

@icheyne icheyne commented Jan 7, 2020

Sorry I should have explained that I'm using youtube-dl.conf with the following config:

-x
-f worstaudio[ext=m4a]
-o "C:\Users\iain\Sync\audio\%(title)s.%(ext)s"

I'm using m4a because opus files won't play in Android. Would be awesome to just use -f worstaudio and have a playable file.

@mcepl
Copy link
Contributor

@mcepl mcepl commented Jan 7, 2020

I'm using m4a because opus files won't play in Android.

That is not correct. Opus files (renamed to .ogg) do play with the native Android media player.

@pihug12
Copy link

@pihug12 pihug12 commented Jan 18, 2020

It's not clean, but --exec 'ffmpeg -i {} -vn -acodec copy "$(basename -- {} .webm).ogg" && rm {}' seems to be working with Webm/Opus format as input.

Example: youtube-dl -f 250 --exec 'ffmpeg -i {} -vn -acodec copy "$(basename -- {} .webm).ogg" && rm {}' https://www.youtube.com/watch?v=2EaxYi31ips

@icheyne
Copy link

@icheyne icheyne commented Jan 18, 2020

That's a decent solution. Thank you.

@tripulse
Copy link

@tripulse tripulse commented Mar 10, 2020

Extension lies but magic code doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.