Topic: Streaming live TV using VLC

Hello
I've been trying to display a live flv stream on the chumby one, but I'm stucked with a codec error.
Basically I'm using VLC to access the tv video card and transcode its signal to a flv stream. In a browser that works just fine, while on the Chumby One it doesn't.
This is the trace generated by my "experimental but mostly working" widget:

2010-05-29 19:45:08 TRACE: NetStream.onStatus called: (76865 ms)
2010-05-29 19:45:08 TRACE:    level:status*
2010-05-29 19:45:08 TRACE:    code:NetStream.Play.Start*
2010-05-29 19:45:08 TRACE:
2010-05-29 19:45:08 ChumbyVidStats::Dump() completed codec ? 0/0 keyframes (0 bytes) dropped, 0/0 P-frames (0 bytes), 0/0 other frames (0 bytes) dropped
2010-05-29 19:45:08     width 0 (0 scaled), height 0 (0 scaled) rate 0 fps
2010-05-29 19:45:08     elapsed time 0.000s data transferred = 0K
2010-05-29 19:45:08 TRACE: NetStream.onStatus called: (76889 ms)
2010-05-29 19:45:08 TRACE:    level:status*
2010-05-29 19:45:08 TRACE:    code:NetStream.Play.Stop*
2010-05-29 19:45:08 TRACE:
2010-05-29 19:45:08 TRACE: ns.onMetaData *************
2010-05-29 19:45:08 TRACE:    filesize:0*
2010-05-29 19:45:08 TRACE:    audiocodecid:2*
2010-05-29 19:45:08 TRACE:    stereo:true*
2010-05-29 19:45:08 TRACE:    audiosamplesize:16*
2010-05-29 19:45:08 TRACE:    audiosamplerate:44100*
2010-05-29 19:45:08 TRACE:    audiodatarate:0*
2010-05-29 19:45:08 TRACE:    videocodecid:2*
2010-05-29 19:45:08 TRACE:    framerate:12.0000048*
2010-05-29 19:45:08 TRACE:    videodatarate:781.25*
2010-05-29 19:45:09 TRACE:    height:240*
2010-05-29 19:45:09 TRACE:    width:320*
2010-05-29 19:45:09 TRACE:    duration:0*
2010-05-29 19:45:09 TRACE: NetStream.onStatus called: (77115 ms)
2010-05-29 19:45:09 TRACE:    level:status*
2010-05-29 19:45:09 TRACE:    code:NetStream.Buffer.Full*
2010-05-29 19:45:09 TRACE:
2010-05-29 19:45:10 TRACE: NetStream.onStatus called: (78139 ms)
2010-05-29 19:45:10 TRACE:    level:status*
2010-05-29 19:45:10 TRACE:    code:NetStream.Buffer.Empty*

The stream starts, the codec stops working (as the Dump() message seems to suggest) and the stream stops too (network statistics show that data continues to flow, though).
The metadata is correct, the same as I get when I run my widget on the PC.
I also took the time to test the same data stream, but from a regular file (stream to file option) and this one worked nicely.

I suspect that at a widget level there's not much I can do, as the problem seems to originate from the player internals.
Is the chumby one capable of playing a live flv stream?
Thanks

PS: this is the transcode settings I used for VLC 1.0.5 on the command line, as the gui doesn't have an option for flv streaming:

--sout=#transcode{vcodec=FLV1,acodec=mp3,channels=2,samplerate=44100}:std{access=http,mux=ffmpeg{mux=flv},dst=0.0.0.0:8091/stream.flv}

2 (edited by cbreeze 2010-06-06 10:34:23)

Re: Streaming live TV using VLC

Hi,

I am just throwing this out there.  This works for a different video streaming widget using .flv video, but it may help you.

//video
var url_to_flv_video_stream:String = "url_to_flv_goes_here";
var nullConnection:NetConnection = new NetConnection();
nullConnection.connect(null);
var stream:NetStream = new NetStream(nullConnection);
_root.my_video.attachVideo(stream); //assumes video object on Stage called "my_video"
stream.play(url_to_flv_video_stream);

