caprica / vlcj

Java framework for the vlc media player
http://www.capricasoftware.co.uk/projects/vlcj
1.13k stars 260 forks source link

Streaming http VLCJ #561

Closed Palak92 closed 7 years ago

Palak92 commented 7 years ago

I am trying to stream a video via vlcj to local host by using this code:

public class StreamHttp extends VlcjTest {
static MediaPlayerFactory mediaPlayerFactory;
    public static void main(String[] args) throws Exception {
        new NativeDiscovery().discover();     

        String options = formatHttpStream("127.0.0.1", 5555);       

        mediaPlayerFactory = new MediaPlayerFactory(args);
        HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
        mediaPlayer.playMedia("screen://", options);

        Thread.currentThread().join();
    }

    private static String formatHttpStream(String serverAddress, int serverPort) {
        StringBuilder sb = new StringBuilder(60);
        sb.append(":sout=#transcode{vcodec=mp4v,vb=800,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=http,mux=ts,");
        sb.append("dst=");
        sb.append(serverAddress);
        sb.append(':');
        sb.append(serverPort);
        sb.append("}}");
        return sb.toString();
    }
}

But when I type IP address and port number in my browser nothing comes up.

caprica commented 7 years ago

First, please take the time to format your code in markdown correctly if you expect any help.

Second, what do you expect me to do with this limited information and without logs. Enable logs, look at the logs, if you're still stuck, post the logs.

Palak92 commented 7 years ago
  1. The code is : link for code

  2. The logs:

 ### _--- exec-maven-plugin:1.2.1:exec (default-cli) @ ScreenCapture ---
247 [main] INFO uk.co.caprica.vlcj.Info - vlcj: 3.10.1
248 [main] INFO uk.co.caprica.vlcj.Info - java: 1.8.0_121 Oracle Corporation
248 [main] INFO uk.co.caprica.vlcj.Info - java home: C:\Program Files\Java\jdk1.8.0_121\jre
248 [main] INFO uk.co.caprica.vlcj.Info - os: Windows 7 6.1 amd64
316 [main] INFO uk.co.caprica.vlcj.binding.LibVlcFactory - vlc: 2.1.3 Rincewind, changeset 2.1.3-0-ge6a71cc
316 [main] INFO uk.co.caprica.vlcj.binding.LibVlcFactory - libvlc: libvlc.dll
TagLib: MP4: No audio tracks
TagLib: MP4: No audio tracks
TagLib: MP4: No audio tracks
TagLib: MP4: No audio tracks_

The Program runs but I am not able to see streamed video at this IP

caprica commented 7 years ago

I see markdown formatting escapes you.

Probably something wrong with your transcoding "sout" string.

Palak92 commented 7 years ago

I checked the string containing "sout" with vlc media player ( in streaming option ) and copied it down in my program. I rechecked the string by executing it on cmd window. It works there too. The logs dont show any issue with the string.

caprica commented 7 years ago

Enable verbose native logging in vlcj using "-vvv" in MediaPlayerFactory arguments. Play your media.

Enable verbose logging in VLC using "-vvv" on the command-line. Play your media.

Compare differences in the logs.

caprica commented 7 years ago

Put it this way, there can only be a few things that are wrong.

Either it's your MRL, "screen://" - now this on its own looks OK, but you may need to set other options.

Or it's your sout string.

Or it's some other option you need to set on the MediaPlayerFactory.

Or it's some other option you need to set on your mediaPlayer.playMedia() call.

Look at the ScreenTestPlayer.java for some properties I set when using screen:// that you don't.

It's simply impossible for me to say given what you posted that it must be x, y or z.

Palak92 commented 7 years ago

StreamingVideosVLC.zip

I tried to compare the logs. They seem to be different and massive. I think there is some issue in mux. I have attached the files. here snippet to logs-- VLC:

