bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.43k stars 8.11k forks source link

p2p not support #2740

Open discoy opened 7 years ago

discoy commented 7 years ago

I found that 'p2p://' not be supported in ijkplayer.

is there any way that can make p2p:// be supported in ijkplayer?

MythodeaLoL commented 7 years ago

@discoy ijk use ffmpeg project, ffmpeg dont support p2p native, or p2p:// protocol. Is the same as asking for a torrent support. Mayme u need libtorrent. But u need to pass torrent data to ijk, i dont know how to do this, maybe a using a pipe/FileDescriptor .

for sample:

final ParcelFileDescriptor write = pipes[1];
AssetFileDescriptor afd = new AssetFileDescriptor(write, 0, -1);
OutputStream outputStream = afd.createOutputStream();
/*Create a thread write byte data to outputstream*/
// outputStream.write(buffer);
FileDescriptor fileDescriptor = pipes[0].getFileDescriptor();
mMediaPlayer.setDataSource(fileDescriptor);

But how to pass libtorrent to outputStream? How to pass fileDescriptor to ijkplayer? How to find an example of libtorrent to do this?

https://github.com/Bilibili/ijkplayer/issues/1566 torrent dlna (no response) https://github.com/Bilibili/ijkplayer/issues/1307 p2p (have response)

discoy commented 7 years ago

@FloridaStream do you have test your method which make it be supported for torrent or p2p? I think whether we can start a local service to download(may be use libtorrent or other libs ) the source which is p2p:// protocol or torrent,on the other side we can start server http://127.0.0.1:LocalPort/url .the ijk get data from this url like https://github.com/danikula/AndroidVideoCache

MythodeaLoL commented 7 years ago

I have not yet started my streaming project with the torrent client on android, but I am already archiving some projects that can inspire me to realize this, you can access them here AndroidTorrent.

I know some of the ideas on how to do this that came to mind are using FileDecriptor with PIPE for ijk (I do not know if ijk supports FileDecriptor, I think not yet), and another is how you commented yourself, using libtorrent Or similar libraries to break the torrent and stream through an http server.

Remember, the torrent must be in a format that is recognizable, ie the files in the torrent need to be like .mov / .mp4 / .avi for example, they can not be compressed, if they are compressed, you will have a too gritty headache, and can get into coma hahaha

This is not an easy thing to do. If you have any information that you can share with me in the future, thank you. We are all in this challenge together. Good luck @discoy.

discoy commented 7 years ago

@FloridaStream Thank you for your sharing.As you say it's not an easy thing to do but i think it's worth a try. Looking forward to share with you more,thank you again!