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.22k stars 9.93k forks source link

[Request] Output format TS (MPEG Transport Stream) #11498

Open Reino17 opened 7 years ago

Reino17 commented 7 years ago

The purpose of my issue is:

ffmpeg version N-82759-g1f5630a-Sherpya Copyright (c) 2000-2016 the FFmpeg developers built with gcc 6.2.1 (GCC) 20161118 Option bsf:v (A comma-separated list of bitstream filters) cannot be applied to input file ht tps://r4---sn-mn4vg5aa-5hns.googlevideo.com/...... -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to. Error parsing options for input file https://r4---sn-mn4vg5aa-5hns.googlevideo.com/....... Error opening input files: Invalid argument

ERROR: ffmpeg exited with code 1 File "main.py", line 19, in File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l__init__.py", line 444, in main File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l__init__.py", line 434, in _real_main File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 1791, in download File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 705, in extract_info File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 751, in process_ie_result File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 1435, in process_video_result File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 1699, in process_info File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 1641, in dl File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\downloader\common.py", line 353, in download File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\downloader\external.py", line 43, in real_download File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\downloader\common.py", line 162, in report_error File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 568, in report_error File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmph8curlv3\build\youtube_d l\YoutubeDL.py", line 530, in trouble


but this errors out because `-bsf:v h264_mp4toannexb` is put in front of the input file, when in fact it should be inserted after `' -i 'https://r4---sn-mn4vg5aa-5hns.googlevideo.com/......' -c copy`.
To be clear: to convert MP4 to TS the bitstream filter `-bsf:v h264_mp4toannexb` is needed!

I've also tried without `--external-downloader-args "-bsf:v h264_mp4toannexb"`. Youtube-dl then puts out a TS-file, but only because I forced it to with `-o "%(title)s.ts"`. In the end the video is still a MP4-file, because of the `-f mp4` in the ffmpeg command line, which seems to be hardcoded in the source.

`--recode-video ts` certainly wouldn't be an option, because this doesn't involve a recode/conversion, but just a special remux.
`--merge-output-format ts` could be an option, but there's no merge required for `-f 18` in this case, because it's already a MP4-file.
So I was actually looking for something like `--output-format ts` which then inserts `-f mpegts` instead of `-f mp4`. FFMpeg then automatically inserts `-bsf:v h264_mp4toannexb`.
Better yet: FFMpeg is so smart that as long as you make sure the output file ends with the ts-extension, then `' -i 'https://r4---sn-mn4vg5aa-5hns.googlevideo.com/......' -c copy 'file:Amsterdam - Gewelddadige beroving toerist.ts'` is enough. In the background FFMpeg automatically inserts `-bsf:v h264_mp4toannexb -f mpegts`. (I'm not sure whether `--no-part` should be enabled for this or not)

Why the request for TS as output format in the first place?
Because officially the only way to concatenate H.264 video's is when they're raw (*.h264), or in a MPEG Transport Stream container.
asmolcic commented 7 years ago

I don't know anything about python but I have found in ffmpeg.py a method "run_ffmpeg_multiple_files". Inthere, options are added from the configuration args and the command line is extended with the input option ("-i") and the file name. So, all the input files come to the end of the command line and output options remain at the beginning. I think this is a valid request.