Camera preview using ffplay

Source: Internet
Author: User

Camera preview using ffplay

Hardware Platform: Jetson TK1 Development Board (NVIDIA Tegra K1 Mobile Processor 32bit), Ningbo shunyu photoelectric SP103A (OV16825) Module
Software Platform: Ubuntu/Linaro 4.8.2-16ubuntu4 (Linux version 3.10.40 32bit)

The camera driver has been implemented and supports v4l2 interfaces.

First install the SDL library, the first SDL-1.2.14 version installed through source code, always prompts SDL initialization failure when used. For the second time, enter the command "sudo apt-get remove libsdl1.2debian", "sudo apt-get install libsdl1.2-dev", and then solve the problem by installing the SDL-1.2.15 through the source code.

Install x264. The procedure is simple.
$ Git clone git: // git.videolan.org/x264.git
$ Cd x264
$./Configure
$ Make
$ Sudo make install

Install ffmpeg and download the latest version from the official website through git. The current version is version 2.8. Use configure -- enable-memalign-hack -- enable-static, make, install sudo make install.

Our driver outputs raw sensor data in the bayer raw10 format. Each color occupies 16 bits, and only 10 bits are valid data in the order of bggr. The original ffmpeg Code does not support raw10 and must be modified. The original code supports bayer raw8 and bayer raw16, because both bayer raw10 and bayer raw16 occupy two bytes, so we can refer to bay raw16 for modification. First, add an item in ff_fmt_conversion_table in libavdevice/v4l2-common.c. Here we borrow raw16 format directly. In the application, raw10 is processed as raw16, and V4L2_PIX_FMT_SBGGR10 is used in the v4l2 interface call.

{AV_PIX_FMT_BAYER_BGGR16LE, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SBGGR10 },

For raw16, the current Code sets BAYER_SHIFT to 8 in libswscale/bayer_template.c, indicating that the 8-bit low is discarded directly, because raw10 can only discard the 2-bit low, so we set BAYER_SHIFT to 2.

For debugging convenience, you can change av_log_level in libavutil/log. c from AV_LOG_INFO to AV_LOG_TRACE to output more information.

After completing the preceding modification, re-compile, install ffmpeg, and run the "ffplay-f v4l2-input_format bayer_bggr16le-video_size 4608x3456-I/dev/video0" command to preview, if you still prompt that SDL initialization fails, enter the DISPLAY =: 0 and export DISPLAY commands in the shell to set DISPLAY.

This article permanently updates the link address:

Related Article

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.