I'm sorry I can't explain it more, but if you still need some assistance, post back.

Cheers.

Come join thousands of chumby owners in Chumbyland!

Re: Streaming live TV using VLC

Thanks.
That's what my code does and plain flv files play just fine, even those produced by VLC. It's just live streams that don't work. BTW other video playing widgets show the same problem.
That's why I think this has something to do with the internals of the chumby flash player.

Re: Streaming live TV using VLC

francesco wrote:

Thanks.
That's what my code does and plain flv files play just fine, even those produced by VLC. It's just live streams that don't work. BTW other video playing widgets show the same problem.
That's why I think this has something to do with the internals of the chumby flash player.

I suppose that could be a possibility, though I believe the ORBTV widget is doing a "live" flv stream when it encodes, and that was working in Flash player lite when I built it.

I guess we wait to see what Duane has to say on this matter. smile

Cheers.

Come join thousands of chumby owners in Chumbyland!

Re: Streaming live TV using VLC

Do you happen to know which codec VLC is using? Our Flash Lite only supports Sorenson Spark and On2 VP6.  If you're simply repackaging an H.264 stream in an FLV container, then that won't work.

I think the video data rate is a bit high as well - we recommend  a maximum of 220 kbps.

Re: Streaming live TV using VLC

Duane wrote:

Do you happen to know which codec VLC is using? Our Flash Lite only supports Sorenson Spark and On2 VP6.  If you're simply repackaging an H.264 stream in an FLV container, then that won't work.

The flv1 codec should be H263 Sorenson. Flash shows videocodecid:2 which should be the correct value.

Duane wrote:

I think the video data rate is a bit high as well - we recommend  a maximum of 220 kbps.

Well I thought that too, but even a lower bit rate stream (200kb/s) has the same problem. Here is the metadata:

2010-06-07 19:38:27 TRACE:    filesize:0*
2010-06-07 19:38:27 TRACE:    audiocodecid:2*
2010-06-07 19:38:27 TRACE:    stereo:false*
2010-06-07 19:38:27 TRACE:    audiosamplesize:16*
2010-06-07 19:38:27 TRACE:    audiosamplerate:44100*
2010-06-07 19:38:27 TRACE:    audiodatarate:31.25*
2010-06-07 19:38:27 TRACE:    videocodecid:2*
2010-06-07 19:38:27 TRACE:    framerate:25*
2010-06-07 19:38:27 TRACE:    videodatarate:175.78125*
2010-06-07 19:38:27 TRACE:    height:240*
2010-06-07 19:38:27 TRACE:    width:320*
2010-06-07 19:38:27 TRACE:    duration:0*

On a side note, files encoded with a higher bit rate play fine.

Re: Streaming live TV using VLC

Hmmm, OK, then the next thing I'd try is running the Flash Player with more debugging:

# stop_control_panel
# cd /tmp
# chumbyflashplayer -i controlpanel.swf -l 383

This will output a *lot* more info about the runtime behavior - hopefully it will kick out more stuff about your video.

Re: Streaming live TV using VLC

Duane, thank you very much for your advice.

This the last log I got by following your instructions:

