library for Maxim MG1264 Crusher hardware H.264 encoder (beta) updated 11.05.2010

 

Project moved to http://code.google.com/p/crusher264/

 

 

This is a home page of crusher264 library, based on the reverse-engineered turbo.264/RDX-160-EF Crusher and CrusherCapture H264 Encoder stick. It created to implement linux driver for Maxim's MG1264/MG3500 chips.

Hardware:

Encoder-mode features:

  1. H264 Baseline profile (I & P frames only).
  2. Bitrate, framerate, width, height regulation.
  3. Gop size set.
  4. RC buffer size set.
  5. Deblocking filter flag (+alpha & beta values).
  6. Flag to create new gop on scene change.
  7. Real-time (or faster) conversion up to 640x480.
  8. Max image dimensions: 768x576.

Capture-mode features:

  1. H264 Baseline profile (I & P frames only).
  2. Bitrate, framerate, width, height regulation.
  3. Due lack of deinterlacing, image width can be 288px max (with proper aspect ratio settings), that's what "blackmagic design" guys calls full 720x576.
  4. AAC Audio capture with fixed samplerate 48kHz (may be other, when set proper clock).

 

News:

NEWS 2010-11-05:

  • Added environment variable "CRUSHER_DEV" that tells library what device number to use.
  • Added new application cruserRTMP, that capable to publish CrusherCapture stream to RTMP servers or dump it to flv file.

NEWS 2010-16-04:

  • Now library sends USB-reset to device when it stucked (or does not reply).
  • FFmpeg patch updated (add native nv12 support to encoder).

NEWS 2010-28-03:

  • Add raw-pcm output from CrusherCapture as wave file.
  • Move qbox parser to user-space.
  • added usb reset when i/o failed.
  • updated ffmpeg-patch (added: qbox demuxer, crushercap-device, updated libcrusher264-encoder).

NEWS 2010-15-03:

  • CrusherCapture support added (AAC audio capure supported too).
  • added usb reset after encoding finished (fixed hot-starting bug).

NEWS 2009-27-10:

  • previous code fully rewritten and publically released as crusher264
  • patch for ffmpeg added

 

Downloads:

crusher264-1.1.1.tar.gz (older files)

ffmpeg-patch (for latest ffmpeg from git)

Installation:

$ tar -xvzf  crusher264-1.1.1.tar.gz
$ cd crusher264-1.1.1
$ wget http://tipok.org.ua/downloads/hardware/crusher264/firmware/firmware.tar.gz
$ tar -xvzf firmware.tar.gz
$ ./configure
$ make
$ sudo make install

 

To use this library without root-priveleges:

Udev rules have to be updated. Add to /etc/udev/rules.d directory file 50-udev-default.rules that contain this strings:

# libusb device nodes
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0666"

FFmpeg patching:

(after installing crusher264)

$ git clone git://git.ffmpeg.org/ffmpeg/
$ cd ffmpeg
$ git clone git://git.ffmpeg.org/libswscale/
$ wget http://tipok.org.ua/downloads/hardware/crusher264/patch/libcrusher264-16042010.ffmpeg-git.patch
$ patch -p1 < libcrusher264-28032010.ffmpeg-git.patch
$ ./configure --enable-gpl --enable-libcrusher264
$ make
$ sudo make install

 

Encoder usage:

Here we using patched ffmpeg for encode:

$ ffmpeg -loglevel debug -async 1 -flags +loop -i input.ts \
> -f flv -vcodec libcrusher264 -deinterlace -g 25 -r 25 -sc_threshold 1 -b 500k -s 320x240 \
> -acodec aac -ab 64k -ac 1 -ar 44100 -y test.flv

$ ffmpeg -flags +loop -i test.mpg -f mpegts -vcodec libcrusher264 -an -deinterlace -g 25 -sc_threshold 1 -b 600k -s 640x480 -y test.ts
$ ffmpeg -async 1 -flags +loop -i udp://239.102.1.2:5004 -f mpegts -vcodec libcrusher264 -acodec mp2 -ab 128k -deinterlace -g 25 \
> -sc_threshold 1 -b 500k -s 320x240 -y test.ts

Or use stand-alone application to encode uncompressed raw video (but first create it):

$ ffmpeg -i test.mpg -f rawvideo -an -deinterlace -s 720x576 -pix_fmt yuv420p -y test720x576.yuv
$ sample/crusher264 -i test720x576.yuv -s 720x576 -b 1500000 -o test.h264

 

Capture usage:

(new) Here is sample to capture from CrusherCapture (Blackmagic Video Recorder):

Capture from component-video input, with 352x288 image size and bitrate 300Kbps, also 1-channel audio captured with 48 kHz and bitrate 64Kbps to file, named "test.h264.aac":

$ sample/crusher264 -i 2 -s 352x288 -b 300000 -a 64000 -c 1 -o test.h264

Capture from composite-video input, with 640x480 image size and bitrate 1500Kbps, also 2-channels audio captured with 48 kHz and bitrate 128Kbps to "qbox" file, that playable by patched ffmpeg:

$ sample/crusher264 -i 0 -s 640x480 -b 1500000 -a 128000 -c 2 -f qbox -o test.qbox

Publishing CrusherCapture stream to rtmp-server and saving audio-video to dump.flv. Stream parameters set to: composite-video input, with 320x240 image size and bitrate 300Kbps, also 2-channel audio captured with 48 kHz and bitrate 64Kbps. Publishing works only if librtmp with headers installed.

$ sample/crusherRTMP -i 0 -s 320x240 -b 300000 -a 64000 -f dump.flv rtmp://example.com/live/flv:livestream.flv

This samples for patched ffmpeg. Additional parameters, such as bitrates, audio-codec, device-number given by "-i" parameter:

$ ffmpeg -flags +global_header -v 10 -loglevel debug -ac 2 -s 640x480 -f crushercap \
> -i devnum=0:bitrate=1800000:ab=128000:acodec=aac \
> -f mp4  -vcodec copy -acodec copy -y test.mp4
$ ffmpeg -flags +global_header -v 10 -loglevel debug -ac 1 -s 320x240 -f crushercap \
> -i devnum=0:bitrate=300000:ab=64000:acodec=aac \
> -f flv -vcodec copy -acodec copy -y test.flv

TODO:

  1. Support different samplerates (not only 48kHz), because flash-players don't like this sr.
  2. Check NTSC support (it works in encoder-mode, but may not work on capture-mode).
  3. Fix bug with codec hot-starting. (done)
  4. Add SPS/PPS extradata extraction to ffmpeg patch (this needs to creating mp4 files). (done)
  5. Add CrusherCapture support (Blackmagic Video recorder).  (done)
  6. Add MG3500 (H.264 HD Encoder) Support.
  7. Move some parts of code into v4l driver.
  8. Add i2c functionality. (done)
  9. Add encoding (not only capture) functionality to Blackmagic device.

  More Info:

Crusher reference design consists from this IC's:

 

CrusherHD reference design:

  • USB-controller: Cypress EZ2 (CY7C68013A-56LFXC)
  • Encoder: Maxim MG3500
  • RAM: 2xDDR2 ProMOS V59C1512164QCF3 (total: 128Mb).
  • unknown i2c EEPROM ATMLH936 (maybe AT93C66), but only 2 wires used
  • clock generator? 99Ti 7C (i2c)