zmwangx/rust-ffmpeg

Support for URLs

AdrianEddy opened this issue · 2 comments

Currently, all input and output wrappers take AsRef<Path> parameter. This restricts the usage to local files only, but ffmpeg actually supports a lot of other protocols, including remote urls like http or rtsp

It should be possible to pass a custom url to ffmpeg.

I started to work on a PR to add support for URLs, but not sure which option would be the best:

  • Replace AsRef<Path> to ToString - this breaks current usage if someone passes Path
  • Add new methods like open_url(url: &str... - there are a few open/input/output function variants and will lead to duplication of many functions
  • Since the Path is converted to string anyway right away, is there a way to make the function signature accept both Path and &str? I wasn't able to find a way to do that, Path doesn't implement ToString nor std::fmt::Display

Safest way would be to add open_url functions, but I would prefer not to duplicate all these functions

Thoughts?

What about a new trait entirely, like MediaSource? Then you could impl<P: AsRef<Path>> MediaSource for P to preserve the existing callsites, but also add new impls for other sources.