2010-06-08 21:01:09 TRACE: nsPlay live stream
2010-06-08 21:01:09 NetStreamRequest::Open(1): Opening protocol 'http://' host '192.168.0.50' port 8091 location '/stream.flv'
2010-06-08 21:01:09 NetStreamRequest::Open(1) opened http object id 74
2010-06-08 21:01:09 KeyboardObject::Pump() disregarding invalid code 14a for event type 1
2010-06-08 21:01:09 NetStreamRequest::ProcessHeaders(1) content-type: application/octet-stream
2010-06-08 21:01:09 KeyboardObject::Pump() disregarding invalid code 14a for event type 1
2010-06-08 21:01:09 TeleStream::DoOnStatus(NetStream.Play.Start,status,(null),(null))
2010-06-08 21:01:09 TRACE: NetStream.onStatus called: (3356 ms)
2010-06-08 21:01:09 TRACE:    level:status*
2010-06-08 21:01:09 TRACE:    code:NetStream.Play.Start*
2010-06-08 21:01:09 TRACE:
2010-06-08 21:01:09 TeleStream::DoOnStatus(NetStream.Play.Stop,status,(null),(null))
2010-06-08 21:01:09 ChumbyVidStats::Dump() completed codec ? 0/0 keyframes (0 bytes) dropped, 0/0 P-frames (0 bytes), 0/0 other frames (0 bytes) dropped
2010-06-08 21:01:09     width 0 (0 scaled), height 0 (0 scaled) rate 0 fps
2010-06-08 21:01:09     elapsed time 0.000s data transferred = 0K
2010-06-08 21:01:09 TRACE: NetStream.onStatus called: (3374 ms)
2010-06-08 21:01:09 TRACE:    level:status*
2010-06-08 21:01:09 TRACE:    code:NetStream.Play.Stop*
2010-06-08 21:01:09 TRACE:
2010-06-08 21:01:09 TRACE: ns.onMetaData *************
2010-06-08 21:01:09 TRACE:    filesize:0*
2010-06-08 21:01:09 TRACE:    audiocodecid:2*
2010-06-08 21:01:09 TRACE:    stereo:true*
2010-06-08 21:01:09 TRACE:    audiosamplesize:16*
2010-06-08 21:01:09 TRACE:    audiosamplerate:44100*
2010-06-08 21:01:09 TRACE:    audiodatarate:62.5*
2010-06-08 21:01:09 TRACE:    videocodecid:2*
2010-06-08 21:01:09 TRACE:    framerate:12*
2010-06-08 21:01:09 TRACE:    videodatarate:185.546875*
2010-06-08 21:01:09 TRACE:    height:240*
2010-06-08 21:01:09 TRACE:    width:320*
2010-06-08 21:01:09 TRACE:    duration:0*
2010-06-08 21:01:10 TeleStream::DoOnStatus(NetStream.Buffer.Full,status,(null),(null))
2010-06-08 21:01:10 TRACE: NetStream.onStatus called: (4184 ms)
2010-06-08 21:01:10 TRACE:    level:status*
2010-06-08 21:01:10 TRACE:    code:NetStream.Buffer.Full*
2010-06-08 21:01:10 TRACE:
2010-06-08 21:01:10 SI_CreateSoundDecompressor: sampleRate: 44khz, sampleSize: 16 bits, channels: 2, format: 1010001 (MP3)
2010-06-08 21:01:10 SI_OpenStreamSoundDevice(mmobj=0x002ae7b4)
2010-06-08 21:01:10 SoundObject::GlobalInit()
2010-06-08 21:01:11 SoundObject::AssureSoundDriver() buffer size request 16384 frames
2010-06-08 21:01:11 > ALSA Playback Initialized (changed=Y) (with hwsync = 1)
2010-06-08 21:01:11 > format : SND_PCM_FORMAT_S16_LE
2010-06-08 21:01:11 > sample_rate : 44100 hz
2010-06-08 21:01:11 > channels : 2
2010-06-08 21:01:11 > chunk size : 64 frames [256 bytes]
2010-06-08 21:01:11 > buffer size : 16384 frames [65536 bytes]
2010-06-08 21:01:11 > samples per pump : 8
2010-06-08 21:01:11 > bytes per pump : 32
2010-06-08 21:01:11 > bytes per buffer : 2048
2010-06-08 21:01:11 > sound buffers : 16
2010-06-08 21:01:11 SoundObject::Open() opened device "plug:dmixer"
2010-06-08 21:01:11 TeleStream::DoOnStatus(NetStream.Buffer.Empty,status,(null),(null))
2010-06-08 21:01:11 TRACE: NetStream.onStatus called: (5237 ms)
2010-06-08 21:01:11 TRACE:    level:status*
2010-06-08 21:01:11 TRACE:    code:NetStream.Buffer.Empty*
2010-06-08 21:01:11 TRACE:
2010-06-08 21:01:11 TRACE: (Advance timer heartbeat)
2010-06-08 21:01:15 TRACE: nsPlayStop----- nsplay : true
2010-06-08 21:01:15 StreamObject::CancelURLStream(1) cancelling
2010-06-08 21:01:15 NetStreamRequest::Cancel(1)
2010-06-08 21:01:15 HTTPCurlObject::Cancel(id=74) removing handle 00319af8 from multihandle
2010-06-08 21:01:15 SI_CloseStreamSoundDevice(mmobj=0x002ae7b4)
2010-06-08 21:01:15 SoundObject::Close[r](mmobj=0x002ae7b4 g_pcm_handle=0x003350c0 cut=0) keepOpen=1, calling drain
2010-06-08 21:01:15 SoundObject::Close() snd_pcm_state() returns 3
2010-06-08 21:01:15 SoundObject::Close() completed drain
2010-06-08 21:01:15 SoundObject::Close[r](0x81c0005c mmobj=0x002ae7b4) new g_openState==0
2010-06-08 21:01:15 SI_DestroySoundDecompressor

