ivtv(3pm)
π ivtv β the Video::ivtv era π
okay bestie, so this is a page from the User Contributed Perl Documentation collection, and the module it's all about is Video::ivtv β a Perl extension for using V4l2 in the ivtv perl scripts. pull up a chair, we're doing ioctls π
β¨ NAME β¨
Video::ivtv β literally a Perl extension for using V4l2 in the ivtv perl scripts. that's the whole vibe. π
πΈ SYNOPSIS πΈ
here's how you actually use it, no cap:
use Video::ivtv;
open(my $tuner, "</dev/video0") or die "Error opening /dev/video0! $!";
my $tunerFD = fileno($tuner); # the C functions need the file handle #.
# initialize the Video::ivtv module
my $ivtvObj = Video::ivtv->new();
# get the current resolution
my ($width, $height) = $ivtvObj->getResolution($tunerFD);
# set the new resolution
$ivtvObj->setResolution($tunerFD, 640, 480);
close($tuner);
see how the C functions need the file handle number? that's the fileno($tuner) moment, and it matters, bestie. π«Ά
π¦ DESCRIPTION π¦
so the Video::ivtv module is here to hand you helper methods for working with videodev2.h structures and for making ioctl calls that have proven to be too difficult to create pack strings for in perl itself. it's giving "we tried, we cried, we wrote a module." π
and listen β this is not supposed to be an equivalent of the Video::Capture::V4l module, which was created for videodev.h. different era, different header, different girlies. don't mix them up. β
π EXPORT π
All functions and the variables section. yes, the whole thing. take it all, it's yours. π
π VARIABLES π
%codecIndexesβ this contains the index names and their position in theivtv_ioctl_codecstructure, as returned bygetCodecInfo()and as expected bysetCodecInfo(). it's the map, iykyk. πΊοΈ%capIndexesβ this contains the index names and their position in thev4l2_capabilitystructure, as returned bygetCapabilities(). π§
π₯ FUNCTIONS π₯
the main characters. all of them. periodt.
@(driver, card, bus_info, version, capabilities) getCapabilities(fd)β returns the contents of thev4l2_capabilitystructure. and if the ioctl fails? you get an empty list back. no drama, just nothing. π@(width,height) getResolution(fd)β pass in the file handle number usingfileno($fd)and the width and height are returned in an array ref. if an error shows up in the ioctl call, then width and height will =-1. πint setResolution(fd, width, height)β specify the new width, height to set the capture to.- Returns
undefif invalid resolution is specified. - Returns a
1if sucess,0if error from the actual code.
- Returns
int getStandard(fd)β returns the current video standard the card is using. β¨int setStandard(fd, standard)β sets the video standard to what is specified (hex value). returns1on success,0on error.@(index, id, name, frameperiod_numerator, frameperiod_denominator, framelines) enumerateStandard(fd, index)β returns the contents of thev4l2_standardstructure for the specified index. if the ioctl fails thenindex = -1. π¦int getFrequency(fd, tuner)β returns the current frequency for the specified tuner, or-1if an ioctl error occured. returnsundefon invalid parameters. πint setFrequency(fd, tuner, freq)β sets the specified frequency on the specified tuner. returns1on success,0on error.int getInput(fd)β returns the current input number starting from0. returns-1if an error occured. π€int setInput(fd, input)β sets the input to the specified value.inputis a0indexed value. returns1on success,0on error.@(index, name, type, audioset, tuner, std, status) enumerateInput(fd, index)β returns the contents of thev4l2_inputstructure for the specified index. if the ioctl fails thenindex = -1. π@(aspect, audio_bitmask, bframes, bitrate, bitrate_peak, dnr_mode, dnr_spatial, dnr_temporal, dnr_type, framerate, framespergop, gop_closure, pulldown, stream_type) getCodecInfo(fd)β returns the contents of theivtv_ioctl_codecstructure. if the ioctl fails then an empty list is returned. and heads up:audio_bitmaskis what audio used to be. πint setCodecInfo(fd, aspect, audio_bitmask, bframes, bitrate, bitrate_peak, dnr_mode, dnr_spatial, dnr_temporal, dnr_type, framerate, framespergop, gop_closure, pulldown, stream_type)β sets the card to the specified codec related stuff. returns1on success,0on error. and again, fr fr:audio_bitmaskis what audio used to be. π₯int setEndGOP(fd, end_gop)β sets theGOP_ENDflag to the specified value (1or0) to instruct the driver to finish a recording with a closed GOP.- Returns
undefifend_gop<0or >1. - Returns
1on success,0on error.
- Returns
int stopEncoding(fd)β calls theVIDIOC_STREAMOFFioctl to signal we want to stop encoding (reading from the driver).- Returns
1on success,0on error.
- Returns
π«Ά AUTHOR π«Ά
James A. Pattie <james at pcxperience dot com> β thank you for your service, icon. π
β SEE ALSO β
perl. that's it. that's the list. go read your perl docs bestie. π
and that's the whole page, no notes π this was ivtv(3pm) from perl v5.40.1, dated 2025-04-13 β slay, go ioctl something. πβ¨π¦
π¦ where this page comes from
- debian trixie: libvideo-ivtv-perl 0.13-11 Β· GPL-1.0-or-later
- ubuntu resolute: libvideo-ivtv-perl 0.13-11 Β· GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms