havlenapetr / FFMpeg

this is port of ffmpeg for android (this is app, but in future i will do android lib from it and then system will be able to convert videos automatically)
883 stars 420 forks source link

How to play streaming video (and audio)? #31

Open misol101 opened 13 years ago

misol101 commented 13 years ago

Hello,

your setDataSource doc states "Sets the data source (file-path or http/rtsp URL) to use", but it seems that it simply tries to open the supplied datasource as a file (with av_open_input_file), so it cannot play streams or remote files.

Are you working on enabling this as well in your library? If not, do you have any pointers on how it could be done?

Thanks for any help!

tsingien commented 13 years ago

config ffmpeg: jni/libffmpeg/config.h

-CONFIG_HTTP_PROTOCOL 0 -CONFIG_TCP_PROTOCOL 0

+CONFIG_HTTP_PROTOCOL 1 +CONFIG_TCP_PROTOCOL 1

jni/libffmpeg/config-arm.mak: -!CONFIG_TCP_PROTOCOL=yes -!CONFIG_HTTP_PROTOCOL=yes

+CONFIG_TCP_PROTOCOL=yes +CONFIG_HTTP_PROTOCOL=yes

misol101 commented 13 years ago

Thanks, but after a clean build with your changes I get:

/home/misol/Android/android-ndk-r5c/samples/havlenapetr-FFMpeg-7c27aa2/obj/local/armeabi/libavformat.a(allformats.o): In function av_register_all': /home/misol/Android/android-ndk-r5c/samples/havlenapetr-FFMpeg-7c27aa2/jni/libffmpeg/libavformat/allformats.c:237: undefined reference tohttp_protocol' /home/misol/Android/android-ndk-r5c/samples/havlenapetr-FFMpeg-7c27aa2/jni/libffmpeg/libavformat/allformats.c:237: undefined reference to `tcp_protocol' collect2: ld returned 1 exit status make: *\ [/home/misol/Android/android-ndk-r5c/samples/havlenapetr-FFMpeg-7c27aa2/obj/local/armeabi/libffmpeg_jni.so] Error 1

Can you help out again?

misol101 commented 13 years ago

Finally managed to compile with tcp/hhtp on, using the following (with a few ugly hacks, I'm no make build expert):

diff -r jni/libffmpeg/config-arm.mak ../../samples/havlenapetr-FFMpeg-7c27aa2/jni/libffmpeg/config-arm.mak
272c272
+CONFIG_NETWORK=yes
---
-!CONFIG_NETWORK=yes
948c948
+CONFIG_HTTP_PROTOCOL=yes
---
-!CONFIG_HTTP_PROTOCOL=yes
957c957
+CONFIG_TCP_PROTOCOL=yes
---
-!CONFIG_TCP_PROTOCOL=yes
diff -r jni/libffmpeg/config.h ../../samples/havlenapetr-FFMpeg-7c27aa2/jni/libffmpeg/config.h
199c199
+#define CONFIG_NETWORK 1
---
-#define CONFIG_NETWORK 0
875c875
+#define CONFIG_HTTP_PROTOCOL 1
---
-#define CONFIG_HTTP_PROTOCOL 0
884c884
+#define CONFIG_TCP_PROTOCOL 1
---
-#define CONFIG_TCP_PROTOCOL 0
diff -r jni/libffmpeg/config.mak ../../samples/havlenapetr-FFMpeg-7c27aa2/jni/libffmpeg/config.mak
272c272
+CONFIG_NETWORK=yes
---
-!CONFIG_NETWORK=yes
948c948
+CONFIG_HTTP_PROTOCOL=yes
---
-!CONFIG_HTTP_PROTOCOL=yes
957c957
+CONFIG_TCP_PROTOCOL=yes
---
-!CONFIG_TCP_PROTOCOL=yes
diff -r jni/libffmpeg/libavformat/network.h ../../samples/havlenapetr-FFMpeg-7c27aa2/jni/libffmpeg/libavformat/network.h
67c67
+#if 0
---
-
93d92
+ #endif
diff -r jni/libffmpeg/libavformat/os_support.h ../../samples/havlenapetr-FFMpeg-7c27aa2/jni/libffmpeg/libavformat/os_support.h
50c50
+//typedef int socklen_t;
---
-typedef int socklen_t;

Unfortunately (and like I suspected) there is no difference when setDataSource is called (av_open_input_file fails, which seems to make sense since it seems to work with files only?). tsingien, how do I actually make any use of my now "http/tcp-enabled" library?

tsingien commented 13 years ago

maybe you should call ./configure --your parameters such as --enable-network --enable-http etc. on linux.

this command will create config.h and config.mak. then copy config options to your havlenapetr project.

misol101 commented 13 years ago

But are you saying that remote streams and urls will in fact play "automagically" as long as my ffmpeg config is right? That av_open_input_file (as called in mediaplayer.cpp) will open and play these with no other modifications needed? Is that working for you?

tsingien commented 13 years ago

yes.

Will u please give me your email address? I'll send my config.h and config.mak to u.

misol101 commented 13 years ago

Great, thanks! Send to **@yahoo.com

easycui commented 13 years ago

I also have such problem. Do you mind send me config.h and config.mak? My email is easy.cuiyuxin@gmail.com Thanks.

Mag83 commented 13 years ago

I'm getting the following errors updating the config files. Could you please also send me the config files? (_@_*.com) /network.h:69: : redefinition of 'struct __kernel_sockaddr_storage' /network.h:83: error: redefinition of 'struct addrinfo'

I just want to play an rtsp h264 HiP stream on 2.2 Android tablets. Default Android MediaPlayer has at least 10s buffering delay and I need to reduce it. Using ffmpeg with jni seems to be, at that time, the only way to reduce it.

kietcao commented 13 years ago

I'm getting the following errors updating the config files. Compile thumb : ffmpeg_jni <= cmdutils.c In file included from libffmpeg/cmdutils.c:44: libffmpeg/libavformat/network.h:69: error: redefinition of 'struct __kernel_sockaddr_storage' libffmpeg/libavformat/network.h:83: error: redefinition of 'struct addrinfo' make: *\ [libffmpeg/cmdutils.o] Error 1

I just want to play an rtsp h264 HiP stream on 2.2 Android tablets. Default Android MediaPlayer has at least 10s buffering delay and I need to reduce it. Using ffmpeg with jni seems to be, at that time, the only way to reduce it. Email: caoanhkiet2003@gmail.com. Thanks for your reply.

kietcao commented 13 years ago

I build with configuration is successfull.

/libffmpeg/config.h

define CONFIG_NETWORK 1

define CONFIG_HTTP_PROTOCOL 1

define CONFIG_TCP_PROTOCOL 1

define CONFIG_RTMP_PROTOCOL 1

define CONFIG_RTP_PROTOCOL 1

define CONFIG_UDP_PROTOCOL 1

define HAVE_STRUCT_SOCKADDR_STORAGE 1

define HAVE_STRUCT_ADDRINFO 1

define HAVE_SOCKLEN_T 1


libffmpeg/config.mak CONFIG_NETWORK=yes CONFIG_HTTP_PROTOCOL=yes CONFIG_TCP_PROTOCOL=yes CONFIG_RTMP_PROTOCOL=yes CONFIG_RTP_PROTOCOL=yes CONFIG_UDP_PROTOCOL=yes HAVE_STRUCT_SOCKADDR_STORAGE=yes HAVE_SOCKLEN_T=yes HAVE_STRUCT_ADDRINFO=yes

But It does not play rtsp. Please let me know, why is it?

tsingien commented 13 years ago

I never test rtsp stream. http is ok.

kietcao commented 13 years ago

Do You use http with m3u8? Please send me link to testing?

xccloveny commented 11 years ago

@kietcao can you send me the config.sh config.h and config.mak? xccloveny@gmail.com Thank you very much!

xccloveny commented 11 years ago

@misol101 can you send me the config.sh config.h and config.mak? xccloveny@gmail.com Thank you very much! I have the same problem,maybe you had done this now :),please give me some advice.