The stream gets loaded and the mime type is recognized. After that the video codec stops decoding, as if the source was 0 bytes long. Also, the sound device is opened but no sound is actually played.
Sometimes an image from the video is displayed and a fragment of sound can be heard, but really not often.

From the log I don't see many clues, though....

Re: Streaming live TV using VLC

Hmmm - OK, I'll forward this to the guy who maintains the Flash Player to see if he has any insight.

Re: Streaming live TV using VLC

I'll need to investigate this - I assume when you say "live" you're basically transcoding on the fly and sending data out via http as it's streamed.

There are two possible issues, and I will need to set up a server-side test to see exactly what's happening.

Flashplayer handles flv streams differently when there is no complete header information (as would be the case if you're transcoding on the fly).

If you do something like this:
wget -O foo http://my.url --save-headers --server-response > foo2 2>&1

and I'm assuming that http://my.url triggers a script that does the transcoding, then foo should contain headers preceding the actual data, and foo2 should contain additional information from the http session.

Can you do that and send me the text part of foo and the contents of foo2? That would help me reproduce this so I can see what's happening.

Thanks!

Re: Streaming live TV using VLC

So here we go.
file foo

HTTP/1.0 200 OK
Content-type: application/octet-stream
Cache-Control: no-cache

FLV

followed by the metadata and the rest of flv file. Http headers turn out to be very basic.
I also tried stripping the headers from foo and the result played nicely on the chumby. So the issue may well be in the handling of the http headers.

File foo2

--01:08:39--  http://192.168.0.50:8091/stream.flv
           => `foo'
Connecting to 192.168.0.50:8091... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 200 OK
  Content-type: application/octet-stream
  Cache-Control: no-cache
Length: unspecified [application/octet-stream]

    0K .......... .......... .......... .......... ..........   48.53 KB/s
   50K .......... .......... .......... .......... ..........   46.66 KB/s
  100K .......... .......... .......... .......... ..........   83.97 KB/s
  150K .......... .......... .......... .......... ..........   52.41 KB/s
  200K .......... .......... .......... .......... ..........   56.89 KB/s
  250K .......... .......... .......... .......... ..........   41.60 KB/s
  300K .......... .......... .......... ........


Regarding the setup, the web server that streams the data is actually integrated into VLC and I don't think I can easily trim default headers.

Re: Streaming live TV using VLC

Hi Francesco,

Thanks for performing that other test - downloading the file from VLC and playing it (or stripping out the headers after downloading with --save-headers) does indeed confirm that the problem lies in the way the headers are being processed. I should be able to reproduce this by scripting and may not need to set up a live A/V source with VLC.

Had I re-read your original post on this thread I would have seen that you set up the listener socket for VLC and were using that exact socket address:port in your example. But in any case this gives me something I can go on.

Thanks for getting me all the relevant details, I should be able to respond on this within the next few days..