main warning: late buffer for mux input (359666)
main debug: removing module "avcodec"
avcodec debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) stopped
main debug: removing module "x264"
x264 debug: framecount still in libx264 buffer: 0
x264 info: frame I:3 Avg QP:15.10 size: 5836 
x264 info: frame P:560 Avg QP:10.62 size: 426 
x264 info: mb I I16..4: 17.8% 0.0% 82.2% 
x264 info: mb P I16..4: 0.1% 0.0% 0.3% P16..4: 23.6% 0.6% 0.8% 0.0% 0.0% skip:74.6% 
x264 info: final ratefactor: 7.69 
x264 info: coded y,uvDC,uvAC intra: 66.5% 83.6% 74.4% inter: 10.0% 9.6% 8.5% 
x264 info: i16 v,h,dc,p: 2% 98% 0% 0% 
x264 info: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 55% 7% 2% 3% 2% 3% 2% 3% 
x264 info: i8c dc,h,v,p: 24% 63% 10% 2% 
x264 info: ref P L0: 97.0% 1.6% 1.3% 
x264 info: kb/s:43.65 
main debug: Filter 000000000259f170 removed from chain
main debug: removing module "swscale"
avcodec debug: removing input
main warning: no more input streams for this mux
main debug: removing module "avcodec"
avcodec debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) stopped
main debug: killing decoder fourcc `h264', 0 PES in FIFO
main debug: saving a free vout
main debug: reusing provided vout
main debug: removing module "mp4"
mp4 debug: freeing all memory
main debug: removing module "record"
main debug: removing module "filesystem"
main debug: Program doesn't contain anymore ES
main debug: dead input
main debug: destroying useless sout
main debug: destroying chain... (name=transcode)
main debug: removing module "stream_out_transcode"
main debug: destroying chain done
main debug: destroying chain... (name=duplicate)
main debug: removing module "stream_out_duplicate"
stream_out_duplicate debug: closing a duplication
main debug: destroying chain... (name=http)
main debug: removing module "stream_out_standard"
main debug: removing module "avcodec"
access_output_http warning: HTTP sout access cannot seek
access_output_http warning: HTTP sout access cannot seek
access_output_http warning: HTTP sout access cannot seek
main debug: removing module "access_output_http"
main warning: force closing connections
main debug: HTTP host removed
access_output_http debug: Close
main debug: destroying chain done
main debug: destroying chain... (name=display)
main debug: removing module "stream_out_display"
main debug: destroying useless vout
main debug: removing module "direct3d"
direct3d debug: Direct3D scene released successfully
direct3d debug: DirectXEventThread terminating
direct3d debug: DirectXCloseWindow
direct3d debug: WinProc WM_DESTROY
qt4 debug: releasing video...
qt4 debug: Video is not needed anymore
main debug: removing module "freetype"
main debug: removing module "yuvp"
main debug: removing module "swscale"
main debug: destroying chain done
main debug: destroying chain done
main debug: changing item without a request (current 0/1)
main debug: nothing to play
qt4 debug: IM: Deleting the input

from VLCJ:

[000000005b7ea420] avcodec decoder debug: allowing 4 thread(s) for decoding
[000000005b7ea420] avcodec decoder debug: avcodec codec (H264 - MPEG-4 AVC (part 10)) started
[000000005b7ea420] avcodec decoder debug: using frame thread mode with 4 threads
[000000005b7ea420] main decoder debug: using decoder module "avcodec"
[0000000000560a40] main demux meta debug: looking for meta reader module matching "any": 4 candidates
TagLib: MP4: No audio tracks
TagLib: MP4: No audio tracks
[0000000000560a40] lua demux meta debug: Trying Lua scripts in C:\Users\T4ATC\AppData\Roaming\vlc\lua\meta\reader
[0000000000560a40] lua demux meta debug: Trying Lua scripts in C:\Program Files\VideoLAN\VLC\lua\meta\reader
[0000000000560a40] lua demux meta debug: Trying Lua playlist script C:\Program Files\VideoLAN\VLC\lua\meta\reader\filename.luac
[0000000000560a40] lua demux meta debug: Trying Lua scripts in C:\Users\T4ATC\AppData\Roaming\vlc\lua\meta\reader
[0000000000560a40] lua demux meta debug: Trying Lua scripts in C:\Program Files\VideoLAN\VLC\lua\meta\reader
[0000000000560a40] lua demux meta debug: Trying Lua playlist script C:\Program Files\VideoLAN\VLC\lua\meta\reader\filename.luac
[0000000000560a40] main demux meta debug: no meta reader modules matched
[0000000000559e30] main input debug: `file:///C:/dev/4609/code/ScreenCapture/out2.mp4' successfully opened
[000000005b79cec0] mp4 demux debug: elst (0) gives 0ms (movie)-> 333ms (track)
[000000005b79cec0] mp4 demux debug: track[Id 0x1] using Sync Sample Box (stss)
[000000005b79cec0] mp4 demux debug: stts gives 2 --> 0 (sample number)
[0000000000559e30] main input debug: Buffering 0%
[000000005ccedba0] main spu text debug: looking for text renderer module matching "any": 4 candidates
[0000000000559e30] [000000005ccedba0] main input debug: freetype spu text debug: Buffering 0%
Using Arial as font from file C:\Windows\Fonts\arial.ttf
[000000005ccedba0] freetype spu text debug: using fontsize: 2
[000000005ccedba0] main spu text debug: using text renderer module "freetype"
[000000005cd0f5a0] main scale debug: looking for video filter2 module matching "any": 110 candidates
[000000005cd0f5a0] swscale scale debug: 32x32 chroma: YUVA -> 16x16 chroma: RGBA with scaling using Bicubic (good quality)
[000000005cd0f5a0] main scale debug: using video filter2 module "swscale"
[000000005cd1aeb0] main scale debug: looking for video filter2 module matching "any": 110 candidates
[0000000000559e30] main input debug: [000000005cd1aeb0] Buffering 33%
yuvp scale debug: YUVP to YUVA converter
[000000005cd1aeb0] main scale debug: using video filter2 module "yuvp"
[000000005ccec900] main video output debug: Deinterlacing available
[000000005ccec900] main video output debug: [0000000000559e30] deinterlace 0, mode blend, is_needed 0
main input debug: Buffering 66%
[000000005ccec900] main video output debug: Opening vout display wrapper
[000000005b765fa0] main vout display debug: looking for vout display module matching "any": 20 candidates
[0000000000559e30] main input debug: Buffering 100%
[0000000000559e30] main input debug: Stream buffering done (400 ms in 13 ms)
[000000005b765fa0] direct3d vout display debug: creating Vout EventThread
[000000005b765fa0] direct3d vout display debug: DirectXCreateWindow
[0000000000560880] main window debug: looking for vout window hwnd module matching "any": 6 candidates
[0000000000560880] main window debug: no vout window hwnd modules matched
[000000005b765fa0] direct3d vout display debug: created video sub-window
[000000005b765fa0] direct3d vout display debug: Vout EventThread running
[000000005b765fa0] direct3d vout display debug: disabling screen saver
[000000005b765fa0] direct3d vout display debug: Direct3d Device: Intel(R) HD Graphics Family 32902 278 9
[000000005b765fa0] direct3d vout display warning: trying surface pixel format: YUY2
[000000005b765fa0] direct3d vout display debug: selected surface pixel format is YUY2
[000000005b765fa0] direct3d vout display debug: Using D3DTEXF_LINEAR for minification
[000000005b765fa0] direct3d vout display debug: Using D3DTEXF_LINEAR for magnification
[000000005b765fa0] direct3d vout display debug: Direct3D scene created successfully
[000000005b765fa0] direct3d vout display debug: Direct3D device adapter successfully initialized
[000000005b765fa0] main vout display debug: using vout display module "direct3d"
[000000005b765fa0] main vout display debug: A filter to adapt decoder to display is needed
[000000005ce50410] main filter debug: looking for video filter2 module matching "any": 110 candidates
[000000005ce50410] swscale filter debug: 264x331 chroma: I444 -> 264x331 chroma: YUY2 with scaling using Bicubic (good quality)
[000000005ce50410] main filter debug: using video filter2 module "swscale"
[000000005b765fa0] main vout display debug: Filter 'Swscale' (000000005ce50410) appended to chain
[000000005ccec900] main video output debug: original format sz 264x331, of (0,0), vsz 264x331, 4cc I444, sar 1:1, msk r0x0 g0x0 b0x0
[000000005ccedba0] main spu text debug: removing module "freetype"
[000000005cd2c140] main spu text debug: looking for text renderer module matching "any": 4 candidates
[000000005cd2c140] freetype spu text debug: Using Arial as font from file C:\Windows\Fonts\arial.ttf
[000000005cd2c140] freetype spu text debug: using fontsize: 2
[000000005cd2c140] main spu text debug: using text renderer module "freetype"
[000000005b7ea420] avcodec decoder debug: using direct rendering
[0000000000559e30] main input debug: Decoder buffering done in 61 ms
[000000005b7ea420] main decoder debug: End of video preroll
[000000005ccec900] main video output debug: picture might be displayed late (missing 0 ms)
[000000005b765fa0] main vout display debug: auto hiding mouse cursor

my mrl is same in both the cases.

Palak92 commented 7 years ago

I have tried putting MRL as file:///C:/out2.mp4 and string a: "sout \"#transcode{vcodec=h264,vb=56,venc=x264{profile=baseline},fps=12,width=176,height=144,acodec=mp3,ab=24,channels=1,samplerate=44100}:duplicate{dst=http{mux=ffmpeg{mux=flv},dst=:8080/},dst=display :sout-keep\""