User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Analog Cam Recorder Project

Mon Aug 18, 2014 2:22 pm

Hi! I am new to forum, but I have already searched (for 2 days now) about recording Composite Video on Rasp Pi.

Ok, I know there is already tons of material about this issue, but I haven't found anything like what I am willing to do.

I realized the best way to do this is buying some compliant Composite/USB device and capture video from /dev/video0 stream. Ok, looks fine and will probablly solve the problem, but... I have another idea...

What if...

1. Connect NTSC composite Camera (I am using SK-C300) to a GPIO pin with analorRead() capabilities.
2. Perform analogRead's to sampling data and creating a FIFO to put decoded data into a file.
3. Another job will read FIFO's content and ffmpeg to send it to composite output

I am supposing if I decode composite signal, extracting monochome data, I just need to know how to write each chunck of data to FIFO.

I know it the simpler way is to buy a USB dongle to do this, but I don't know... Feels like we could extract more from Rasp Pi. Analog read is kind of stuff I used to do with Arduino and its 16MIPS... I was wondering how much MIPS can I extract from a Rasp Pi?

Thanks in advance!
Renato Aloi

PS: Sorry my bad english, I am Brazilian guy.

EDIT:
More resources I've found:
http://www.raspberrypi.org/forums/viewt ... =38&t=8944
and
https://github.com/umlaeute/v4l2loopback/

EDIT2:
Future reference:
http://elinux.org/images/e/eb/Howtocolor.pdf
and
http://www.serasidis.gr/circuits/colour ... ar_gen.htm
and
https://courses.cit.cornell.edu/ee476/video/

EDIT3:
http://en.wikipedia.org/wiki/YUV
and
https://www.intersil.com/content/dam/In ... an9727.pdf

