Skip to content

Instantly share code, notes, and snippets.

@Technicus
Last active October 25, 2015 07:29
Show Gist options
  • Save Technicus/a923e0f6d60e42b40609 to your computer and use it in GitHub Desktop.
Save Technicus/a923e0f6d60e42b40609 to your computer and use it in GitHub Desktop.
#! /bin/bash
######## working solution ########
ffmpeg -f video4linux2 -y -input_format mjpeg -framerate 25 -video_size 640x480 -i /dev/video0 ./out.mpeg &
sleep 2
mplayer -fs ./out.mpeg
######## System Information ########
# $ ffmpeg -f video4linux2 -list_formats all -i /dev/video0
# ffmpeg version 2.8.1 Copyright (c) 2000-2015 the FFmpeg developers
# built with gcc 5.2.0 (GCC)
# configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab --host-cflags='"-fPIC"'
# libavutil 54. 31.100 / 54. 31.100
# libavcodec 56. 60.100 / 56. 60.100
# libavformat 56. 40.101 / 56. 40.101
# libavdevice 56. 4.100 / 56. 4.100
# libavfilter 5. 40.101 / 5. 40.101
# libavresample 2. 1. 0 / 2. 1. 0
# libswscale 3. 1.101 / 3. 1.101
# libswresample 1. 2.101 / 1. 2.101
# libpostproc 53. 3.100 / 53. 3.100
# [video4linux2,v4l2 @ 0x54e2bdf0] Compressed: mjpeg : MJPEG : 640x480 1280x1024 1280x960 1600x1200 2048x1536 2592x1944 640x480
# /dev/video0: Immediate exit requested
# $ lsusb
#
# Bus 001 Device 007: ID 090c:f37d Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Endoscope camera
# Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
# Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
# Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
# Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
######## nothing below this comment worked ########
# mplayer ./out.mpeg &
# ffmpeg -f video4linux2 -input_format mjpeg -framerate 25 -video_size 640x480 -i /dev/video0 ./out.mpeg -f video4linux2 -input_format mjpeg -framerate 25 -video_size 640x480 -i /dev/video0 ./videoPipe.mpeg
#-f matroska - | ffplay -
# ffplay ./out.mpeg
#ffplay -f video4linux2 -framerate 25 -video_size 640x480 ./out.mpeg
# ffmpeg -f video4linux2 -input_format mjpeg -framerate 25 -video_size 640x480 -i /dev/video0 ./out.mpeg ./videoPipe.mpeg | ffplay -f video4linux2 -framerate 25 -video_size 640x480 ./videoPipe.mpeg
# (ffplay spam 2> /dev/null &) ; capture /dev/stdout | ffmpeg -f video4linux2 -y -input_format mjpeg -framerate 25 -video_size 640x480 -i /dev/video0 ./out.mpeg - spam
#ffplay -f video4linux2 -framerate 30 -video_size 640x480 /dev/video0
#ffmpeg -f video4linux2 -y -input_format mjpeg -framerate 25 -video_size 640x480 -i /dev/video0 ./out.mpeg -f mpegts - | ffplay -analyzeduration 10 -f mpegts -
#ffmpeg -f video4linux2 -y -input_format mjpeg -framerate 25 -video_size 640x480 -i /dev/video0 ./out.mpeg -f mpegts - | mplayer -analyzeduration 10 -f mpegts -
# Adjusting camera functions
#
# Brightness, zoom, focus, etc, can be adjusted with v4l2-ctl. Display all controls and their menus:
#
# v4l2-ctl -L
# Then adjust the value:
#
# v4l2-ctl -c <option>=<value>
Bus 001 Device 005: ID 090c:f37d Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Endoscope camera
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
#! /bin/bash
mplayer -tv driver=v4l2:gain=1:width=640:height=480:device=/dev/video0:fps=10:outfmt=rgb16 tv://
./mplayerUSB.sh
MPlayer SVN-r37379 (C) 2000-2015 MPlayer Team
210 audio & 441 video codecs
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing tv://.
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <[email protected]>
comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: SMI
Capabilities: video capture streaming
supported norms:
inputs: 0 = Camera 1;
Current input: 0
Current format: MJPEG
==================================================================
WARNING: UNTESTED OR UNKNOWN OUTPUT IMAGE FORMAT REQUESTED (0x52474210)
This may cause buggy playback or program crash! Bug reports will
be ignored! You should try again with YV12 (which is the default
colorspace) and read the documentation!
==================================================================
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Inappropriate ioctl for device
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
Unable to set gain control!
Could not find a UTF-8 locale,
character keys beyond Latin-1 will not be handled.
Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
[vdpau] Error when calling vdp_device_create_x11: 1
[VO_XV] It seems there is no Xvideo support for your video card available.
[VO_XV] Run 'xvinfo' to verify its Xv support and read
[VO_XV] DOCS/HTML/en/video.html#xv!
[VO_XV] See 'mplayer -vo help' for other (non-xv) video out drivers.
[VO_XV] Try -vo x11.
v4l2: select timeout
MPlayer interrupted by signal 2 in module: preinit_libvo
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 56.26.100 (internal)
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG)
==========================================================================
Audio: no sound
Starting playback...
[mjpeg @ 0xb4aae8]No JPEG data found in image
Error while decoding frame!
[mjpeg @ 0xb4aae8]ignoring invalid SAR: 0/0
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
Movie-Aspect is undefined - no prescaling applied.
[swscaler @ 0xc510b8]bicubic scaler, from yuv422p to rgb565le using C
[swscaler @ 0xc510b8]No accelerated colorspace conversion found from yuv422p to rgb565le.
[swscaler @ 0xc510b8]using unscaled yuv422p -> rgb565le special converter
VO: [x11] 640x480 => 640x480 BGR 16-bit
[swscaler @ 0xc510b8]full chroma interpolation for destination format 'rgb565le' not yet implemented
Movie-Aspect is undefined - no prescaling applied.
[swscaler @ 0xc510b8]No accelerated colorspace conversion found from yuv422p to rgb565le.
VO: [x11] 640x480 => 640x480 BGR 16-bit
[swscaler @ 0xc510b8]full chroma interpolation for destination format 'rgb565le' not yet implemented
V: 0.0 2/ 2 ??% ??% ??,?% 0 0
v4l2: ioctl set mute failed: Invalid argument
v4l2: 4 frames successfully processed, 0 frames dropped.
Exiting... (Quit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment