Differences between revisions 7 and 8
Revision 7 as of 2008-12-06 04:19:41
Size: 3134
Editor: AURORA
Comment:
Revision 8 as of 2008-12-06 04:28:11
Size: 3999
Editor: AURORA
Comment:
Deletions are marked like this. Additions are marked like this.
Line 25: Line 25:
   . ffmpeg -f oss -ar 48000 -ac 2 -i /dev/dsp1 -deinterlace -b 10000k -pix_fmt yuv422p -s 640x480 -r 30 -f rawvideo -i ${HOME}/vpipe -vcodec mpeg2video -acodec libmp3lame -y ch42.mpg    . ffmpeg -f oss -ar 48000 -ac 2 -i /dev/dsp1 -deinterlace -b 10000k -pix_fmt yuv422p -s 640x480 -r 30 -f rawvideo -i vpipe -vcodec mpeg2video -acodec libmp3lame -y ch42.mpg
Line 32: Line 32:
 . The "-f oss -ar 48000 -ac2 -i /dev/dsp1" sequence specifies the audio properties--it tells ffmpeg to capture from /dev/dsp1 using an OSS interface, and to use a bit rate of 48KHz with 2 channels (stereo).
 . The "-deinterlace" option tells ffmpeg to compensate for motion artifacts caused by analog video broadcast interlacing--this is not strictly necessary
 . the "-b 10000k" option tells ffmpeg to encode the video at a bitrate of 10000kbps--I've found that anything over ~4000k yields generally high quality, while anything significantly lower will produce a noticeably blocky video.
  * The "-f oss -ar 48000 -ac2 -i /dev/dsp1" sequence specifies the audio properties--it tells ffmpeg to capture from /dev/dsp1 using an OSS interface, and to use a bit rate of 48KHz with 2 channels (stereo).
  * The "-deinterlace" option tells ffmpeg to compensate for motion artifacts caused by analog video broadcast interlacing--this is not strictly necessary
  * The "-b 10000k" option tells ffmpeg to encode the video at a bitrate of 10000kbps--I've found that anything over ~4000k yields generally high quality, while anything significantly lower will produce a noticeably blocky video.
  * The "-pix_fmt yuv422p" option tells ffmpeg that each incoming frame is in the planar YUV422 pixel format--this is the format that the cx88 app currently specifies to the driver. Future version may support an pixel format option, using the -o switch.
  * The "-s 640x480 -r 30" sequence tells ffmpeg that the incoming video has a resolution of 640x480 pixels with a frame rate of 30 fps. This is compatible with the NTSC video system; for PAL/SECAM, you would probably want to use "-s 768x576 -r 25"
 * The "-f rawvideo -i vpipe" sequence tells ffmpeg that the incoming video consists of raw pixel frames, originating from a file named "vpipe"
 * The "-vcodec mpeg2video -acodec libmp3lame" tells ffmpeg to use the MPEG-2 format with mp3 audio when encoding the mpeg file.
 * "-y ch42.mpg" tells ffmpeg to store the encoded mpeg video in a file named ch42.mpg

Capture App Examples

Tune to channel 4 in the default profile and send MPEG transport stream to VLC at port 8802 and to a file at ~/out.m2t:

  • Shell 1:
    • vlc udp://@127.0.0.1:8802
    Shell 2:
    • cx88 -d /dev/cx88mpeg0 -u udp://localhost:8802 -u file://${HOME}/out.m2t -x /usr/local/share/examples/cx88/cx88.xml.sample -c 4

Tune to channel 45 in the DVBT_EU_UHF profile, send MPEG transport stream to /home/user/out.m2t in current directory, and automatically terminate capture after 28.7 minutes:

  • cx88 -d /dev/cx88mpeg0 -u udp://localhost:8802 -u file:///home/user/out.m2t -x /usr/local/share/examples/cx88/cx88.xml.sample -c DVBT_EU_UHF:45 -n 28.7

Capture audio only from channel 42 in the USA profile and send to sound card at /dev/dsp0:

  • cx88 -d /dev/cx88audio0 -u oss:///dev/dsp0 -x /usr/local/share/examples/cx88/cx88.xml.sample -c USA:42

Capture audio only from channel 42 in the USA profile and use a third-party app to handle the actual playback:

  • cx88 -d /dev/cx88audio0 -x /usr/local/share/examples/cx88/cx88.xml.sample -c USA:42

Capturing Raw Video

The best way I've found to capture raw video (e.g. from an analog TV station) is to use a named pipe to send the video frames to ffmpeg for encoding to an mpeg file. Future version of cx88 may have a live capture facility that can display the raw pixels directly to the screen (e.g. using SDL). The output from ffmpeg may also be piped into a player such as VLC for live viewing, but this is rather inefficient.

  • Capture video and audio from channel 42 in the USA profile and send to ffmpeg for encoding via a named pipe:
    • Shell 1:
      • mkfifo vpipe
      • ffmpeg -f oss -ar 48000 -ac 2 -i /dev/dsp1 -deinterlace -b 10000k -pix_fmt yuv422p -s 640x480 -r 30 -f rawvideo -i vpipe -vcodec mpeg2video -acodec libmp3lame -y ch42.mpg
      Shell 2:
      • cx88 -c 42 -d /dev/cx88video0 -u file://${PWD}/vpipe -d /dev/cx88audio0 -x /usr/local/share/examples/cx88/cx88.xml.sample

As in the above example, ffmpeg can be used to multiplex the audio and video output. The ffmpeg command above uses the OSS-compatible cx88 audio interface, and assumes that /dev/dsp1 is the OSS audio device that corresponds to cx88audio0. It also assumes that cx88video0 and cx88audio0 are the video and audio functions of the same capture card. Note that in the cx88 command, only the video data is sent to the named pipe.

  • ffmpeg can be a little daunting, so let's dissect the ffmpeg command:
    • The "-f oss -ar 48000 -ac2 -i /dev/dsp1" sequence specifies the audio properties--it tells ffmpeg to capture from /dev/dsp1 using an OSS interface, and to use a bit rate of 48KHz with 2 channels (stereo).
    • The "-deinterlace" option tells ffmpeg to compensate for motion artifacts caused by analog video broadcast interlacing--this is not strictly necessary
    • The "-b 10000k" option tells ffmpeg to encode the video at a bitrate of 10000kbps--I've found that anything over ~4000k yields generally high quality, while anything significantly lower will produce a noticeably blocky video.
    • The "-pix_fmt yuv422p" option tells ffmpeg that each incoming frame is in the planar YUV422 pixel format--this is the format that the cx88 app currently specifies to the driver. Future version may support an pixel format option, using the -o switch.
    • The "-s 640x480 -r 30" sequence tells ffmpeg that the incoming video has a resolution of 640x480 pixels with a frame rate of 30 fps. This is compatible with the NTSC video system; for PAL/SECAM, you would probably want to use "-s 768x576 -r 25"
  • The "-f rawvideo -i vpipe" sequence tells ffmpeg that the incoming video consists of raw pixel frames, originating from a file named "vpipe"
  • The "-vcodec mpeg2video -acodec libmp3lame" tells ffmpeg to use the MPEG-2 format with mp3 audio when encoding the mpeg file.
  • "-y ch42.mpg" tells ffmpeg to store the encoded mpeg video in a file named ch42.mpg

Overview/TipsAndTricks (last edited 2011-11-08 21:24:50 by jason)