RTSP -> FLV live stream transcoding
Posted: 26 Mar 2008 23:22
Hi all,
First off, thanks for the great forum. I've had a lot to read over the past few days trying to get RTSP -> FLV live stream transcoding going. I'm still having issue though, so I'm going to post them up.
Problem Scope
I need to transcode a live RTSP stream, encoded with MP4 video and audio into a FLV stream with of any functional video type. I have had very good luck transcoding a static .FLV file with H263 or H264 content into streaming FLV. I have been testing using the vlc 0.9.0 3/22 daily build on both Windows and Linux. I am using Adobe Flex to open the connection to grab video. That code is quite standard - you would do the exact same thing in Flash to play video.
These work:
vlc C:\Media\Videos\Robot_sentinella.flv --sout "#transcode{vcodec=FLV1,acodec=mp3}:std{access=http{mime=video/x-flv},dst=0.0.0.0:8080/stream.flv}" --loop --color -I dummy
vlc --sout "#transcode{vcodec=FLV1}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\Robot_sentinella.flv --loop --color -I dummy
vlc --sout "#transcode{vcodec=FLV1,acodec=mp3,samplerate=11025}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\AVCHD-stright-to-flash.MP4.flv --color -I dummy
vlc --sout "#transcode{vcodec=FLV1,acodec=mp3,samplerate=11025}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\AVCHD-stright-to-flash.MP4.flv --sout-transcode-hurry-up --sout-transcode-high-priority --file-caching=1000 --high-priority --repeat --color -I dummy
As soon as I try to transcode from rtsp or encode to h264 or mp4v, I have issues.
vlc --sout "#transcode{vcodec=h264,vb=96,acodec=mp4a,samplerate=11025,scale=1}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\Robot_sentinella.flv --loop --color -I dummy -vvv
Crashes the 3/22 Windows daily build with
[00000503] x264 encoder debug: version x264 0.58.X
[00000503] x264 encoder debug: initializing pthread-win32
x264 [info]: using threads=3
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 Cache64
x264 [warning]: VBV is incompatible with constant QP, ignored.
[00000503] main encoder debug: using encoder module "x264"
[00000503] x264 encoder debug: pthread-win32 deinitialized
[00000503] main encoder debug: removing module "x264"
[00000502] ffmpeg decoder warning: warning: first frame is no keyframe
(flv@00C897C0)
[00000392] stream_out_transcode private debug: decoder aspect is 576000:432000
[00000392] stream_out_transcode private debug: source pixel aspect is 1.000000:1
[00000392] stream_out_transcode private debug: scaled pixel aspect is 1.000000:1
[00000392] stream_out_transcode private debug: source 320x240, crop 320x240, des
tination 320x240, padding 320x240
[00000392] stream_out_transcode private debug: encoder aspect is 576000:432000
[00000503] main encoder debug: looking for encoder module: 12 candidates
[00000503] x264 encoder debug: version x264 0.58.X
[00000503] x264 encoder debug: initializing pthread-win32
x264 [info]: using threads=3
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 Cache64
x264 [warning]: VBV is incompatible with constant QP, ignored.
[00000503] main encoder debug: using encoder module "x264"
[00000401] main private debug: adding a new input
[00000401] ffmpeg private debug: adding input
I'm disappointed that h264 encoding isn't working, and though it's not the main problem here, I would prefer to use it to H263. Any ideas on this one?
The main problem is that rtsp streams are not properly transcoding to FLV. I'm using Apple's Darwin Streaming server to provide my rtsp. Works greats. The following
vlc --sout "#transcode{vcodec=FLV1}:std{access=http{mime=video/x-flv},dst=0.0.0.0:8080/stream.flv}" rtsp://10.4.0.71:554/sample_100kbit.mp4 --loop --no-audio --color -I dummy
produces
[00000381] dummy interface: using the dummy interface module...
[00000397] main private: creating httpd
[00000409] live555 demuxer: set startseq: 15951
[00000409] live555 demuxer: set startseq: 28408
So it appears to work right? When I try to connect to the same place as before (127.0.0.1:8080/stream.flv), Flex cannot get the video. Instead there are debug traces like this
nsActivate
playing stream txtAddress.text: http://127.0.0.1:8080/stream.flv
openNetStream width: 320 height: 240
onNetStatus event: NetStream.Play.Start
onMetaData()
(Array)#0
[duration] 0
[filesize] 0
[framerate] 1000
[height] 242
[videocodecid] 2
[videodatarate] 0
[width] 192
onNetStatus event: NetStream.Play.Stop
onNetStatus event: NetStream.Buffer.Flush
nsDeactivate
There's not even a height and width listed for the video. By contrast, running the very first command above yields
onMetaData()
(Array)#0
[audiocodecid] 2
[audiosamplerate] 44100
[audiosamplesize] 16
[duration] 0
[filesize] 0
[framerate] 25
[height] 240
[stereo] true
[videocodecid] 2
[videodatarate] 0
[width] 320
and plays properly.
I apologize for the lengthy post, but I wanted to get this all out there. So, here are my questions:
1. Should I be able to transcode a live rtsp stream in mp4 to a live FLV stream with h264 video?
2. What --sout command should I be trying to make this work?
3. Are there other switches I should be setting to VLC to get this working?
Thanks for your attention!
First off, thanks for the great forum. I've had a lot to read over the past few days trying to get RTSP -> FLV live stream transcoding going. I'm still having issue though, so I'm going to post them up.
Problem Scope
I need to transcode a live RTSP stream, encoded with MP4 video and audio into a FLV stream with of any functional video type. I have had very good luck transcoding a static .FLV file with H263 or H264 content into streaming FLV. I have been testing using the vlc 0.9.0 3/22 daily build on both Windows and Linux. I am using Adobe Flex to open the connection to grab video. That code is quite standard - you would do the exact same thing in Flash to play video.
These work:
vlc C:\Media\Videos\Robot_sentinella.flv --sout "#transcode{vcodec=FLV1,acodec=mp3}:std{access=http{mime=video/x-flv},dst=0.0.0.0:8080/stream.flv}" --loop --color -I dummy
vlc --sout "#transcode{vcodec=FLV1}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\Robot_sentinella.flv --loop --color -I dummy
vlc --sout "#transcode{vcodec=FLV1,acodec=mp3,samplerate=11025}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\AVCHD-stright-to-flash.MP4.flv --color -I dummy
vlc --sout "#transcode{vcodec=FLV1,acodec=mp3,samplerate=11025}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\AVCHD-stright-to-flash.MP4.flv --sout-transcode-hurry-up --sout-transcode-high-priority --file-caching=1000 --high-priority --repeat --color -I dummy
As soon as I try to transcode from rtsp or encode to h264 or mp4v, I have issues.
vlc --sout "#transcode{vcodec=h264,vb=96,acodec=mp4a,samplerate=11025,scale=1}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8080/stream.flv}" C:\Media\Videos\Robot_sentinella.flv --loop --color -I dummy -vvv
Crashes the 3/22 Windows daily build with
[00000503] x264 encoder debug: version x264 0.58.X
[00000503] x264 encoder debug: initializing pthread-win32
x264 [info]: using threads=3
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 Cache64
x264 [warning]: VBV is incompatible with constant QP, ignored.
[00000503] main encoder debug: using encoder module "x264"
[00000503] x264 encoder debug: pthread-win32 deinitialized
[00000503] main encoder debug: removing module "x264"
[00000502] ffmpeg decoder warning: warning: first frame is no keyframe
(flv@00C897C0)
[00000392] stream_out_transcode private debug: decoder aspect is 576000:432000
[00000392] stream_out_transcode private debug: source pixel aspect is 1.000000:1
[00000392] stream_out_transcode private debug: scaled pixel aspect is 1.000000:1
[00000392] stream_out_transcode private debug: source 320x240, crop 320x240, des
tination 320x240, padding 320x240
[00000392] stream_out_transcode private debug: encoder aspect is 576000:432000
[00000503] main encoder debug: looking for encoder module: 12 candidates
[00000503] x264 encoder debug: version x264 0.58.X
[00000503] x264 encoder debug: initializing pthread-win32
x264 [info]: using threads=3
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 Cache64
x264 [warning]: VBV is incompatible with constant QP, ignored.
[00000503] main encoder debug: using encoder module "x264"
[00000401] main private debug: adding a new input
[00000401] ffmpeg private debug: adding input
I'm disappointed that h264 encoding isn't working, and though it's not the main problem here, I would prefer to use it to H263. Any ideas on this one?
The main problem is that rtsp streams are not properly transcoding to FLV. I'm using Apple's Darwin Streaming server to provide my rtsp. Works greats. The following
vlc --sout "#transcode{vcodec=FLV1}:std{access=http{mime=video/x-flv},dst=0.0.0.0:8080/stream.flv}" rtsp://10.4.0.71:554/sample_100kbit.mp4 --loop --no-audio --color -I dummy
produces
[00000381] dummy interface: using the dummy interface module...
[00000397] main private: creating httpd
[00000409] live555 demuxer: set startseq: 15951
[00000409] live555 demuxer: set startseq: 28408
So it appears to work right? When I try to connect to the same place as before (127.0.0.1:8080/stream.flv), Flex cannot get the video. Instead there are debug traces like this
nsActivate
playing stream txtAddress.text: http://127.0.0.1:8080/stream.flv
openNetStream width: 320 height: 240
onNetStatus event: NetStream.Play.Start
onMetaData()
(Array)#0
[duration] 0
[filesize] 0
[framerate] 1000
[height] 242
[videocodecid] 2
[videodatarate] 0
[width] 192
onNetStatus event: NetStream.Play.Stop
onNetStatus event: NetStream.Buffer.Flush
nsDeactivate
There's not even a height and width listed for the video. By contrast, running the very first command above yields
onMetaData()
(Array)#0
[audiocodecid] 2
[audiosamplerate] 44100
[audiosamplesize] 16
[duration] 0
[filesize] 0
[framerate] 25
[height] 240
[stereo] true
[videocodecid] 2
[videodatarate] 0
[width] 320
and plays properly.
I apologize for the lengthy post, but I wanted to get this all out there. So, here are my questions:
1. Should I be able to transcode a live rtsp stream in mp4 to a live FLV stream with h264 video?
2. What --sout command should I be trying to make this work?
3. Are there other switches I should be setting to VLC to get this working?
Thanks for your attention!