Android Save Live Video Stream to Storage

About encoding, codec settings, muxers and filter usage
Christoffel
New Cone
New Cone
Posts: 3
Joined: 31 May 2019 10:50

Android Save Live Video Stream to Storage

Postby Christoffel » 31 May 2019 12:03

Hi

I'm trying to save a live video stream to storage in Android App using libvlc.
I can do it on PC with command line and it work fine, I record the file and can view it afterwards.

But in the app the file records, it's only 151B big which is probably empty and if I try to open it I get message "Cannot play this video format"

My question is, is it possible to record to storage in Android with libvlc?

Here is the code I've tried. Any suggestions would help

Code: Select all

This work for PC command line: c:\program files (x86)\videolan\vlc vlc rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov --sout=#transcode{vcodec=h264}:std{access=file,dst='c:\aaa\temp.mp4'} This DON'T work for Android libvlc var currentDirectory = "/storage/emulated/0/dcim/"; var destination = Path.Combine(currentDirectory, "record2.mp4"); media.AddOption(":sout=#file{dst=" + destination + "}"); Attempt 1: media.AddOption(":sout=#transcode{vcodec=h264}:std{access=file,dst=" + destination + "}"); Attempt 2: media.AddOption(":sout=#transcode{vcodec=mp1v, vb=1024, acodec=mpga, ab=128}:std{access=file, mux=mpeg1, dst=" + destination + "}"); Attempt 3: media.AddOption(":sout=#transcode{vcodec=mp1v}:std{access=file, mux=ps, dst=" + destination + "}"); Attempt 4: media.AddOption(":sout:record:dst:prefix=" + destination + "}"); Attempt 5: media.AddOption(":sout=#stream_out_duplicate{dst=std{access=file,mux=ps,dst=" + destination + "}}"); Attempt 6: media.AddOption(":sout=#transcode{vcodec=mp1v}:std{access=file,mux=ps,dst=" + destination + "}"); Attempt 7: media.AddOption("sout=#std{access=file,dst=" + destination + "}");

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: Android Save Live Video Stream to Storage

Postby unidan » 01 Jun 2019 18:23

Hi, can you post the verbose logs of libvlc, that you can get by setting up logging and using adb logcat ?

Christoffel
New Cone
New Cone
Posts: 3
Joined: 31 May 2019 10:50

Re: Android Save Live Video Stream to Storage

Postby Christoffel » 03 Jun 2019 10:16

I'm new to programming in Xamarin. So Will this help


06-03 08:54:46.823 E/VLC (25958): [b875e280/6592] libvlc video output: video output creation failed
06-03 08:54:46.824 E/VLC (25958): [b863d9c0/6592] libvlc decoder: failed to create video output
06-03 08:54:46.849 E/VLC (25958): [b87b2ce8/6592] libvlc window: libvlc_media_player options not set
06-03 08:54:46.850 E/VLC (25958): [b8771688/659b] libvlc vout display: parent window not available
06-03 08:54:46.851 E/VLC (25958): [b875e280/6592] libvlc video output: video output creation failed
[h264 @ 0xb86578a0] get_buffer() failed
[h264 @ 0xb86578a0] thread_get_buffer() failed
[h264 @ 0xb86578a0] decode_slice_header error
[h264 @ 0xb86578a0] no frame!
06-03 08:54:46.855 E/VLC (25958): [b863d9c0/6592] libvlc decoder: failed to create video output
06-03 08:54:46.858 D/Mono (25958): Loading reference 3 of /storage/emulated/0/Android/data/com.companyname.FormsVLCRecorder/files/.__override__/LibVLCSharp.Forms.dll asmctx DEFAULT, looking for Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
06-03 08:54:46.858 D/Mono (25958): Assembly Ref addref LibVLCSharp.Forms[0xb8059818] -> Mono.Android[0xb80750f8]: 28
06-03 08:54:46.867 E/VLC (25958): [b8812528/6592] libvlc window: libvlc_media_player options not set
06-03 08:54:46.867 E/VLC (25958): [b8812b48/659c] libvlc vout display: parent window not available
[h264 @ 0xb86578a0] 06-03 08:54:46.869 E/VLC (25958): [b875e280/6592] libvlc video output: video output creation failed