------ Site is downing, must paste here
CVBS is a common abbreviation for COMPOSITE Video Blanking and Sync or COMPOSITE Video Baseband Signal, more commonly known as Composite Video. Though far less commonly used than YPbPr (at least when it comes to labeling connections on video equipment,) YUV (or Y'UV) is one of several abbreviations used to identify a color-difference COMPONENT video format and/or signal. Both YPbPr and YUV as well as CVBS denote specific analog video signal formats.

Invariably analog component video offers superior video performance over composite video. Therefore, with rare exception, component video connections should generally be given preference over composite video (CVBS) connections.

Typically a composite video connection, which often uses connectors that are color-coded yellow, consists of a single 75Ω coaxial interconnect to connect between an individual composite video output (or Composite OUT) on one piece of video equipment to a composite video input (or Composite IN) on another piece of video equipment.

When dealing with analog component video signals the most common component video connection consists of no less than three equal-length 75Ω coaxial cables bundled as a set or molded to form a one-piece component video interconnect. Each coaxial cable in the bundle is terminated with a Green, Red or Blue color-coded (and/or labeled) coaxial connector to match the corresponding color-coded (and/or labeled) component video connectors on the video equipment being connected.

If you are connecting the composite video output on the DVD player to the composite video input on your plasma TV you would choose the CVBS setting. However, if both your DVD player AND your plasma TV are equipped with at least one set of analog component video connections, and you are using the proper (“3-wire”) 75Ω coaxial component video interconnect, then you should choose the YUV output setting on the DVD player. Again, the latter should generally provide a better video picture, however due to a variety of technical issues you may want to compare both configurations to be certain.

Resources from this post was not working... Removed
-------------
and
http://www.labguysworld.com/Goldmark1_006.htm

EDIT4:
Set back! R2R Ladder Is for analog output, not input!!! Some resources using LM339, 741 and 555
http://www.seas.upenn.edu/~ese206/labs/ ... dc206.html
http://www.seekic.com/circuit_diagram/E ... RFACE.html
http://www.eeweb.com/blog/circuit_proje ... -converter
Last edited by renato.aloi on Tue Aug 19, 2014 9:29 pm, edited 8 times in total.

User avatar
Burngate
Posts: 6328
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 3:54 pm

Unlike the Arduino, the Pi has no analogue inputs, so what you want to do won't work.

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 5:25 pm

Ops, I wasn't expecting that!

So... back to ADC via i2c SPI (limited by 20Mhz right?) or CSI connector...?

Thanks for the reply!

Edit: Perhaps something with Arduino Leonardo and TVOut Lib? Just an thought....

Renato
Last edited by renato.aloi on Mon Aug 18, 2014 8:14 pm, edited 2 times in total.

Duane Degn
Posts: 55
Joined: Thu Jul 10, 2014 6:30 am
Location: Idaho, USA

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 6:13 pm

You could capture monochrome video with a fast ADC chip.

The ADC08100 is an 8-bit parallel ADC chip which could be used to capture a NTSC video.

I used this chip with a Propeller chip to capture low res video to display to a DIY LED array. It was a relatively expensive, very low resolution way of capturing and displaying video but I thought it was pretty cool to have access to each pixel of the image.

Image

If you look carefully, you can see the work "HI," as seen by the camera in the top left of the photo, displayed on the LED array.

I'm not sure if you'd need to use asembler in to do this on the Pi or if C would be fast enough. The Propeller only has 32K RAM to hold both the code and the image. The large amount of RAM of the RPi would make it much easier to store images than trying to store images on the Propeller.

BTW, I did not learn to use the ADC08100 on my own. I adapted Hano's 4-bit capture code (with more pixels) to an 8-bit version using fewer pixels.

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 8:07 pm

Hey Duane! What a cool project!

I am scaveging for this chip (ADC08100) here on old set top boxes, vhs recorders, but no luck so far...

I was thinking somethig a little more simplist, like and R2R ladder buffer to Rasp Pi GPIO. I Already did something with arduino, like this:

http://embeddednewbie.blogspot.com.br/2 ... tions.html

What do you think?

Thanks
Renato

User avatar
mikronauts
Posts: 2803
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 8:21 pm

Renato,

I like your enthusiasm!

*BUT*

You should research:

- NTSC video timing
- analog sampling rates required to digitize NTSC video
- maximum SPI sample rate achievable on the Pi
- maximum GPIO read rates on the Pi

I could have just said there is no way to do it on the Pi, but where is the fun in that?

If you really want to, you could actually do a "slow scan" low resolution NTSC capture, but it would not be anywhere near full NTSC resolution, nor would it be 60fps.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Duane Degn
Posts: 55
Joined: Thu Jul 10, 2014 6:30 am
Location: Idaho, USA

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 9:29 pm

renato.aloi wrote:Hey Duane! What a cool project!
Thanks Renato. To be honest, I was surprised it worked as well as it did. It was one of my early attempts at writing code in assembly and I was really pleased I was able to PWM the LEDs using a stack of 74HC595 shift registers with 8-bit resolution without causing the image to flicker.

There's some more information about this project in post #1 and post #5 of this thread.
renato.aloi wrote:
I am scaveging for this chip (ADC08100) here on old set top boxes, vhs recorders, but no luck so far...
Dig-Key no longer stocks the ADC08100 but I found them at Mouser for $11.70. You could probably purchase an USB video capture device for the price of a ADC08100 but what fun would that be?
renato.aloi wrote: I was thinking somethig a little more simplist, like and R2R ladder buffer to Rasp Pi GPIO.
Phil Pilgrim was able to capture both black and white NTSC and color NTSC video using a pair of MOSFETs and a few passive components with the Propeller chip.

I don't understand this stuff enough to know if you could do something similar with the Raspberry Pi or not. I'm inclined to think this sort of video capture would require the code be written in assembly but I'm just guessing.

Duane Degn
Posts: 55
Joined: Thu Jul 10, 2014 6:30 am
Location: Idaho, USA

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 9:33 pm

mikronauts wrote: I could have just said there is no way to do it on the Pi, but where is the fun in that?

If you really want to, you could actually do a "slow scan" low resolution NTSC capture, but it would not be anywhere near full NTSC resolution, nor would it be 60fps.
Do you have a guess if the Pi would be able to do this sort of stuff better than the Propeller? The Pi sure has the Prop beat as far as processor speed and RAM.

User avatar
mikronauts
Posts: 2803
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 10:03 pm

In bare metal mode, interrupts off, it should be able to do better than a prop.

If you read all 32 gpio's via dma, hooked up a flash adc, and processed the 32 bits to extract/reshuffle say an 8 bit flash adc's output, it might work OK, but due to required data shuffling, I really don't think it could do real time full rez capture. I wish there were simple byte/word ports available for reading/writing on the Pi!

Adding a $10 usb analog video capture stick should simply work, and work well.
Duane Degn wrote:
mikronauts wrote: I could have just said there is no way to do it on the Pi, but where is the fun in that?

If you really want to, you could actually do a "slow scan" low resolution NTSC capture, but it would not be anywhere near full NTSC resolution, nor would it be 60fps.
Do you have a guess if the Pi would be able to do this sort of stuff better than the Propeller? The Pi sure has the Prop beat as far as processor speed and RAM.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 10:16 pm

Hey mikronauts! Now we're talking! :)
- NTSC video timing
My first idea was outputing VGA so I stepped into this subject. But... let's keep at recording analog for now...

I am trying the most simpliest way to do that; and set a start point from there.

I was studying PAL standard, because here at Brazil, we have the infamous PAL-M:
http://martin.hinner.info/vga/pal.html
and this one:
http://www.intersil.com/content/dam/Int ... an9644.pdf

About keeping up with sync pulses, I found this quite amusing:
http://www.electronixandmore.com/projects/tvtoscope/
and
http://www.seekic.com/circuit_diagram/C ... RATOR.html

The approach I choosed is based on this project, forcing data through FIFO chip:
http://www.techmind.org/vd/mk1/vdescrpt.html
- analog sampling rates required to digitize NTSC video
That is the part I am willing to do! If my idea works,
it must be implemented in two separated drivers/jobs like master/slave fake device...

I am still working on this... What I am trying to do is deal with R2R ladder samples,
buffer some data, check some timming syncronization, calculate some color and brigthness information
and put the frames into some FIFO
(here lies my problem! What must I write to the fifo buffer? At wich format?)
Then other driver/job will read FIFO and do whatever I want (I wish!) hehehe

This idea poped up when I did lay my eyes on the Broadcast approach! Some resource:

http://superuser.com/questions/411897/u ... m-on-linux
and
http://93.93.128.176/forums/viewtopic.p ... 15f96c711b
and
http://www.linux-mag.com/id/406/
- maximum SPI sample rate achievable on the Pi
- maximum GPIO read rates on the Pi
These last two must go to do list. Getting there! hehehe

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Mon Aug 18, 2014 10:39 pm

mikronauts wrote:In bare metal mode, interrupts off, it should be able to do better than a prop.

If you read all 32 gpio's via dma, hooked up a flash adc, and processed the 32 bits to extract/reshuffle say an 8 bit flash adc's output, it might work OK, but due to required data shuffling, I really don't think it could do real time full rez capture. I wish there were simple byte/word ports available for reading/writing on the Pi!

Adding a $10 usb analog video capture stick should simply work, and work well.
Hehehe, I alread did that. I bought this one, with 4 video inputs:
http://produto.mercadolivre.com.br/MLB- ... ox-360-_JM

--------
But don't tell anyone, will spoil the fun! :)
---------

I really don't think it could do real time full rez capture. I wish there were simple byte/word ports available for reading/writing on the Pi!
That's the idea! Low image resolution at low frame rates. I just need a few rough images from the FIFO.... But are you saying Pi has no 16-bit addressing RAM, FIFO, etc?

I am brazilian, sorry if I lost something in the translation.

Thanks
Renato

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Tue Aug 19, 2014 12:56 am

Duane Degn wrote: Phil Pilgrim was able to capture both black and white NTSC and color NTSC video using a pair of MOSFETs and a few passive components with the Propeller chip.

I don't understand this stuff enough to know if you could do something similar with the Raspberry Pi or not. I'm inclined to think this sort of video capture would require the code be written in assembly but I'm just guessing.
Very impressive Phil's work! But this Parallax Propeller is amazing too!

http://en.wikipedia.org/wiki/Parallax_Propeller
http://www.parallax.com/product/28327

It seems to be transparent to Propeller these NTSC and analog video treatments... 80Mhz? Multi core? Too much information. I cant keep up! I will keep up with R2R ladders and C++ device driver programming. That will have to do the trick...

Thanks for sharing your project! I will take a look more carefully, your project is huge too!

User avatar
mikronauts
Posts: 2803
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Analog Cam Recorder Project

Tue Aug 19, 2014 1:18 am

Renato,

Basically, the Pi GPIO was never meant to capture byte and word values, and is an (almost) random selection of bits from a 32 bit port.

This makes life VERY difficult for high speed byte data capture.

The other issue is that the Pi runs Linux, and gets a lot of interrupts.

What you are trying to do is not quite impossible, but very painful.

I think the best you could hope for would be about 160x120 grayscale image at <10fps, and it would be a TON of work.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Tue Aug 19, 2014 1:42 am

What you are trying to do is not quite impossible, but very painful.

I think the best you could hope for would be about 160x120 grayscale image at <10fps, and it would be a TON of work.
Hi @mikronauts

I know I am pushing some boundaries here, but i think is for educational puproses... Somewhere in the middle of this hurricane of pain we find ourselfs some firm ground to establish our own libs for device driving... (?) Feels like a question, perhaps...

Thanks for the brainstorm! I will be back with some results to wonder a go or no-go for this project... Wish me luck! hehehe

Renato

User avatar
mikronauts
Posts: 2803
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Analog Cam Recorder Project

Tue Aug 19, 2014 1:52 am

Hi Renato,

Of course I wish you good luck!

I will be interested to see how far you can get (resoution/fps)... so do update this thread :)

