Showing posts with label vlc. Show all posts
Showing posts with label vlc. Show all posts

Friday, January 19, 2018

Stream screen to Youtube with VLC

Leave a Comment

I'm looking to stream to Youtube with VLC and made the following command-string:

cvlc -vv screen:// --live-caching=0 --screen-fps=30 --screen-width=1920 --screen-height=1080 --sout='#transcode{vcodec=h264,scale=Auto,width=1920,height=1080,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=rtmp,mux=ffmpeg{mux=flv},dst=rtmp://a.rtmp.youtube.com/live2/xxxxxxxxxxx}' 

If I replace screen:// .. with a videofile, the stream successfully uploads to Youtube.

But I have no idea why it won't cast the screen. Youtube briefly shows a connection but no image. The stream isn't interrupted by VLC and it shows the upload to keep proceeding, but it's never picked up by YT. Any help would be appreciated.

For the record, I am able to view the screen offline in VLC without streaming.

I get a particular error that stands out:

core mux warning: late buffer for mux input (repeated while streaming)  

but this happens as well in the case of uploading the video and then doesn't seem to cause an issue.

Log

Below is the log when I try to set up an HTTP server streaming the desktop while also playing in VLC. I do get an image, but only a static one, the first frame of the stream.

https://pastebin.com/EzSWuAM3

It tells me a lot that my computer is slow, however it's a Corei5 and the VLC process only takes up 9% with a lot remaining. Saving to file works fine.

Note

I have two monitors. That might be a problem for it somehow, I don't know.

Update

I fixed the dropped frames issue by increasing the buffer with live-caching=2500. Now it works fine with a local HTTP server, but still not with YT.

0 Answers

Read More

Sunday, September 24, 2017

saving VLC player snapshot with filename same as video filename

Leave a Comment

How can I save a snapshot from VLC player with a filename exactly the same as the video file playing. i.e. playing video file examplevideo52.mp4 I want to be able to save a snapshot with the filename examplevideo52.jpg

1 Answers

Answers 1

With the existing settings, the closest you can get for a video file named sample.mp4 is a snapshot with name sample.mp4-0001.jpg.

You can achieve this using following settings. Settings -> Video -> Video Snapshots enter image description here

You can find more tags at - https://wiki.videolan.org/Documentation:Play_HowTo/Format_String/

Read More

Friday, September 1, 2017

VLC with VB NET: How to rotate stream/video 180°? (Tools-Effects-Geometry-Zoom-Transform)

Leave a Comment

I'm working with "AxVLCPlugin21" Through VB.Net and I can do the basic stuff like play, pause, etc. But now I want to rotate a video 180° but i cant find info about this, can you help me with a working example for vb net?

Thank you all.

1 Answers

Answers 1

From here I assume you should do something like:

var options = new Array("--video-filter rotate{angle=180}"); // Or: var options = "--video-filter rotate{angle=180}"; var id = vlc.playlist.add("file:///D:\video.mp4", "fancy name", options); 

or maybe

var options = new Array(":video-filter=rotate{angle=180}"); // Or: var options = ":video-filter=rotate{angle=180}"; var id = vlc.playlist.add("file:///D:\video.mp4", "fancy name", options); 
Read More

Saturday, April 15, 2017

Show the clip-time in VLC-player, while playing (the time the clip was recorded)

Leave a Comment

I'm recording some sports footage, and write down some notes, while the recording is going on.

I would like to be able to, as fast as possible, to link my comment to the passage on the video. I record it with a GoPro, so the 1,5 hour longs video gets chopped up to small pieces.

I thought it would be an idea, if VLC could display the actual time of when the footage was take, on screen. In the same manner of this (opening VLC from a command-line with that comment):

vlc.exe --sub-filter=marq{marquee=$T/$D" Volume:"$V,size=-2,color=16776960}:marq{marquee=Time:%H:%M:%S" Date:"%d/%m/%Y,color=16776960,size=-2,position=6} 

That line just shows the current time. I wanted it for example to show something like this:

If the recording was started at 19:39:21, - then three minutes and 7 seconds into the video, the counter should say 19:42:28. Is that achievable somehow?

I assumed that VLC was the best/easiest way to achieve it - but if someone else has another or a better idea, then I'm all ears.

1 Answers

Answers 1

Here's a LUA extension that should do what you need. It'll show the time in the top-right based on a given "start" time. The only thing you'll need to do is set what that start time is. You can adjust the start time at any point and the text should update accordingly:

  1. Put the file custom_time.lua in [VLC DIR]\VLC\lua\extensions
  2. Put the file looper_custom_time.lua in [VLC DIR]\VLC\lua\intf
  3. run VLC using the command line arguments: vlc.exe --extraintf=luaintf{intf="looper_custom_time"}
  4. You should see the time in the top-right starting at 12:00:00 and incrementing based on the video playing
  5. You can go to View -> Custom Time and set what the starting time should be, and the text should update

Let me know if it works!

custom_time.lua :

function descriptor()   return {     title = "Custom Time",     capabilities = { }   } end  function activate()   window = vlc.dialog("Enter Time")     textbox = window:add_text_input("HH:MM:SS", 1, 1, 1, 1)   label = window:add_label("Enter Start Time (24h)", 2, 1, 1, 1)   button = window:add_button("Set", setStartTime, 1, 2, 2, 1) end  function deactivate() end  function meta_changed() end  function setStartTime()   vlc.config.set("bookmark10", textbox:get_text())   vlc.msg.info("[ext_Custom_Time] " .. "Set Start Time to: ".. os.date("%H:%M:%S", globalTimeFinal)) end 

looper_custom_time.lua :

-- "looper_custom_time" >> copy the script file into VLC\lua\intf\ folder -- activate it: -- vlc.exe --extraintf=luaintf{intf="looper_custom_time"}  function Looper()    local loops=0 -- counter of loops    while true do       if vlc.volume.get() == -256 then break end  -- inspired by syncplay.lua; kills vlc.exe process in Task Manager        if vlc.playlist.status()=="stopped" then -- no input or stopped input          loops=loops+1          Log(loops)          Sleep(1)       else -- playing, paused          if vlc.playlist.status()=="playing" then             showFinalTime()             Sleep(1)          elseif vlc.playlist.status()=="paused" then             showFinalTime()             Sleep(0.3)          else -- ?             Log("unknown")             Sleep(1)          end       end    end end  function getStartTime()    local pattern = "(%d+):(%d+):(%d+)"    local startTimeString = vlc.config.get("bookmark10")    if startTimeString == nil then       startTimeString = ""    end     local hh, mm, ss = startTimeString:match(pattern)    return os.time({year = 2000, month = 1, day = 1, hour = hh, min = mm, sec = ss}) end  function Log(lm)    vlc.msg.info("[looper_intf] " .. lm .. os.date(" %H:%M:%S", getStartTime())) end  function showFinalTime()    local timePassed = getTimePassed()    local timeStart = getStartTime()    local timeFinal = os.date("%H:%M:%S", timeStart + timePassed)    vlc.osd.message( timeFinal, vlc.osd.channel_register(), "top-right", 1200000) end  function getTimePassed()    return vlc.var.get(vlc.object.input(), "time") end  function Sleep(st) -- seconds    vlc.misc.mwait(vlc.misc.mdate() + st*1000000) end  Looper() 
Read More

Sunday, March 26, 2017

Live video streaming from recording files over HTTP based on PHP

Leave a Comment

I want to organize live streaming from recording files over HTTP based on PHP.

INTRODUCTION: On the streaming server I writing video to local file(local_file.mpg) and when received a request from client then start streaming to it from
$start_byte = filesize("local_file.mpg")-10MB; The local_file.mpg is still writing and PHP script continue reading it and flushing.

PROBLEM: I streaming it via HTTP Range with the following headers:

header('HTTP/1.1 206 Partial Content'); header("Content-Type: video/mpeg"); header('Content-Length: '.($seek_end - $seek_start)); header('Content-Range: bytes '.$seek_start.'-'.$seek_end.'/'.$size); 

And flushing as follows:

while(!feof($fp)){     $buf_size = 1024*8;     $pos = ftell($fp);     if ($pos >= $item["to_byte"]){             fclose($fp);             break;     }      if ($pos + $buf_size > $item["to_byte"]){         $buf_size = $item["to_byte"] - $pos;     }      if ($buf_size > 0){         echo fread($fp, $buf_size);     }      flush();     ob_flush(); } 

I open it via VLC or FFplay, but it played until the time moment when the stream was requested. This is to be expected, because we determine the size of the file and provide it to requested side. But if we artificially increase a file size, for example
$size = filesize("local_file.mpg")+999999999999; it also not help, because video players requesting new data too early when it is not recorded. And also stopped play at the time moment when the stream was requested.

1. Please advice how to correct organize live streaming from recording files over HTTP based on PHP.
2. Is it possible to do it with HTTP RANGE mechanism or I should use another way?


UPDATE: Based on this question I tried the next code:

<?php  $file = "online.mpg";  function flush_buffers(){     ob_end_flush();     ob_flush();     flush();     ob_start(); }  header('Content-Type: video/mpeg'); $stream = fopen( $file, "rb" ); fseek($stream, (filesize($file)-10000000), SEEK_SET);  while(1){     $response = fread($stream, 8192);      echo $response;     flush_buffers(); }  fclose( $stream ); exit(); ?> 

And it works well via ffplay, but via VLC it played no more then 1 minute and stoped then.
Please advice how to make it work on VLC also?

1 Answers

Answers 1

Do you have a time limit for php execution ? if yes , change it to unlimited with :

set_time_limit(0); 
Read More

Thursday, April 7, 2016

Detect if Android SurfaceView is drawing/moving

Leave a Comment

I'm using libvlc on and android app to play a network stream; the native code draws the image on a surfaceview.

Let's assume the video stops and I have no access to the native code, how can I detect if the SurfaceView is still moving (the video is not frozen)?

I tried getViewTreeObserver().addOnDrawListener(); and getViewTreeObserver().addOnPreDrawListener(); but they do not have the effect I'm looking for.

Thanks

2 Answers

Answers 1

You can't get that information from the SurfaceView, because the SurfaceView itself does not know.

The SurfaceView's job is to set up the Surface, and create a hole in the View layout that you can see through. Once it has done these things, it is no longer actively involved in the process of displaying video. The content flows from the decoder to the Surface, which is managed by SurfaceFlinger (the system graphics compositor).

This is, for example, how DRM video works. The app "playing" the video has no access to DRM-protected video frames. (Neither does SurfaceFlinger, actually, but that's a longer story.)

The best way to know if content is still arriving is to ask the video source if it is still sending you content. Another approach would be to change your SurfaceView to a TextureView, and provide an onSurfaceTextureUpdated() callback method.

Answers 2

I am not sure what exactly what you are trying to achieve here but you can see if surface view is rendering or not through implementing an interface called SurfaceHolder.Callback which gives you access to the following methods,

  1. On Surface Created - This is called immediately after the surface is first created.

  2. On Surface Changed - This is called immediately after any structural changes (format or size) have been made to the surface.

  3. On Surface Destroyed - This is called immediately before a surface is being destroyed.

Take a look at the documentation for surface view. For SurfaceHolder take a look at this link. Basically in order to know

Read More