ivtv(3pm)

πŸ“¦
version 0.13 Β· 5 versions
, in debian trixie, ubuntu resolute

πŸ’– 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 the ivtv_ioctl_codec structure, as returned by getCodecInfo() and as expected by setCodecInfo(). it's the map, iykyk. πŸ—ΊοΈ
  • %capIndexes β€” this contains the index names and their position in the v4l2_capability structure, as returned by getCapabilities(). 🧚

πŸ”₯ FUNCTIONS πŸ”₯

the main characters. all of them. periodt.

  • @(driver, card, bus_info, version, capabilities) getCapabilities(fd) β€” returns the contents of the v4l2_capability structure. 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 using fileno($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 undef if invalid resolution is specified.
    • Returns a 1 if sucess, 0 if error from the actual code.
  • 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). returns 1 on success, 0 on error.
  • @(index, id, name, frameperiod_numerator, frameperiod_denominator, framelines) enumerateStandard(fd, index) β€” returns the contents of the v4l2_standard structure for the specified index. if the ioctl fails then index = -1. πŸ¦‹
  • int getFrequency(fd, tuner) β€” returns the current frequency for the specified tuner, or -1 if an ioctl error occured. returns undef on invalid parameters. πŸ™ˆ
  • int setFrequency(fd, tuner, freq) β€” sets the specified frequency on the specified tuner. returns 1 on success, 0 on error.
  • int getInput(fd) β€” returns the current input number starting from 0. returns -1 if an error occured. 😀
  • int setInput(fd, input) β€” sets the input to the specified value. input is a 0 indexed value. returns 1 on success, 0 on error.
  • @(index, name, type, audioset, tuner, std, status) enumerateInput(fd, index) β€” returns the contents of the v4l2_input structure for the specified index. if the ioctl fails then index = -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 the ivtv_ioctl_codec structure. if the ioctl fails then an empty list is returned. and heads up: audio_bitmask is 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. returns 1 on success, 0 on error. and again, fr fr: audio_bitmask is what audio used to be. πŸ”₯
  • int setEndGOP(fd, end_gop) β€” sets the GOP_END flag to the specified value (1 or 0) to instruct the driver to finish a recording with a closed GOP.
    • Returns undef if end_gop < 0 or > 1.
    • Returns 1 on success, 0 on error.
  • int stopEncoding(fd) β€” calls the VIDIOC_STREAMOFF ioctl to signal we want to stop encoding (reading from the driver).
    • Returns 1 on success, 0 on error.

🫢 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