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

Allow using ffmpeg -vf ( video filters ) in --external-downloader-args #12072

Open
basiclaser opened this issue Feb 10, 2017 · 10 comments
Open

Allow using ffmpeg -vf ( video filters ) in --external-downloader-args #12072

basiclaser opened this issue Feb 10, 2017 · 10 comments
Labels

Comments

@basiclaser
Copy link

@basiclaser basiclaser commented Feb 10, 2017

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.02.10. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • [x ] I've verified and I assure that I'm running youtube-dl 2017.02.10

Before submitting an issue make sure you have:

  • [x ] At least skimmed through README and most notably FAQ and BUGS sections
  • [ x] Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • [ x] Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • [ x] Feature request (request for a new functionality)
  • Question
  • Other

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output:

Option vf (set video filters) cannot be applied to input url http://livestream-f.akamaihd.net/i/23093026_6897778_lsiswg499e87c8vkhxz_1@407805/index_2320_av-b.m3u8?sd=10&dw=100&rebase=on&hdntl=exp=1486831046~acl=%2fi%2f23093026_6897778_lsiswg499e87c8vkhxz_1%40407805%2f*~data=hdntl~hmac=480a5086e32f3ffea64b61645ab7db0738f7e7e1c8000aeccd91de259aa8f63a -- 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 http://livestream-f.akamaihd.net/i/23093026_6897778_lsiswg499e87c8vkhxz_1@407805/index_2320_av-b.m3u8?sd=10&dw=100&rebase=on&hdntl=exp=1486831046~acl=%2fi%2f23093026_6897778_lsiswg499e87c8vkhxz_1%40407805%2f*~data=hdntl~hmac=480a5086e32f3ffea64b61645ab7db0738f7e7e1c8000aeccd91de259aa8f63a.
Error opening input files: Invalid argument


