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

Re: Embedding subtitles ends in ERROR: Conversion failed! #22090

Closed
PotcFdk opened this issue Aug 13, 2019 · 4 comments
Closed

Re: Embedding subtitles ends in ERROR: Conversion failed! #22090

PotcFdk opened this issue Aug 13, 2019 · 4 comments

Comments

@PotcFdk
Copy link

PotcFdk commented Aug 13, 2019

Regarding an investigation I did that is related to a previously reported issue (#21929):

Consider these two youtube-dl calls:
A: youtube-dl -v -i -f "22/136+bestaudio[ext=m4a]/bestvideo[height<=720]+bestaudio[ext=m4a]/best[height<=720]" --all-subs --embed-subs --merge-output-format mkv -o A.mkv "https://www.youtube.com/watch?v=oGVhOWqsBWM"
B: youtube-dl -v -i -f "bestvideo+bestaudio" --all-subs --embed-subs --merge-output-format mkv -o B.mkv "https://www.youtube.com/watch?v=oGVhOWqsBWM"

They only differ in their -f parameter and their -o filename (A.mkv vs B.mkv).

A ends up with:

[download] Destination: A.mkv
[download] 100% of 46.87MiB in 00:00
[ffmpeg] Embedding subtitles in 'A.mkv'
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i file:A.mkv -i file:A.ko.vtt -i file:A.tr.vtt -i file:A.hr.vtt -i file:A.sr.vtt -i file:A.pt.vtt -i file:A.en.vtt -i file:A.vi.vtt -i file:A.fr.vtt -i file:A.ar.vtt -i file:A.es.vtt -map 0 -c copy -map -0:s -map -0:d -c:s mov_text -map 1:0 -metadata:s:s:0 language=kor -map 2:0 -metadata:s:s:1 language=tur -map 3:0 -metadata:s:s:2 language=hrv -map 4:0 -metadata:s:s:3 language=srp -map 5:0 -metadata:s:s:4 language=por -map 6:0 -metadata:s:s:5 language=eng -map 7:0 -metadata:s:s:6 language=vie -map 8:0 -metadata:s:s:7 language=fra -map 9:0 -metadata:s:s:8 language=ara -map 10:0 -metadata:s:s:9 language=spa file:A.temp.mkv
ERROR: Conversion failed!

while B completes without errors:

[download] Destination: B.mkv.f251
[download] 100% of 6.92MiB in 00:00
[ffmpeg] Merging formats into "B.mkv"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i file:B.mkv.f137 -i file:B.mkv.f251 -c copy -map 0:v:0 -map 1:a:0 file:B.temp.mkv
Deleting original file B.mkv.f137 (pass -k to keep)
Deleting original file B.mkv.f251 (pass -k to keep)
[ffmpeg] Embedding subtitles in 'B.mkv'
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i file:B.mkv -i file:B.en.vtt -i file:B.fr.vtt -i file:B.tr.vtt -i file:B.hr.vtt -i file:B.ko.vtt -i file:B.sr.vtt -i file:B.vi.vtt -i file:B.pt.vtt -i file:B.ar.vtt -i file:B.es.vtt -map 0 -c copy -map -0:s -map -0:d -map 1:0 -metadata:s:s:0 language=eng -map 2:0 -metadata:s:s:1 language=fra -map 3:0 -metadata:s:s:2 language=tur -map 4:0 -metadata:s:s:3 language=hrv -map 5:0 -metadata:s:s:4 language=kor -map 6:0 -metadata:s:s:5 language=srp -map 7:0 -metadata:s:s:6 language=vie -map 8:0 -metadata:s:s:7 language=por -map 9:0 -metadata:s:s:8 language=ara -map 10:0 -metadata:s:s:9 language=spa file:B.temp.mkv
Deleting original file B.en.vtt (pass -k to keep)
Deleting original file B.fr.vtt (pass -k to keep)
Deleting original file B.tr.vtt (pass -k to keep)
Deleting original file B.hr.vtt (pass -k to keep)
Deleting original file B.ko.vtt (pass -k to keep)
Deleting original file B.sr.vtt (pass -k to keep)
Deleting original file B.vi.vtt (pass -k to keep)
Deleting original file B.pt.vtt (pass -k to keep)
Deleting original file B.ar.vtt (pass -k to keep)
Deleting original file B.es.vtt (pass -k to keep)

Comparing the respective ffmpeg calls from A (first line) and B (second line):

ffmpeg -y -loglevel repeat+info -i file:A.mkv -i file:A.ko.vtt -i file:A.tr.vtt -i file:A.hr.vtt -i file:A.sr.vtt -i file:A.pt.vtt -i file:A.en.vtt -i file:A.vi.vtt -i file:A.fr.vtt -i file:A.ar.vtt -i file:A.es.vtt -map 0 -c copy -map -0:s -map -0:d -c:s mov_text -map 1:0 -metadata:s:s:0 language=kor -map 2:0 -metadata:s:s:1 language=tur -map 3:0 -metadata:s:s:2 language=hrv -map 4:0 -metadata:s:s:3 language=srp -map 5:0 -metadata:s:s:4 language=por -map 6:0 -metadata:s:s:5 language=eng -map 7:0 -metadata:s:s:6 language=vie -map 8:0 -metadata:s:s:7 language=fra -map 9:0 -metadata:s:s:8 language=ara -map 10:0 -metadata:s:s:9 language=spa file:A.temp.mkv
ffmpeg -y -loglevel repeat+info -i file:B.mkv -i file:B.en.vtt -i file:B.fr.vtt -i file:B.tr.vtt -i file:B.hr.vtt -i file:B.ko.vtt -i file:B.sr.vtt -i file:B.vi.vtt -i file:B.pt.vtt -i file:B.ar.vtt -i file:B.es.vtt -map 0 -c copy -map -0:s -map -0:d -map 1:0 -metadata:s:s:0 language=eng -map 2:0 -metadata:s:s:1 language=fra -map 3:0 -metadata:s:s:2 language=tur -map 4:0 -metadata:s:s:3 language=hrv -map 5:0 -metadata:s:s:4 language=kor -map 6:0 -metadata:s:s:5 language=srp -map 7:0 -metadata:s:s:6 language=vie -map 8:0 -metadata:s:s:7 language=por -map 9:0 -metadata:s:s:8 language=ara -map 10:0 -metadata:s:s:9 language=spa file:B.temp.mkv

The only difference between these two merge-calls to ffmpeg is that A adds an extra -c:s mov_text.

Question

Is this a bug or an oversight? If not, what is the explanation for youtube-dl specifying a subtitle format that is incompatible with mkv when --merge-output-format mkv is explicitly specified?
Is the subtitle codec chosen based on -f? Why, wouldn't it make more sense to have it chosen based on what the target file container supports?

@dstftw
Copy link
Collaborator

dstftw commented Aug 13, 2019

Once again: do not hardcode the extension in output template. Output template is the template of the file to be downloaded not the target file. Extension of A is mp4 not mkv therefore -c:s mov_text. Hardcoding custom extension in output template will not involve remuxing or recoding of the actual format to that custom extension.

@dstftw dstftw closed this as completed Aug 13, 2019
@PotcFdk
Copy link
Author

PotcFdk commented Aug 13, 2019

@dstftw I see, it was unclear to me, that there was this distinction.
The name "merge output format", to me at least, implied that it specifies the format of the merge output (files being merged into mkv -> merge output format = mkv) and not the format of the download container (pre-merge). I assumed it would simply stream-copy the video and audio data from whatever it downloaded into a newly created merge output container as specified by the user instead of it just being a command line option to "override" the automatic detection (which, to me, seems silly in the first place; care to give a quick example where this would be useful?)
Maybe it'd be wise to rename the option to avoid future confusion?

@dstftw
Copy link
Collaborator

dstftw commented Aug 13, 2019

--merge-output-format is only used when there is something to merge, it has no effect for individual files, read FAQ already.

@PotcFdk
Copy link
Author

PotcFdk commented Aug 13, 2019

I am sorry, I was mentally blind. I read the FAQ entry multiple times but I seem to have missed the correct meaning of "if a merge is required". It's obvious now in hindsight.

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

No branches or pull requests

2 participants