LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-04-2014, 10:27 AM   #1
MattHabermehl
LQ Newbie
 
Registered: Feb 2014
Posts: 2

Rep: Reputation: Disabled
Adjusting v4l2 settings after launching mplayer to framebuffer in console?


Hi All,
First time poster, long-time fan.
I'm using a raspberry pi (debian flavour) with a USB webcam. The most effective way to display the video from the webcam is to launch mplayer directly from the console (no xwindows).
This is relatively simple:
Code:
mplayer -tv driver=v4l2:device=/dev/video0 tv://
However, the default settings mplayer uses for the webcam are terrible. Brightness, contrast and saturation all need heavy adjustments. I can set these in V4L2 using commands like this:
Code:
v4l2-ctl --set-ctrl brightness=134
However, mplayer seems to reset the V4L2 values every time it launches, erasing the modifications I made through the v4l2-ctl command.

Using the the Pi's default graphical interface environment, I have determined that it is possible to change the V4L2 values while mplayer is running, and I get the result that I want.

However, this is where I need help: when running mplayer from the command line, and outputting the video to the framebuffer, I'm not sure how I would be able to run those V4L2 commands while A) mplayer is occupying the terminal such that no other commands may be entered, and B) the full screen is occupied by the framebuffer video.

I tried a couple different strategies of bash script, and I tried the "screen" program. Neither seemed to do what I hoped. However, I'm a relative novice at both. Would someone be able to point me in the direction of some Linux magic that would help me to accomplish what I need to do?

Thanks so much,
Matt

Last edited by MattHabermehl; 02-04-2014 at 02:26 PM. Reason: solved
 
Old 02-04-2014, 02:24 PM   #2
MattHabermehl
LQ Newbie
 
Registered: Feb 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Smile [solved] Adjusting v4l2 settings after launching mplayer to framebuffer in console?

Haha!
For anyone else looking to do this (in my Google adventure prior to posting this question, I appeared not to be the only one):

mplayer can be set into a slave mode where you can feed it more commands. Among those commands is the "run" command which can run a terminal command enclosed in quotation marks. You can also direct commands into mplayer from a file. Combined, these two features lead to a solution:

create a file with the mplayer commands you wish to give. My file is called "v4l-mplayer-settings". The file consists of the following:
Code:
run "v4l2-ctl --set-ctrl brightness=134"
run "v4l2-ctl --set-ctrl contrast=43"
run "v4l2-ctl --set-ctrl saturation=38"
Then I run this command in the terminal (or from a bash script):
Code:
mplayer -vo sdl:driver=fbcon -slave -quiet -input file=v4l-mplayer-settings -tv driver=v4l2:device=/dev/video0 tv://
the -vo flag and the following sdl:driver=fbcon may be particular to my system, as a lot of people suggest using fbdev instead of fbcon. This sends your video to the framebuffer. It may be optional to set this if you are running the mplayer command from the console without any x software running.

-slave puts mplayer in slave mode to accept commands
-quiet is meant to provide you an mplayer-specific command line where you can feed mplayer commands via the keyboard. I'm not sure if it's required if you use -input file. However, it doesn't hurt.
-input file= is where I direct mplayer to use the commands I included in the above v4l-mplayer-settings file.
-tv indicates that we are setting properties for the tv device, using video for linux 2 (which is what I need to use to access my webcam), and the device at /dev/video0 (which is the video device of my webcam - your system may be different.
Finally, tv:// just directs mplayer to invoke its TV viewer system.

Last edited by MattHabermehl; 02-04-2014 at 02:25 PM. Reason: solved
 
Old 10-09-2014, 04:49 AM   #3
ikletti
LQ Newbie
 
Registered: Aug 2003
Distribution: Debian woody + KDE 3.1
Posts: 9

Rep: Reputation: 0
After hours of fiddling with a Raspberry Pi, different webcams and infinite repetitions of "google / trial / error", I finally found this post. Your solution works for me. Thank you very, very much.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Grub2/console-setup commands for console mode 132 x 43 without framebuffer LQ123 Debian 0 10-22-2013 09:44 AM
V4L2 / FrameBuffer LCD device drivers? knb Linux - Kernel 0 07-17-2009 10:59 PM
Adjusting Keyboard and Mouse Settings RJEmery SUSE / openSUSE 2 03-27-2006 06:36 PM
Framebuffer console settings n3tw0rk Linux - General 8 01-24-2004 11:27 AM
adjusting monitor settings iceman47 Linux - Software 0 03-19-2003 03:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration