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

Downloading video *AND* audio, in a consistent way? #6818

Closed
keybounce opened this issue Sep 9, 2015 · 2 comments
Closed

Downloading video *AND* audio, in a consistent way? #6818

keybounce opened this issue Sep 9, 2015 · 2 comments

Comments

@keybounce
Copy link

@keybounce keybounce commented Sep 9, 2015

Is there a way to download video and audio in a consistent way?

Background: I have a wrapper script for Youtube-dl. At first, when I was playing with YouTube, 480p downloads gave .flv files, and asking for mp4's gave me 360p's with audio. Getting both video and audio from youtube required fetching two files, converting the flv to mp4, and combining.

Next, I found that other sites that had mp4's would return mp4 videos with audio already in them.

Youtube now makes 480p's in mp4 format, and the HTML5 player has been playing mp4's with nothing apparently special about them, so I adjusted my script to fetch mp4 files and be done.

But ... I've discovered that while I've gotten video plus audio from PBS for nova, and from Chrunchyroll for other TV shows, my youtube downloads have been video without audio.

What is the proper way to say "Fetch this video file, and only make an attempt to fetch an additional audio file if there isn't one already in the video"?

For that matter, is there a way to do the same thing with subtitles -- only fetch a subtitle if the video doesn't have one?

My current wrapper:

#!/bin/bash
set -x
# Usage: youtube-480 url
## youtube-dl -f "bestvideo[height<=480][ext=mp4]+bestaudio[ext=m4a]/[height<=?480]" --sub-lang en --write-sub --recode-video mp4 "$@"
youtube-dl -f "bestvideo[height<=480][ext=mp4]" --list-sub "$@" | grep -m 1 '^[eE][nN]' | awk '{print $1}' > /tmp/yt-sub.$$
## youtube-dl -f "bestvideo[height<=480][ext=mp4]" --sub-lang $(cat /tmp/yt-sub.$$) --sub-format ass --write-sub --recode-video mp4 "$@"
youtube-dl -f "bestvideo[height<=480]" --sub-lang $(cat /tmp/yt-sub.$$) --write-sub --embed-subs --recode-video mp4 "$@"
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Sep 9, 2015

If you want video+audio as single file to have higher priority over other formats you should put it first when specifying preference with /, e.g. -f best[height<=480]/bestvideo[height<=480]+bestaudio.
For subtitles - it's not possible.

@keybounce
Copy link
Author

@keybounce keybounce commented Sep 9, 2015

Thank you.

@keybounce keybounce closed this Sep 9, 2015
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
2 participants
You can’t perform that action at this time.