Best Regards,

Bill
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Duane Degn
Posts: 55
Joined: Thu Jul 10, 2014 6:30 am
Location: Idaho, USA

Re: Analog Cam Recorder Project

Tue Aug 19, 2014 3:56 am

renato.aloi wrote:But this Parallax Propeller is amazing too!
Both Bill and myself are fans of the Parallax Propeller.

Bill makes a cool board to make using the Propeller with the Raspberry Pi easier. He has a thread about the board here.

Shipping the board to Brazil might cost prohibitive for you but you could still use his software if you were to add a Propeller to your project.

I have one of Bill's boards I just started putting it together tonight. I'm looking forward to trying out the Raspberry Pi/Propeller combo.

I also wish you good luck and second Bill's request for updates about your project.

User avatar
mikronauts
Posts: 2803
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Analog Cam Recorder Project

Tue Aug 19, 2014 3:28 pm

Thank you for the kind words Duane :-)

I just checked, for the Lite kit (no integrated circuits, but he could source those in Brazil) shipping to Brazil would be about $11 (no insurance or tracking)

For a full kit (with chips) or assembled and tested, cheapest tracked/insured parcel would be surface, at $47

The good news is that it looks like I'll have a DHL account very soon, and if the DHL account rep is right, tracked/insured shipping may get more affordable!
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
mikronauts
Posts: 2803
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Analog Cam Recorder Project

