Trendnet TV-IP400 - Zoneminder 1.22.x

12

description

b

Transcript of Trendnet TV-IP400 - Zoneminder 1.22.x

  • development, Home AutomationAugust 14th, 2007Controlling the Trendnet TV-IP400W camera with ZoneMinder

    Update (7 /18/08): this driver and instructio ns wo rk fo r Z o neMinder 1.22.x o nly, see my update fo r Z M 1.23.xsuppo rt.

    I cant even rem em ber when was the last tim e that I had to reverse engineer som ething.. i t m ay have been as long ago asm y col lege days. But last week I had a couple of evenings of fun figur ing out the inner workings of m y TrendnetTV-IP400W. This is a cool l i ttle internet cam era wi th bui l t in wi fi and a bui l t in web server . You can control i t from abrowser and you can actual ly pan and ti l t this cam era around the room , so even though the picture qual i ty isnt great(probably com parable to your average webcam ), i t can be very useful i f you want to keep an eye on your house, your pets,your baby, etc from anywhere in the wor ld. The best par t: you can pick one up onl ine for less than $200, which is a steal fora pan/ti l t IP cam era.

    The bui l t in web server is useful for checking up on the l ive si tuation, but i t does not have any features to autom atical lynoti fy som ething or som eone i f m otion is detected in front of the cam era. The windows control appl ication does do m otiontr iggered recording, but i f you want to m oni tor your cam era from outside your hom e youl l have to set i t up to em ai l al l thevideos to yoursel f, as the windows app cant function as a web inter face.

    Al l of this m akes this cam era m ore of a toy, wi th l im i ted rem ote m oni tor ing features. But, I wouldnt be m e i f I didntfigure out a way to get what I wanted from this thing. Since I al ready have 2 Linux boxes running Misterhouse, MythTVand var ious databases and developer tools, I figured one of these boxes could easi ly function as a survei l lance system aswel l .

    So I set out to instal l ZoneMinder on m y Ubuntu system . ZoneMinder is an extrem ely ful l featured (open source) videocam era secur i ty and survei l lance system . It suppor ts m ul tiple CCTV and IP cam eras, has a web inter face, i t can controlPTZ (Pan Ti l t Zoom ) cam eras, and suppor ts custom tr iggers, m ul tiple m otion z ones per cam era, etc.

    After a l i ttle bi t of tinker ing I got ZoneMinder running, and i t turned out that even getting i t to capture video from m yTrendnet cam turned out to be tr ivial Al l I needed to do was to configure the cam era stream to http://192.168.0.140/video.cgi on m y hom e LAN!

    Unfor tunately, thats as m uch as Id be able to do wi th ZoneMinder and this cam . The IP400W uses a propr ietary controlprotocol to m ove the cam era and there wasnt any ZoneMinder dr iver for i t yet.

    But how hard could i t be to wr i te one?

    The cam era al ready cam e wi th a web inter face wi th sim ple form buttons to control m ovem ent, so I figured thesecom m ands should be easy to fake by a scr ipt. That wasnt the case though, since there were no di rect http requests fromthe cam era control page: the page loads a Java applet and this applet is responsible for al l TCP/IP com m unication wi th thecam era.

    After that fi rst l i ttle hum p I figured I should probably fi rst em ai l Trendnet and ask them nicely for the protocol specs, but asI m ore or less expected they werent able to give m e that info (booo). So m y only chance would be to reverse engineer theprotocol and wr i te m y control scr ipt wi th what I learned from that. Heres what I did.. and i f youre not interested in how Idid i t you can scrol l straight down to find out how to get your own Trendnet cam era working in ZoneMinder . If you just wantto know m ore about the detai ls of the protocol so you can wr i te your own dr iver , check out the specs here.

    deco mpiling the java applet o f the T rendnets web interface.

    So as i t turned out, the web inter face wasnt sending control com m ands back to the cam era using HTTP GET or POST from

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    1 of 12 10/19/2008 05:41 PM

  • the control page, but i t was sending com m ands through a Java applet instead, by cal l ing functions l ikem ovePanTi l tDegree() on the applet. That wasnt going to tel l m e m uch about the com m and protocol , so I instal led Jad,saved the applets from m y cam on m y harddisk and star ted decom pi l ing.I had never actual ly decom pi led a java class before and i t was pretty interesting to see propr ietary binary-only softwareturn back into source code wi th Jad! Of course al l or iginal nam es of non-publ ic m ethods and var iables had been lost, butthere were only a couple of pr ivate m ethods in the class, and m any of the m em ber var iables I could give real nam es againby looking at how they were used in publ ic getter and setter m ethods. Unfor tunately Jad had problem s decom pi l ing par t ofthe class fi le, so the resul ting source fi le had som e garbage in there and I wasnt going to be able to run the code in adebugger to real ly see what com m ands i t would generate. But in any case i t was clear what ur ls i t uses for control , foradm inistration features and for the video stream , and what com m and param eters i t knows.

    running a netwo rk sniffer to reverse engineer the pro to co l

    Decom pi l ing the cam eras java applet was very useful , but after seeing that the applet uses sim ple HTTP POST requests tosend com m ands to the cam era, I real iz ed I m ay have been able to skip al l of that and figure out the (text based) protocolwi th a sim ple network sni ffer . So I instal led Eavesdrop on m y Mac, a handy l i tle tool that wi l l tel l you exactly what data iscom ing into and leaving your system . (before al l of this I had tr ied Fi rebug, since that should also tel l you about al lrequests leaving Fi refox, but as i t turns out Fi rebug does not track any requests sent by java applets, only by htm l andjavascr ipt code).As soon as I fi red up Eavesdrop and star ted playing wi th the IP400Ws control pages, the answers to m y questions star tedrol l ing in.In less than an hour I had al l the com m ands wr i tten down and I was able to send basic com m ands to the cam era wi th asim ple per l scr ipt.Whi le playing wi th the param eter values, i even found som e com m ands that arent possible wi th the web inter face. It turnsout the cam era can be m oved diagonal ly as wel l (which is not possible wi th the Trendnets web inter face, al though I think i tis wi th the PC app) and there is also a swing m ode that m oves slowly from the extrem e left to the extrem e r ight posi tionand back, stop for a second at every 10 degrees or so.

    Another interesting thing I learned was that the z oom feature isnt real ly suppor ted on the cam era server side at al l .When you change the view m ode to 2x or 4x, i t is the applet in your browser that sim ply m agni fies the im age. It was clearfrom the picture degradation that the cam era didnt have an optical z oom , but i ts too bad that the digi tal z oom is done onthe cl ient side, since that m eans that ZoneMinder wont have access to a z oom feature, unless Id wr i te som e server sidescr ipt that can m anipulate the incom ing video stream .

    For people who want to wr i te thei r own control appl ications, the protocol descr iptions are here, and you can read about m yruby dr iver here. My ruby dr iver actual ly includes suppor t for stor ing presets, which the ZM dr iver cant do (yet).

    writing the zo neminder co ntro l script and co nfigure Z o neMinder fo r this cam

    With the IP400Ws control protocol (m ostly) decyphered, i t was now tim e to wr i te the ZoneMinder control scr ipt. For tunately,that was the easy par t. ZoneMinder has done an excel lent job of creating a cam era control inter face that should be able tosuppor t control lable cam eras wi th alm ost any set of features, by cal l ing a scr ipt or external program wi th cer tainpredefined param eters. Even better news, an existing control scr ipt for a panasonic IP cam era showed m e how that issending HTTP GET com m ands to a Panasonic cam era wi th a sim i lar set of features. Im not a Per l pro at al l , but I couldhandle this one. Another hour later , I was control l ing m y Trendnet cam through ZoneMinder !

    Il l get to the point now, because i f youre sti l l reading here, youre probably also an IP400W or IP400 owner who wants to usei t wi th ZoneMinder . Heres what to do:

    Download m y z m control -trendnet-ip400.pl scr ipt and instal l i t in a di rectory thats in your path. On m y Ubuntusystem the other control scr ipts were instal led in /usr /local /bin so that would be a good spot to put this one as wel l .Make sure the scr ipt has execute perm issions so you m ay want to run chm od 755 z m control -trendnet-ip400.pl

    1.

    Thats real ly al l that should be requi red on the instal lation end. Now al l thats left is to configure ZoneMinder toControl your Trendnet. Fi rst, m ake sure your ZoneMinder configuration is configured to control PTZ cam eras. In the

    2.

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    2 of 12 10/19/2008 05:41 PM

  • System tab of the Options page, m ake sure the option ZM_OPT_CONTROL is checked.If you havent done so yet, i ts tim e to add your new m oni tor now. In the General tab, give your cam a nam e (m ineis cal led ki tchen_cam ) and set the source type to rem ote. In m ost of the tabs I didnt change m uch from the defaul tsettings. Heres what m y tabs look l ike:

    3.

    The settings in the buffers and tim estam p tabs do not need to be changed. My control tab looks as fol lows:

    Make sure the control IP address or hostnam e iscorrect, i t should be the sam e as what you entered inthe source tab.

    The Control Type input dropdown in your ZoneMinder

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    3 of 12 10/19/2008 05:41 PM

  • instal lation l ikely wont have the Trendnet IP-400W option, so lets enter that. Cl ick on edi t.

    Cl ick on Add New Control . This should pop up theControl Capabi l i ty window wi th a 9 di fferent tabs. Thesescreens are used to speci fy what kind of features ourcam era suppor ts. Ive added screenshots of m y tabsbelow. Som e of these settings m ay be i r relevant or notoptim al , but as they say: i f i t aint broke, dont fix i t.

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    4 of 12 10/19/2008 05:41 PM

  • sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    5 of 12 10/19/2008 05:41 PM

  • sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    6 of 12 10/19/2008 05:41 PM

  • sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    7 of 12 10/19/2008 05:41 PM

  • No z oom , focus, whi te and i r is features are suppor ted by this cam era so you can leave al l the checkboxes unchecked in thecorresponding tabs. Final ly, m y presets tab looks l ike this:

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    8 of 12 10/19/2008 05:41 PM

  • You probably want to change the Num Presets value to the actual num ber of presets that youre using (the m ax is 25), soyou dont end up wi th a bunch of buttons in the control page that dont do anything.

    Setting presets is not suppor ted yet by m y ZoneMinder dr iver . Ive figured out how to do i t now and i ts suppor ted in m ynew Ruby dr iver , but I probably wont add i t to the ZoneMinder dr iver unless I get a lot of requests for i t. (i ts a l i ttletr ickier to im plem ent than the other com m ands, since i t requi res pul l ing in and parsing par t of an m jpeg stream ).

    When youre done setting values in al l these tabs, cl ick on save and you should see the control capabi l i ties window again,wi th your new Trendnet control added to the l ist. Make sure this new control is selected in the Moni tor - Control tab above.

    The one thing that I do need to add at som e point is secur i ty control . Right now, this dr iver wi l l onl y work i f you disableuser access control in the Configuration -> User screen of the Trendnet adm inistration inter face. So m ake sure your camis behind a fi rewal l !

    Its tim e to test your new cam era control . Cl ick on your cam era in the m ain ZoneMinder console page, and when yourcam era window opens you should see a Control l ink in the top. (i f you dont see i t, double check that theZM_OPT_CONTROL option is set as descr ibed in step 2). Cl ick on the Control l ink and you should see som ething l ike this:

    Al l the buttons for m ovem ent and presetsshould work now. If they dont, check yourZoneMinder logs and take i t from there.

    I hope this page is helpful to the TV-IP400users out there! Please let m e know i f youhave any suggestions or feedback or i f youve

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    9 of 12 10/19/2008 05:41 PM

  • im proved the code or configuration.

    Ive also been working on a Ruby dr iver forthis cam era, and a sm al l and sim ple rai lsappl ication for viewing and control l ing i t fromthe web. Its got a separate inter face forhandhelds such as sm art phones or pocketPCs so you can easi ly check on yourhouse/com pany/baby/dog when youre out andabout. It could also m ake a goodsoftware/hardware com bo for setting up acheap control lable outdoor or indoor webcam forpubl ic access. Il l post m ore about this soon.

    sfpeter.com Blog ArchiveSays:August 20th, 2007 at 11:47 pm

    [] engineered the protocol that is used tocontrol the cam era, and wrote a ZoneMinderdr iver for i t go here for m ore inform ation.This fol low up descr ibes the control protocolthat I reverse engineered, and []

    1.

    burki Says:September 23rd, 2007 at 7:08 am

    hal lo, can you help m ei have also the tv-ip400 and i wi l l upload any fi le to the nas server in the sam e network. how m ust i configur theUpload? The adress of the nasserver is 192.168.1.100

    HRB

    2.

    peter Says:September 26th, 2007 at 10:39 am

    I havent used this functional i ty, but I think the TV-IP400W only suppor ts FTP for upload. If your NAS suppor ts FTPtoo, then set up an FTP account for your trendnet cam era in your NAS, go into your IP400s web configuration andenter the account info in the configurationupload screen. Make sure to enable the checkbox enable upload video toFTP server and set up the tim e schedule, fram e rate and fi lenam e settings. Since the IP400W doesnt do anym otion detection, youre going to get a lot of video on your server . Unless you real ly want to record al l video non-stop(or at cer tain tim es), I recom m end you use software that suppor ts m otion detection, such as ZoneMinder , or evenjust the windows software that com es wi th your cam era.

    3.

    rshafer0 Says:October 27th, 2007 at 5:52 pm

    Hel lo I am new to Zonem inder . I tr ied to get m y TV-IP400W working wi th Fedora 7 and I could only get a blackscreen wi th no video. I read that there have been problem s wi th this issue in using Fedora 7. I decided to instal lFedora core 6 using this URL to the T http://www.z onem inder .com /wiki /index.php/Fedora_Core_6_Step-by-StepThen I used your ar ticle on TV-IP400W to configure i t the rest of the way. Now I sti l l get the sam e resul ts. I addedthe new m oni tor in ZM, and the IP address turns green. I go to view the m oni tor and i t is sti l l just a black screen. Ican go to the cam era di rectly through the Trend software and I see video, so I know i t works. I have been able to getwebcam s to work wi th Zonem inder . I am having issues wi th stream ing m peg video from this device, I guess.There m ust be som ething that I am m issing. Any help would be greatly appreciated.

    4.

    ?lker ?LGEN Says:December 6th, 2007 at 3:28 pm

    5.

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    10 of 12 10/19/2008 05:41 PM

  • I am so happpy find your web si te.

    I am using z m and 8 channel saa7130 dvr card and i ts per fedctly running.I bought the IP cam dl ink dcs-900 .I can see the video but cant record or m ocord or m odect.

    Did you hava a think for this problem ?Thank you

    soares Says:December 20th, 2007 at 2:55 am

    You give m e the way to handel m y Trendnet TV-IP 100.

    Thank you for your good job.

    6.

    phiberop Says:January 17th, 2008 at 11:03 am

    Peter , thank you so m uch for the scr ipt you wrote for this cam era! Have you tested i t wi th ZM version 1.23.1? Iveread on the ZM forum that a lot of people are having issues wi th control scr ipts in the new version and I have beenunable to get your scr ipt working in 1.23.x so far . Can you confi rm i f i t is an issue wi th 1.23.1 or i f there m ight besom e other problem Im having? If i ts 1.23.1, can you m odi fy your scr ipt to accom m odate the changes? Thanks!

    7.

    Clyde Aseniero Says:February 15th, 2008 at 10:23 pm

    can Zonem inder run wi thout any capture card using IP Cam era only

    8.

    Don Says:April 30th, 2008 at 5:22 am

    Has anyone been able to find a way to change the Hom e posi tion to a di fferent coordinate? I suspect i t can bechanged in the configuration fi le but i ts al l code and so far no luck.

    9.

    peter Says:M ay 8th, 2008 at 9:15 pm

    I think I read in the help fi les som ewhere that the Hom e posi tion cannot be changed. You m ay be able to set a hom eposi tion in Zonem inder (not sure), but the hom e posi tion (preset 0) for the actual Trendnet cam cannot be changed.

    10.

    macko Says:M ay 21st, 2008 at 12:53 pm

    The scr ipt worked per fect, i can control the TV-IP400 just fine, but i dont get any video. I think i t could be due to thestream address. How you m anage to change i t to video.cgi on the cam era. Il l appreciate any help.

    11.

    macko Says:M ay 21st, 2008 at 12:57 pm

    The problem is not the stream address, m ust be som ething else..any help?

    12.

    land Says:June 12th, 2008 at 7:18 am

    Hel loI have the sam e problem as you Macko, I use the IP cam era TV-IP400. The scr ipt to control the cam era work fine buti dont get video stream ing. I use z onem inder 1.22.3 and the way I use to take im age from cam era is FTP uploadand I configure the source as fi le in z onem inder to get video. Does som ebody have a better way?

    13.

    peter Says:July 18th, 2008 at 10:34 pm

    14.

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    11 of 12 10/19/2008 05:41 PM

  • i f you dont get any video, you m ight want to try disabl ing the option ZM_NETCAM_REGEXPS in the option panels.This apparently fixed the issue for several other people in the ZoneMinder forum s.

    sfpeter.com Blog Archive new T rendnet T V-IP400W cont roller forZoneminder 1.23.x Says:July 31st, 2008 at 12:10 am

    [] Make sure you have indeed version 1.23.x. You can see this in the ti tle of the m ain console window. If you aresti l l using version 1.22.x, ei ther upgrade your ZoneMinder or use m y old dr iver . []

    15.

    Seth Says:September 12th, 2008 at 10:19 pm

    Thank you! disabl ing the option ZM_NETCAM_REGEXPS did indeed fix the black video issue.

    16.

    mat t Says:September 25th, 2008 at 7:03 pm

    Hey Peter , Im not speci fical ly trying to use m y IP400W wi th ZoneMinder but rather wi th a console program fromi-Catcher . i -Catcher doesnt have the bui l t in controls for the IP400W but i t does al low for gener ic cam s wi th ei thersingle jpeg scans or m otion jpeg stream s. I have tr ied the ur l you suggested but there is no response from the cam .Any fur ther suggestions?

    17.

    peter Says:September 25th, 2008 at 8:11 pm

    try enter ing that ur l in your browser . If that does work, theres probably som e issue wi th i -catcher . If i t doesnt work,then check that you have access control turned off, as i t probably wont work wi th http authentication enabled.

    18.

    mat t Says:September 29th, 2008 at 6:35 am

    When enter ing the ur l in IE7, i t just tr ies to save a cgi fi le. Wi th Fi refox 3, I can usual ly get a stream ing videofeed going but i t wi l l random ly ask m e i t I want to save the sam e cgi fi le. When I cancel , i t keeps showing the l ivefeed. What is working in i -catcher is a 1 sec jpeg update.http://IP/im age.jpg

    19.

    peter Says:September 29th, 2008 at 10:20 am

    Have you tr ied both http://ip/m jpeg.cgi and http://ip/video.cgi ? If one of them doesnt work, the other one m ight. Ifnei ther of them work, then i ts probably an incom patibi l i ty wi th icatcher that ei ther Trendnet or iCatcher would needto fix

    20.

    sfpeter.com Blog Archive Controlling the Tre... http://www.sfpeter.com/2007/08/14/controlling-the...

    12 of 12 10/19/2008 05:41 PM