Camera Preview via Ffplay

Source: Internet
Author: User

Camera Preview via Ffplay

Hardware platform: Jetson TK1 Development Board (NVIDIA Tegra K1 Mobile Processor 32bit), Ningbo Sunny-yu photoelectric sp103a (OV16825) module
Software platform: Ubuntu/linaro 4.8.2-16ubuntu4 (Linux version 3.10.40 32bit)

The camera driver has been implemented to support the V4L2 interface.

First install the SDL library, the first time through the source code installation of the SDL-1.2.14 version, when used always prompts the SDL initialization failed. The second time first enter the command "sudo apt-get remove Libsdl1.2debian", "sudo apt-get install Libsdl1.2-dev", and then the source code installation SDL-1.2.15 problem solved.

Then install the x264, the steps are relatively simple
$git Clone Git://git.videolan.org/x264.git
$CD x264
$./configure
$make
$sudo make Install

Finally install FFmpeg, download the latest version of the official website via git, the current version is version 2.8, through configure--enable-memalign-hack--enable-static,make, sudo make Install the installation is ready.

Our driver output is sensor raw data, for Bayer RAW10 format, each color occupies 16bit, only low 10 bits is valid data, order for BGGR. FFmpeg The original code is not supported RAW10, need to make certain changes. The original code supports Bayer Raw8 and Bayer Raw16, because Bayer Raw10 and Bayer Raw16 are all taking up two bytes, so we refer to Bay RAW16 for modifications. First, add an item in the ff_fmt_conversion_table of LIBAVDEVICE/V4L2-COMMON.C, here we borrow the RAW16 format directly, in the application appears RAW10 as RAW16 processing, Use V4L2_PIX_FMT_SBGGR10 when the V4l2 interface is called.

{av_pix_fmt_bayer_bggr16le, Av_codec_id_rawvideo, V4l2_pix_fmt_sbggr10},

For RAW16, the current code in LIBSWSCALE/BAYER_TEMPLATE.C Bayer_shift is set to 8, indicating that the low 8 bits are discarded directly, because RAW10 can only discard the lower 2 bits, so we set the Bayer_shift to 2.

For ease of debugging, you can change the libavutil/log.c av_log_level from Av_log_info to av_log_trace and output more information.

After you have done the above changes, recompile, install FFmpeg, and then use the command "Ffplay-f v4l2-input_format bayer_bggr16le-video_size 4608x3456-i/dev/video0" To achieve the preview, If you are still prompted to fail SDL initialization, you can enter the display=:0 and export display commands in the shell to set display.

Camera Preview via Ffplay

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.