get_buffer() failed
[h264 @ 0xb86578a0] thread_get_buffer() failed
[h264 @ 0xb86578a0] decode_slice_header error
[h264 @ 0xb86578a0] no frame!
06-03 08:54:46.872 E/VLC (25958): [b863d9c0/6592] libvlc decoder: failed to create video output
06-03 08:54:46.873 W/art (25958): JNI RegisterNativeMethods: attempt to register 0 native methods for md546698daa40cfc4c645e97972c2567f23.VideoViewRenderer
06-03 08:54:46.884 E/VLC (25958): [b8772368/6592] libvlc window: libvlc_media_player options not set
06-03 08:54:46.884 E/VLC (25958): [b8819850/659d] libvlc vout display: parent window not available
06-03 08:54:46.885 E/VLC (25958): [b87aafb0/6592] libvlc video output: video output creation failed
[h264 @ 0xb86578a0] get_buffer() failed
[h264 @ 0xb86578a0] thread_get_buffer() failed
[h264 @ 0xb86578a0] decode_slice_header error
[h264 @ 0xb86578a0] no frame!
06-03 08:54:46.886 E/VLC (25958): [b863d9c0/6592] libvlc decoder: failed to create video output
06-03 08:54:46.893 D/Mono (25958): Loading reference 2 of /storage/emulated/0/Android/data/com.companyname.FormsVLCRecorder/files/.__override__/LibVLCSharp.Android.AWindow.dll asmctx DEFAULT, looking for Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
06-03 08:54:46.893 D/Mono (25958): Assembly Ref addref LibVLCSharp.Android.AWindow[0xb8057a30] -> Java.Interop[0xb80957d8]: 11
06-03 08:54:46.931 D/Mono (25958): DllImport searching in: 'libvlc' ('libvlc.so').
06-03 08:54:46.931 D/Mono (25958): Searching for 'libvlc_media_player_set_android_context'.
06-03 08:54:46.931 D/Mono (25958): Probing 'libvlc_media_player_set_android_context'.
06-03 08:54:46.931 D/Mono (25958): Found as 'libvlc_media_player_set_android_context'.
06-03 08:54:46.952 E/VLC (25958): [b87ad958/659e] libvlc window: request 1 not implemented
06-03 08:54:46.953 E/VLC (25958): [b87ad958/659e] libvlc window: request 1 not implemented
06-03 08:54:46.953 E/VLC (25958): [b87aafb0/6592] libvlc video output: video output creation failed[h264 @ 0xb86578a0] get_buffer() failed
[h264 @ 0xb86578a0] thread_get_buffer() failed
[h264 @ 0xb86578a0] decode_slice_header error
[h264 @ 0xb86578a0] no frame!

irzan2010
New Cone
New Cone
Posts: 1
Joined: 22 Oct 2019 09:21

Re: Android Save Live Video Stream to Storage

Postby irzan2010 » 22 Oct 2019 09:40

I try this, and it saved the video. But unfortunately it not showed the video on screen.
PS: I removed some code for confidentiality.

Code: Select all

ArrayList<String> options = new ArrayList<>(); options.add("-vvv"); // add another options as you need here LibVLC libVLC = new LibVLC(this.getActivity(), options); MediaPlayer mediaPlayer = new MediaPlayer(libVLC); File appDirectory = getContext().getExternalFilesDir(""); File videosDir = new File(appDirectory + "/videos"); if (!videosDirexists()) { videosDir.mkdir(); } String rtspUrl = ""; // --> put your stream URL here Media media = new Media(libVLC, Uri.parse(rtspUrl)); media.setHWDecoderEnabled(true, false); // add another options as you need here media.addOption(":sout=#file{dst=\"" + videosDir + "/my_stream.mp4\"}"); mediaPlayer.setMedia(media); mediaPlayer.play();


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 21 guests