ERROR: ffmpeg exited with code 1
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 19, in <module>
    youtube_dl.main()
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 451, in main
    _real_main(argv)
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 441, in _real_main
    retcode = ydl.download(all_urls)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1791, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 705, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 751, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1435, in process_video_result
    self.process_info(new_info)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1699, in process_info
    success = dl(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1641, in dl
    return fd.download(name, info)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 353, in download
    return self.real_download(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/hls.py", line 77, in real_download
    return fd.real_download(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/external.py", line 43, in real_download
    self.get_basename(), retval))
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 162, in report_error
    self.ydl.report_error(*args, **kargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 568, in report_error
    self.trouble(error_message, tb)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 530, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())


Description of your issue, suggested solution and other information

I would like to add a timestamp to a live video stream that I'm downloading. The command I'm running is as follows:

youtube-dl --hls-use-mpegts --external-downloader-args "-vf \"drawtext=fontfile=/Library/Fonts/Arial Black.ttf: \
text='%{localtime\:%c}': fontcolor=white@0.8: fontsize=24: box=1: boxcolor=black@0.5: \
boxborderw=5: x=(w-text_w)-10: y=10\"" "https://livestream.com/accounts/23093026/events/6897778/\
player?enableInfoAndActivity=true&autoPlay=true&mute=false&startswith=true"

I have tested the ffmpeg -vf drawtext arguments without youtube-dl and the timestamp is video filter is correctly added. example:

ffmpeg -i test.mp4 -s 640x480 -r 30 \
-vf "drawtext=fontfile=/Library/Fonts/Arial Black.ttf: \
text='%{localtime\:%c}': fontcolor=white@0.8: fontsize=24: box=1: boxcolor=black@0.5: \
boxborderw=5: x=(w-text_w)-10: y=10" -vcodec libx264 -vb 2000k \
-preset ultrafast -f mp4 output.mp4

But the error above ( Option vf (set video filters) cannot be applied to input url ... ) shows up when i run the youtube-dl command above. Please can you tell me if you know of a way I can get a time stamp appended to my livestream download? Thank you very much.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Feb 10, 2017

An adhoc fix:

diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py
index bdd3545a2..61acb3510 100644
--- a/youtube_dl/downloader/external.py
+++ b/youtube_dl/downloader/external.py
@@ -208,8 +208,6 @@ class FFmpegFD(ExternalFD):
             # http://trac.ffmpeg.org/ticket/6125#comment:10
             args += ['-seekable', '1' if seekable else '0']
 
-        args += self._configuration_args()
-
         # start_time = info_dict.get('start_time') or 0
         # if start_time:
         #     args += ['-ss', compat_str(start_time)]
@@ -269,7 +267,9 @@ class FFmpegFD(ExternalFD):
             if live:
                 args += ['-rtmp_live', 'live']
 
-        args += ['-i', url, '-c', 'copy']
+        args += ['-i', url]
+        args += self._configuration_args()
+
         if protocol in ('m3u8', 'm3u8_native'):
             if self.params.get('hls_use_mpegts', False) or tmpfilename == '-':
                 args += ['-f', 'mpegts']
@yan12125 yan12125 changed the title Issue using ffmpeg -vf ( video filters ) in --postprocessor-args Allow using ffmpeg -vf ( video filters ) in --external-downloader-args Feb 10, 2017
@yan12125 yan12125 added the request label Feb 10, 2017
@johnhawkinson
Copy link
Contributor

@johnhawkinson johnhawkinson commented Feb 12, 2017

That fix seems problematic (maybe that's why you didn't commit it), since ffmpeg can have input args and output args. Right now, --external-downloader-args are treated as input args, and with your patch they change to output args. But both kinds of args are potentially useful, so a different paradigm is needed somehow...

Maybe a wrapper script to ffmpeg is the right solution in this case? That's not very appealing either, especially for output args if it involves removing -c copy.

I guess that leaves --external-downloader-output-args?
Or --external-downloader-args=input-args-here {} output-args-here or something...

@basiclaser
Copy link
Author

@basiclaser basiclaser commented Feb 19, 2017

how would i do this? would i have to modify source? I cant find the file in my machine with the executable present.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Feb 19, 2017

would i have to modify source?

Yes

I cant find the file in my machine with the executable present.

You can download https://github.com/rg3/youtube-dl/archive/master.zip and extract it

@basiclaser
Copy link
Author

@basiclaser basiclaser commented Feb 24, 2017

Hi again, I made the changes as @yan12125 demonstrated, and recompiled the source code, but after checking the video (ctrl-c, remove '.part', then play in vlc) from the livestream, there are no timestamps appended to the video. Is the VF appended only after the stream/download finishes or something? when running the ffmpeg command outside of youtube-dl, the same command certainly works. Thanks

@johnhawkinson
Copy link
Contributor

@johnhawkinson johnhawkinson commented Feb 24, 2017

When you run youtube-dl with -v what is the full output? How does it show it invoking ffmpeg?

@basiclaser
Copy link
Author

@basiclaser basiclaser commented Feb 24, 2017

[debug] System config: []
[debug] User config: [u'--hls-prefer-native']
[debug] Custom config: []
[debug] Command-line args: [u'-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.02.24
[debug] Python version 2.7.10 - Darwin-14.5.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.2.3, ffprobe 3.2.3
[debug] Proxy map: {}
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.
ffmpeg version 3.2.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
@johnhawkinson
Copy link
Contributor

@johnhawkinson johnhawkinson commented Feb 24, 2017

I'm sorry, I meant the full output of the actual download with the addition of -v, not just -v by itself. That is:

youtube-dl -v --hls-use-mpegts --external-downloader-args "-vf \"drawtext=fontfile=/Library/Fonts/Arial Black.ttf: \
text='%{localtime\:%c}': fontcolor=white@0.8: fontsize=24: box=1: boxcolor=black@0.5: \
boxborderw=5: x=(w-text_w)-10: y=10\"" "https://livestream.com/accounts/23093026/events/6897778/\
player?enableInfoAndActivity=true&autoPlay=true&mute=false&startswith=true"

(or whatever).

@basiclaser
Copy link
Author

@basiclaser basiclaser commented Feb 24, 2017

./youtube-dl -v --hls-use-mpegts --external-downloader-args "-vf \"drawtext=fontfile=/Library/Fonts/Arial Black.ttf: \
text='%{localtime\:%c}': fontcolor=white@0.8: fontsize=24: box=1: boxcolor=black@0.5: \
boxborderw=5: x=(w-text_w)-10: y=10\"" "https://livestream.com/accounts/23093026/events/6897778/\
player?enableInfoAndActivity=true&autoPlay=true&mute=false&startswith=true"
[debug] System config: []
[debug] User config: [u'--hls-prefer-native']
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--hls-use-mpegts', u'--external-downloader-args', u'-vf "drawtext=fontfile=/Library/Fonts/Arial Black.ttf: text=\'%{localtime\\:%c}\': fontcolor=white@0.8: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)-10: y=10"', u'https://livestream.com/accounts/23093026/events/6897778/player?enableInfoAndActivity=true&autoPlay=true&mute=false&startswith=true']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.02.24
[debug] Python version 2.7.10 - Darwin-14.5.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.2.3, ffprobe 3.2.3
[debug] Proxy map: {}
[livestream] Downloading JSON metadata
[livestream] 6897778: Downloading page 1
[livestream] 6897778: Downloading page 2
[livestream] 6897778: Downloading page 3
[livestream] 6897778: Downloading page 4
[livestream] 6897778: Downloading page 5
[livestream] 6897778: Downloading page 6
[livestream] 6897778: Downloading page 7
[livestream] 6897778: Downloading page 8
[livestream] 6897778: Downloading page 9
[livestream] 6897778: Downloading page 10
[livestream] 6897778: Downloading page 11
[livestream] 6897778: Downloading page 12
[livestream] 6897778: Downloading page 13
[download] Downloading playlist: .
[livestream] playlist .: Collected 126 video ids (downloading 126 of them)
[download] Downloading video 1 of 126
[livestream] 150299546: Downloading JSON metadata
[livestream] 150299546: Downloading SMIL file
[livestream] 150299546: Downloading m3u8 information
[livestream] 150299546: Downloading f4m manifest
[debug] Invoking downloader on u'http://vod.livestream.com/events/0000000000694072/b63304b3-f8b6-4ba4-8d99-ae1eff2f9ee5_2128.m3u8?token=0_5945afa2_4ecc16834f8230c2e85e6a8bd378f0e4c246e77f'
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 1556
[download] Destination: _-150299546.mp4
[download]   9.4% of ~2.20GiB at  1.70MiB/s ETA 39:51
@johnhawkinson
Copy link
Contributor

@johnhawkinson johnhawkinson commented Feb 24, 2017

Notice that this never invokes ffmpeg. It looks like it's using the hlsnative downloader. Perhaps that is because of your --hls-prefer-native configuration in your /etc/youtube-dl.conf or ~/.config/youtube-dl/config file? Try removing that.

You ought to see a:

[debug] ffmpeg command line: ffmpeg -y -headers

group of lines that show youtube-dl is invoking ffmpeg.

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
3 participants
You can’t perform that action at this time.