ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.39k stars 9.96k forks source link

Download to MKV Direct instead of MP4 without muxing process after download. #20937

Open suFDHAI78fyw78q09Y98yfd opened 5 years ago

suFDHAI78fyw78q09Y98yfd commented 5 years ago

Checklist

Question

Download to MKV Direct instead of MP4 without muxing process after download. The videos I download are in a TS container but when use --fixup "never" the download completes and always is in a mp4 container which is great.

Today many videos are not malformed audio but have timestamps errors all the way through from many broadcaster services. If take the mp4 video and do mp4 > mkv then back to mp4 everything is fixed and playable without errors. These errors have been present for over a year now and mkv is the only fix I know of so far.

So what I need is instead of TS to mp4 is TS to mkv with using also the --fixup "never" command and have no aac malformed audio or any muxing after download not happen.

To download as is now instead but of mp4 video we have option to have mkv. Without any post processing to do this.

ealgase commented 5 years ago

That's not possible without remuxing. Why don't you want to remux?

suFDHAI78fyw78q09Y98yfd commented 5 years ago

It takes forever to do and slows the download for me by extra 11 mins to the mux afterwards. Where as Direct from source TS parts to mp4 (default) is instant with the --fixup "never" command. Soon as the download is complete that is it on to the next download, no wasted time quick and easy.

Need mkv only for the fixing all the timestamp errors in the mp4. No tool other than mkvtoolnix so far has been able to fix the mp4. I have tried ffmpeg.. mp4 to mkv and that doesn't fix the mp4 timestamps errors either, or maybe it doesn't use same default settings as mkv toolnix 32bit.

Is there reason why Youtube-dl cannot be coded for direct TS parts to mkv as a default option (mp4 default with mkv as the option). Please do test mkv doesn't have the timestamp errors that the mp4 now have, mkvtoolnix as default does well to fix correctly ffmpeg doesn't.

ealgase commented 5 years ago

I have tried ffmpeg.. mp4 to mkv and that doesn't fix the mp4 timestamps errors either

So the issue isn't with the mp4 container, it's with FFmpeg. Can you send me an example file with the bad timestamps so I can investigate?

suFDHAI78fyw78q09Y98yfd commented 5 years ago

https://www.sendspace.com/file/3qb1m8

ealgase commented 5 years ago

Remuxing with ffmpeg -i Episode\ 1.Britain\'s\ Busiest\ Motorway.1.mp4 -c copy -map 0 -map_metadata 0 Episode\ 1.Britain\'s\ Busiest\ Motorway.1.mp4.fixed.mp4 gives a lot of errors but works.

You're going to have to remux at some point, because there's no way to remove the invalid timestamps without remuxing.

suFDHAI78fyw78q09Y98yfd commented 5 years ago

For also other reasons one by a recent post in Youtube-dl issues.

MP4 videos that have E-AC3 audio format, starting to get popular with some video services. MP4 is unable to play those with E-AC3 audio format. MKV is able to play videos with the E-AC3 audio format.

Another that could be a saving grace as would be for the timestamps problem. Direct TS source to MKV as an option would also be useful for when problems arise. Could be useful for people to test with or as a remidy until new code added or broken code is fixed. The user maybe able to continue downloading without missing any videos.

Please consider TS source parts direct to MKV as an option. I'm sure it will help and strengthen Youtube-dl, Thanks.

ealgase commented 5 years ago

This has nothing to do with mkv.

suFDHAI78fyw78q09Y98yfd commented 5 years ago

Did you also notice this which to me is strange, this viewed using mediainfo. General Format : MPEG-TS

Video Format : AVC Format/Info : Advanced Video Codec

...

Format : MPEG-TS

Should this not be as below for an MP4 video container.

Format : MPEG-4

Weird though simply changing the video extension to .ts does speed up the mux process with ffmpeg. I tried it on the download that you now have. A fix for the above to have the container format match the file extension. One need to change to speed up mux process whether video has timestamp errors or not. . The timestamps problem where do you think they originate the video source, video servers, ffmpeg, extractor !

ealgase commented 5 years ago

The timestamps issue is from the video source. And yes, saving to MPEG-TS is weird (I'm not sure but I think it's the extractor that does that). A simple ffmpeg -i video.mp4 -map 0 -map_metadata 0 -c copy outvideo.mp4 should fix it.

ungenio commented 5 years ago

Hello, in my experience, remux on flight to mkv occur the same errors as when done to mp4 if you use ffmpeg. It is useless to do it in mkv because the problem is the ffmpeg HLS download engine.

I always capture in TS using --hls-prefer-native (if not live streaming) because it is more reliable than ffmpeg, and then I remux mkv with mkvtoolnix and not ffmpeg. For capturing live streaming you should use ffmpeg because --hls-prefer-native does not support live streaming, but always in TS never in mp4.

The remux can be automated with a bat file and mkvmerge.exe

mkvmerge.exe -q -o "output.mkv" "input.ts"

(Sorry. I'm using a translator)

ealgase commented 5 years ago

Hello, in my experience, remux on flight to mkv occur the same errors as when done to mp4 if you use ffmpeg. It is useless to do it in mkv because the problem is the ffmpeg HLS download engine.

I can't reproduce the issue? Remuxing with ffmpeg works for me.