Announcement

Collapse
No announcement yet.

Streaming Video with NSV

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Streaming Video with NSV

    Streaming Live Video with NSVenc
    Last Updated: 04-03-2003


    NSV is a new video format. It is designed to be easily streamed, support any audio and video codec, and be usable on nearly any platform. Currently NSV utilizes MP3 for audio and VP3 for video. Support for more codecs will be added soon. This tutorial shows how to stream a NSV based SHOUTcast stream from a live source.


    1. Downloads
    Download and install the latest version of NSV Tools.
    Download and install the SHOUTcast server 1.9.2 or above.

    Winamp3 or Winamp 2.90 are required for playback.


    2. Headers Set-up
    Create a new text file called headers.txt and save it in the NSVenc folder (C:\Program Files\NSVenc\ by default). In the file include:


    code:

    changeme
    content-type:video/nsv
    icy-metadata:0
    icy-name:My NSV Stream
    icy-genre:Video
    icy-pub:0
    icy-br:128
    icy-url:http://www.com
    icy-irc:#chan
    icy-icq:1234567
    icy-aim:SomeUser
    icy-reset:1


    The first line (changeme) is the password to connect to the server. If it was changed in the server configuration make sure headers.txt reflects that change. Leave lines two and three alone. The forth line down is all information about the stream. The same that would be entered in the SHOUTcast DSP. The "icy-pub" header signifies if it is a public stream, listed on SHOUTcast.com (1 for public, 0 for not public). The next header "icy-br" signifies the stream's bit-rate, guess. The rest should be self explanatory.

    Save the file to the NSVenc folder (C:\Program Files\NSVenc\headers.txt by default) if it hasn't been saved already.


    3. Device and Server Start
    3.1 Getting there
    Plug-in the video capture device you wish to use. (Web cam, video cam, video capture card, etc...). Audio, if used, can be set up using Windows Recording Control.

    Start up the server, make sure it is waiting for a connection.

    3.2 Command Prompt
    Start your command line interpreter (the MS-DOS like thingy). In Widows XP/2K/NT go to Start > Run > type "cmd" > OK. In Windows 9X/ME go to Start > Run > type "command" > OK. Switch to the NSVenc folder (assuming default location here).

    code:

    cd \
    cd "Program Files"
    cd NSVenc

    After that the command prompt should be in the NSVenc folder (C:\Program Files\NSvenc), shown in Figure 3.2.1.

    {Figure 3.2.1 place holder}
    Figure 3.2.1: Command Prompt


    4 Configuring
    4.1 Encoder Setup
    Next the encoder must be configured. At the command prompt type "nsvenc /config" (no quotes). This brings up the "NSVenc configuration," shown in Figure 4.1.1. For now leave this box alone.


    Figure 4.1.1: NSVenc Configuration

    Hit the "NSV Encoder Options" button to bring up the "NSV Encoder Options" box, shown in Figure 4.1.2. Select the audio and video you want. If audio is included use "MP3 (Lame) encoder" and pick the desired encoding options (not discussed). For video choose "VP3 3.1 (proper)." Select a bit-rate to aim for (it won't be constant and may not even be near it). Hit "OK" then "OK" again to exit.


    Figure 4.1.2: NSV Encoder Options

    4.2 Encoder Startup
    Once everything is configured and plugged in it is time to start the encoder. Use the following line (or a variation based on your needs.)


    code:

    nsvenc /cfgcap cap:0,N sc:127.0.0.1:8001:headers.txt

    - /cfgcap brings up the capture configuration
    - cap:0,N says to capture from the first video capture source and capture no audio. Use cap:0,0 for first device video and audio. Use cap: to list all available capture devices, and use the number of the device in subsequent runs to automate. Use audio device 'I' for MiniDV source audio (interleaved)
    - sc: says to send the data to a SHOUTcast server
    - 127.0.0.1 is the IP address of the server. The IP of 127.0.0.1 is for the server being on the same system as NSVenc.
    - 8001 is the port to send the data to. Note this is PortBase+1. The PortBase set in the SHOUTcast server configuration (8000 by default, so 8001 to send to. Using the SHOUTcast DSP it would add the one for you).
    - headers.txt specifies what text file headers are in. This should be the earlier created document in the same folder.

    Up next should be the "Capture Configuration" box (also know as "Poopie Properties"), shown in Figure 4.2.1.


    Figure 4.2.1: Capture Configuration

    Select a capture frame rate and resolution. Start kind of low. The encoding takes a lot of CPU power.

    4.3 Connection
    The encoder should start encoding the video and sending it to the server. If it connects the encoding output will look something like what follows:

    code:
    [size=2]
    from: cap:0,N
    [email protected]
    to : sc:127.0.0.1:8001:headers.txt
    video=VP31 (deinterlaced(LQ)+rescaled(LQ) to [email protected])

    (hit ESC to abort)
    0:59:10 @ 19.8fps 95kbps (d=0,vinq=0,ainq=0)
    [size]


    Also the SHOUTcast server should show a connection. The normal connection information should appear in the log. An example is an output like:

    code:

    <12/13/[email protected]:40:29> [source] connected from 127.0.0.1
    <12/13/[email protected]:40:30> [source] icy-name:My NSV Stream ; icy-genre:Video
    <12/13/[email protected]:40:30> [source] icy-pub:0 ; icy-br:128 ; icy-url: http://www.com
    <12/13/[email protected]:40:30> [source] icy-irc:#chan ; icy-icq:123456 ; icy-aim:SomeUser


    If there are any errors, re-read the above steps and try again. If there are no errors the stream can now be viewed.


    Playback
    Streaming NSV files can be played in Winamp3 Winamp 2.90+, nsvplay (included with NSV Tools, not discussed), NSVPlayX (ActiveX for Internet Explorer, not discussed) and NSVPlayMoz (Mozilla/Netscape plug-in, not discussed).

    The URL for the stream is different then the standard MP3 stream URL. Without any modification Winamp will not be able to determine that it is a NSV file it is receiving and not a MP3 stream. The stream URL for a NSV stream is as follows:
    http://your_ip:8000/;file.nsv

    Where "your_ip" is the IP of the system running the SHOUTcast server. The port is 8000 by default (not 8001) or something else if you changed it in the SHOUTcast configuration (PortBase). There is no typo, use ";file.nsv" and not "listen.pls" after the address and port.

    Open that URL in Winamp (Ctrl-L). If everything is working it will connect, buffer, and then the video window will pop up and play.

    That's it for now.

  • #2
    NSVenc Stuff
    Updated: 04-03-2003


    Additional Notes
    I'll add a few things which are valid as of April 3:

    /ignoredrops on the command line may or may not make your life happier with regard to sync.

    Winamp2 now plays NSV SHOUTcast feeds directly. Simply point the player at a server providing a feed and use ctrl-L and http://server.iport/;stream=stream.nsv to start watching.

    If you wish to include MP3 audio in your stream, make sure to configure the sample rate conversion on the first page appropriately.

    For example, if you are broadcasting a 128kbps stereo MP3 feed, then leave the conversion at 44100 khz stereo. If you'll be using a 24kbps 22khz mono MP3 feed, you should set the sample rate conversion to be 22050 mono. 11khz would be 11025 and so on.

    We do still recommend you continue to use either 44khz, 22khz, or 11khz as the sample rate for broadcasting to ensure maximum compatibility with soundcards.

    You'll want to use CBR and normal quality for the encoding, solely.


    NSVenc Command Line Switches and Options
    Here's a rundown of what all the settings actually do, and some guidelines for setting up a stream of your own.

    First I'll go over a list of what every setting actually means and does, then establish some guidelines for how to configure the settings.

    List of settings and their functions:


    NSVEnc Config Window:
    Deinterlace Video: This should be checked if the source you are capturing from sends an interlaced signal. Most capture boards provide a progressive signal, but a few send alternating frames. Check your capture documentation to see if you need this setting activated. Chances are whether you're streaming from a capture board or off an AVI file; you will not need this enabled.

    High quality deinterlace: Improved deinterlace quality at the expense of more consumption of CPU. Unsuitable for live streaming.

    Cropping: If your source is letterboxed or has garbled edges, you may remove a specific number of pixels from the output stream by entering the number of pixels to remove from each edge here. Keep in mind, however, that the VP3 codec requires a resolution that is a multiple of 8 pixels, so if you crop any pixels, you'll need to crop at total of 8, 16, 24, etc. This has a small impact on CPU.

    Resizing: This option requires significant CPU and should be avoided for live streaming. Resizing takes a large resolution source and reduces it to a resolution more suitable for streaming. You should only use this option as a last effort, as it's far better to preprocess an AVI or tell your capture card to do the reduction for you when you can.

    High quality resize: Improved resizing quality at the expense of CPU. Unsuitable for broadcasting.

    Audio Processing: Resampling is required when your audio codec will be streaming at a reduced sample-rate or in mono. If you use 128kbps MP3, use 44100 and Stereo. for 64kbps mono, you'd use 44100 and mono. for 24kbps MP3, you'd use 22050 sample-rate and Mono. 8kbps mono mp3, 11025 and mono. You get the idea.

    Lowpass filter when downsampling: This reduces the tendency of transient frequencies to sound wacky when downsampling to lower frequencies. Try it on your stream if you're using a low sample-rate to see what its effects are.

    Output frame-rate: If you need to reduce the number of frames per second in the output stream, provide the actual frames you want to stream at here. For example, if you have a 1.2Ghz CPU you might want to only stream at 15 fps instead of 30. You can also increase the frame-rate if you really want to, though the only instance where this remotely makes sense is converting 29.0097 fps to 30.

    NSV Encoder Configuration:
    This screen provides access to the NSV header, audio and video codec controls. I'll only provide information on configuring the MP3 audio and VP3 video codecs:

    NSV Format options:
    All of these options, except sync interval, mean nothing for live streams. They're only useful on file-based NSV streams.

    Audio send-ahead: This defines a differential in sync between the audio stream and video stream. It should almost always remain at 0.

    Min/Max Sync Frame Interval: The number of frames which may occur between a forced resync in the stream. 10 / 50 is a good value for streaming, far better than the 0/150 that is specified as default.

    File header: If checked, includes the optional NSV header which includes metadata.

    TOC size: the size of the NSV header's Table of Contents. 1024 is the default.

    Metadata: Information about the creator, title, copyright and other data. Check NSV's documentation for current fields which can be used here.

    AUDIO:
    Audio format is the codec to use to send audio. You almost certainly want to use MP3 Lame here.

    Encoder options:

    Mode: ALWAYS leave this at CBR. Choose Mono or Stereo, and make sure the previous config page is sampling to match.

    Bitrate: Bitrate is the bitrate of the audio track. Make sure you set an appropriate sample-rate to match on the previous config page (mono 48kbps+ and stereo 96kbps+ = 44100, mono 24-32kbps and stereo 48-96kbps 22050, lower 11025)

    Quality: Always leave this on Low for a live stream.

    VIDEO:
    Video format: You will almost certainly want VP3.

    Bitrate: The target bitrate you want to video stream to go at. Keep in mind this is independent from Audio bitrate. A good standard bitrate for 320x240 30fps is about 256-384kbps. at 160x120 15fps you can go as low at 96kbps.

    Keyframe bitrate: The target bitrate of each keyframe. Keyframes are the master frames the video changes are drawn from, usually occurring at a scene change or when significant differences are on screen. They typically occur about once a second. This value will be the bitrate dedicated to these specific frames, and should be set to between 1/3rd and 1/2 the video bitrate. i.e. 256kbps video bitrate would indicate a 96kbps keyframe bitrate.

    Allow dropped frames: MUST be checked if you expect the stream to be anywhere near the bitrates you've defined.

    Quality: 57 is a good default to use on a fast Athlon XP or P4. otherwise, you'll need to go lower. Note that for some crazy reason, On2 decided to make a higher number mean lower quality. 63 is lowest, 50 is highest. A higher quality also tends to increase bitrate. The higher a quality setting here, the more CPU will be required to stream as well.

    Quick compress: should always be checked on for live streaming

    Auto keyframe: should always be checked on for live streaming

    Threshold: The percentage difference to force a keyframe. set to 90

    Minimum distance: The minimum interframes to allow between keyframes. Set to 8.

    Maximum distance: The maximum frames to allow before forcing a keyframe. Set to 120.

    Noise sensitivity: The keyframe selector will tolerate more noise when this value is raised. 1 is a good default for standard captured video.

    Sharpness: The amount of unsharp mask applied to each frame. 1 is a good value.



    Video Guidelines
    Most everyone will use the VP3 codec. Establishing an ideal bitrate depends on a number of factors, including resolution of source material, available processing power, available upstream bandwidth, and type of material being streamed.


    Video resolution:
    Larger resolutions will require much more bandwidth and CPU. It is fairly impossible to stream real time at 24 or 30fps any material larger than 480 pixels high or wide. Most streams should conform between 160x120 and 320x240. You establish the resolution to stream at on the first config page. Note that if at all possible, configure the source to be at the same resolution you intend to stream at, as this will greatly reduce CPU. Resizing a 640x480 capture or AVI to 320x240 will greatly impact your ability to stream it, so either set the capture settings to the resolution you intend to stream at, or resize the source AVI you'll be streaming from.


    Processing power:
    My Athlon XP 2600+ consumes 50% CPU doing live capture and encode on 30fps at 320x240 using 320kbps and a 180kbps keyframe bitrate. Yes, you *will* need very serious CPU to do live 30fps and 24fps encoding, as in a 1.4Ghz or faster processor. This is all the machine will be able to do with that processing power as well, so if you aren't ready to dedicate a CPU to the task, then you're not ready for high-bitrate high-quality broadcasting. You can reduce the frame rate or the resolution to attain a CPU usage level your machine can broadcast at. You can check by using Windows' Task Manager to look at CPU usage (performance tab) while encoding.


    Upstream bandwidth:
    Obviously, you can only push as many bits as your internet connection allows. All dialup, and most broadband connections do not offer enough upstream bandwidth to stream high-bitrate video. If your DSL line is 1.5 down and 128k up, then you could at most send a 96kbps NSV feed. Serious broadcasters looking to push 320x240 at 24 or 30fps will need to invest in a T1 line. Cable users may be able to squeeze enough bits upstream to a SHOUTcast server somewhere to relay the signal out. I use a company T1 line to send my stream to a SHOUTcast server, which is located at a major datacenter.


    Type of material:
    The rule of thumb here is the more motion, the more bits you'll need. A news broadcast will require significantly less bits than an action movie, as the amount of scene changes and camera motion in the news broadcast is usually focused on the same object.

    Keeping this in mind, some of the following settings may be appropriate for your material:

    T1 upstream, dual 2.4Ghz+ processor:
    Pretty much whatever you want. Preprocessing and capture will occur on one CPU and the other CPU will be dedicated to compression of the audio and video. This CPU coupled with a MiniDV source via Firewire is the ideal broadcast setup.

    T1 upstream, 2 Ghz+ processor, 320x240 30fps capture NTSC:
    audio: 64kbps mono MP3 @ 44100
    video: 280kbps / 120kbps keyframe @ qual 57

    T1 upstream, 1.4Ghz processor, 320x240 30fps capture NTSC:
    audio: 64kbps mono MP3 @ 44100
    video: 256kbps / 100 kbps keyframe @ qual 57, 15 fps

    Cable upstream, 1.4Ghz processor, 160x120 30fps capture NTSC:
    audio: 24kbps mono MP3 @ 22050
    video: 128kbps / 56 kbps keyframe @ qual 57, 15 fps


    Hopefully this establishes some useful guidelines. I invite you to post messages on this forum about what hardware you're using and corresponding settings which work well for you. Please be specific about CPU, capture device, and audio/video settings!

    Good luck,
    -Tom

    Comment

    Working...
    X