Tue Aug 19, 2014 3:31 pm

I just checked, there is a Digikey for Brazil at:

http://br.digikey.com/

The three chips needed by the RoboPi Lite kit could be sourced there

DIP40 P8X32A
DIP16 MCP3208
DIP8 24LC512
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Fri Aug 22, 2014 9:04 pm

Hey people!

I am back! :) Thanks for checking availability to Brazil! I am getting there!

Well, not soo fast as I wish...

I had some set backs. Let's strip up what I did:

1. Realized that R2R Ladder is for DAC only (one direction)
Problem: That R2R Ladder approach is for digital-to-analog convertion, not the other way around.
Solution: Find some Flash ADC buffer that do the job. I have found LM339 and LM324... Both do same thing, only one (Lm339) has a step function, while the other has operational amplifier ramp.

2. Build a prototipe.
Problem: I made this circuit: http://www.ibiblio.org/kuphaldt/electri ... ocid101883
But only with 4-bit (I have only one LM339!) - Did not work! Sampling is occuring only at one bit
Solution: Amplify RCA signal from 0~1V to 0~5V, delivering better resolution to Flash ADC. Working on it!

I will share some photos with you! Let me grab my Tablet. Posting soon...

Photos
IMG_2014082259425.jpg
Signal to be analyzed, as far we can see at my old 1mhz osciloscope
IMG_2014082259425.jpg (25 KiB) Viewed 8480 times
IMG_2014082224215.jpg
Adc with lm339 first test
IMG_2014082224215.jpg (43.52 KiB) Viewed 8480 times
IMG_2014082216354.jpg
Adc toolkit new version
IMG_2014082216354.jpg (52.88 KiB) Viewed 8480 times

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Sat Aug 23, 2014 7:38 pm

My easycap dc60+ arrived!
IMG_201408234496.jpg
My easycap dc60+
IMG_201408234496.jpg (44.75 KiB) Viewed 8448 times
But.... there is always a perhaps....

As far I realized, kernel compilation is needed and there are 2 version both with some issues... Not so easy as the name suggest.

EDIT1: Found this: https://github.com/ezequielgarcia/stk1160-standalone (deprecated)
and this: http://easycap.blogspot.com.ar/

EDIT2:
lsusb return this: Somagic, Inc. SMI Grabber (EasyCAP DC60+ clone) (no firmware) [SMI-2021CBE]
Now with real device name found much more docs!
http://linuxtv.org/wiki/index.php/Easycap
and
http://www.vivaolinux.com.br/artigo/Dis ... x?pagina=2
and
http://ubuntuforums.org/archive/index.p ... 58478.html

EDIT3: Somagic code repo: https://code.google.com/p/easycap-somagic-linux/

Renato

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Sun Aug 24, 2014 6:01 pm

Hey guys!

Well, when I started this thread, I thought that Composite Video -> USB converter dongle was the solution, but now I am not so sure...

I have found out some things...

- There are 3 kinds of dongles
- Original STK1160 chip
- STK1160 Clone AKA Somagic
- UTV007 (Fushicai)

I found this: http://raspberry-at-home.com/video-grab ... pberry-pi/

The post's autor, Jacek tested the 3 types. For short version, STK1160 Original and Fushicai are viable options, as he mentions, he prefers the STK1160 original.

The Somatic he discarded at first! Now I ask you: What version do you think I bought? Only one chance to figure out!

Yes! I've bought the Somatic clone version! I am f#&%...ormidably in trouble :)

So I've found another material, one called The Not SO EasyCap (As these composite dongles are known):
http://captainbodgit.blogspot.com.br/20 ... linux.html

And the code repo for this project:
https://code.google.com/p/easycap-somagic-linux/

There are 2 hacks at GitHub but they does not working at all!

I 've managed to compile somagic-capture and somagic-init for 3.12 Kernel, at RaspPi. For now I think it is working, but I am using the composite out as visual interface (I dont have an easy HDMI monitor here at lab), so something went wrong when doing the pipeline from somagic-capture to mplayer. It is causing my screen to blank and I am loosing visual interface with the RaspPi. Every time I need to reboot.

I am packing all my lab stuff to come closer to my 50" TV. It is not cool put all this wiring to work at my home bed! But I think it is valid the effort to rule out who is failling here: the easycap dongle, my old TV or myself!

Back soon....

EDIT: Almost forgot! Found 2 amazing bash scripts!

Code: Select all

#!/bin/sh
# somagic-record -- Record video from the Somagic EasyCAP and encode to H.264 format
# Written by Jeffry Johnston, 2012. Released to the public domain.
# First run somagic-init, then run this script as root.
# To end recording: killall x264 (or pkill x264).

# TV standard: ntsc or pal
STANDARD=ntsc

# somagic-capture options:
# S-VIDEO: -s
# CVBS (sharpen): --luminance=2 --lum-aperture=3
# Old sync: --sync=1
SOMAGICOPTS="--sync=1 -s"

# x264 video bitrate in kb/s (adjust for space/quality tradeoff):
BITRATE=2000

# x264 options (adjust for speed/quality tradeoff):
# --preset: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
# --threads auto: Use optimum number of threads 
X264OPTS="--preset=veryfast --threads auto"

# mplayer options:
# Deinterlace: -vf yadif
MPLAYEROPTS="-vf yadif"

# Default video and log file prefix:
NAME="video"

# Shouldn't need to change below
if [ $# -eq 1  ] ; then
  NAME=$1
elif [ $# -ne 0  ] ; then
  echo "Usage: $0 [VIDEO_PREFIX]"
  exit 1
fi
if [ ntsc = "$STANDARD" ] ; then
  FPS="30000/1001"
  TV="-n"
elif [ pal = "$STANDARD" ] ; then
  FPS="25"
  TV=""
else 
  echo "Unknown TV standard: '$STANDARD', must be 'ntsc' or 'pal'."
  exit 1
fi
mkfifo stream.yuv >/dev/null 2>&1
ln -s stream.yuv pipe.y4m >/dev/null 2>&1
x264 $X264OPTS --bitrate "$BITRATE" -o "$NAME.264" pipe.y4m >"$NAME.xlog" 2>&1 &
somagic-capture $TV $SOMAGICOPTS 2>"$NAME.slog" | mplayer -benchmark -nosound -vo yuv4mpeg $MPLAYEROPTS -demuxer rawvideo -rawvideo "$STANDARD:format=uyvy:fps=$FPS" -aspect 4:3 - >"$NAME.mlog" 2>&1 &

Code: Select all

#!/bin/sh

PIPE=/tmp/somagic-pipe
OUTFILEDIR=~/dirs/Videos/
LOGDIR=~/.somagic-log/
NOW=`date +"%m_%d_%Y_%H_%M_%S"`

OUTFILE=${OUTFILEDIR}fpv_video_${NOW}.mp4

mkdir $LOGDIR

FFMPEG_LOG=${LOGDIR}ffmpeg.log
SOMAGIC_LOG=${LOGDIR}somagic.log
MPLAYER_LOG=${LOGDIR}mplayer.log

rm $PIPE >/dev/null 2>&1
rm $OUTFILE >/dev/null 2>&1

rm $FFMPEG_LOG
rm $SOMAGIC_LOG
rm $MPLAYER_LOG

mkfifo $PIPE >/dev/null 2>&1


ffmpeg -loglevel panic -f rawvideo -pixel_format uyvy422 -video_size 720x576 -framerate 25 -i $PIPE -vcodec libx264 -preset ultrafast $OUTFILE > $FFMPEG_LOG 2>&1 &

somagic-capture 2> $SOMAGIC_LOG | tee $PIPE | \
mplayer -nosound -vo xv -vf yadif,screenshot -demuxer rawvideo -rawvideo pal:format=uyvy:fps=25 -vf crop=720:430:0:65 -monitoraspect 16:9 -aspect 4:3 -fs - 2> $MPLAYER_LOG

rm $PIPE >/dev/null 2>&1

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Mon Aug 25, 2014 12:12 am

IMG_2014082458777.jpg
Command window
IMG_2014082458777.jpg (55.27 KiB) Viewed 8397 times
IMG_2014082447702.jpg
Results on hdmi tv
IMG_2014082447702.jpg (34 KiB) Viewed 8397 times
IMG_2014082430457.jpg
Results on composite output
IMG_2014082430457.jpg (44.49 KiB) Viewed 8397 times

User avatar
renato.aloi
Posts: 26
Joined: Mon Aug 18, 2014 12:56 am

Re: Analog Cam Recorder Project

Mon Aug 25, 2014 1:23 am

What I have done so far..

My device: Somagic, Inc. SMI Grabber (EasyCAP DC60+ clone) (no firmware) [SMI-2021CBE]

1. SD card free space adjustment

Code: Select all

sudo raspi-config
2. Upgrade of all pending update requests

Code: Select all

sudo apt-get upgrade
3. Libusb and libgcrypt headers download (mplayer and usbutils already last version, ok!)

Code: Select all

sudo apt-get install libusb-1.0-0-dev libgcrypt11-dev
4. easycap-somagic-linux source download

Code: Select all

wget https://easycap-somagic-linux.googlecode.com/files/somagic-easycap_1.1.tar.gz
5. easycap-somagic-linux source unpacking

Code: Select all

tar xvf somagic-easycap_1.1.tar.gz
6. source code compiling and installing

Code: Select all

cd ~/somagic-easycap_1.1
sudo make
sudo make install
(at this point we should have somagic-init and somagic-extract-firmware properly installed on /usr/local/sbin)

7. somagic-easycap-tools source download

Code: Select all

wget https://easycap-somagic-linux.googlecode.com/files/somagic-easycap-tools_1.1.tar.gz
8. somagic-easycap-tools source unpacking

Code: Select all

tar xvf somagic-easycap-tools_1.1.tar.gz
9. tools source code compiling and installing

Code: Select all

cd ~/somagic-easycap-tools_1.1
sudo make
sudo make install
(now we should have somagic-capture working)

10. driver build (documentation mentions parameter 1.1, but 1.2 seems to work)

Code: Select all

git clone https://code.google.com/p/easycap-somagic-linux/
cd ~/easycap-somagic-linux
sudo ./build_packages 1.2 
11. firmware extraction - Sys file download

Code: Select all

wget http://www.seriallink.com.br/util/SmiUsbGrabber3F.sys
(i will publish it at my site, otherwise you should do this using wine - you must have installation CD-ROM)

EDIT: SmiUsbGrabber3F.sys File Published Already!

12. firmware extraction - by somagic utility

Code: Select all

sudo somagic-extract-firmware SmiUsbGrabber.sys
(the command above must create /lib/firmware/somagic_firmware.bin file)

13. Pluging-in the device

Code: Select all

sudo somagic-init
sudo somagic-capture -i 1 -pal | mplayer -nosound -vo x11 -vf yadif,screenshot -demuxer rawvideo -rawvideo "pal:format=uyvy:fps=25" -vf scale=320:240 -aspect 4:3
Until now I've got those crapy images you can see at my last post... Now I am compiling ffmpeg for about 2 hours now...

More upcoming later...

EDIT: ffmpeg took 4 hours to build at my rasp pi!

EDIT2: resources about ffmpeg build
http://sirlagz.net/2012/08/04/how-to-st ... pberry-pi/
and
https://ffmpeg.org/download.html
and
http://www.raspberrypi.org/forums/viewt ... 67&t=47472

Return to “Graphics, sound and multimedia”