1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> 2<HTML 3><HEAD 4><TITLE 5>ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</TITLE 6><META 7NAME="GENERATOR" 8CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK 9REL="HOME" 10TITLE="Video for Linux Two API Specification" 11HREF="book1.htm"><LINK 12REL="UP" 13TITLE="Function Reference" 14HREF="r7624.htm"><LINK 15REL="PREVIOUS" 16TITLE="ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER" 17HREF="r7900.htm"><LINK 18REL="NEXT" 19TITLE="ioctl VIDIOC_ENUMAUDIO" 20HREF="r8242.htm"></HEAD 21><BODY 22CLASS="REFENTRY" 23BGCOLOR="#FFFFFF" 24TEXT="#000000" 25LINK="#0000FF" 26VLINK="#840084" 27ALINK="#0000FF" 28><DIV 29CLASS="NAVHEADER" 30><TABLE 31SUMMARY="Header navigation table" 32WIDTH="100%" 33BORDER="0" 34CELLPADDING="0" 35CELLSPACING="0" 36><TR 37><TH 38COLSPAN="3" 39ALIGN="center" 40>Video for Linux Two API Specification: Revision 0.24</TH 41></TR 42><TR 43><TD 44WIDTH="10%" 45ALIGN="left" 46VALIGN="bottom" 47><A 48HREF="r7900.htm" 49ACCESSKEY="P" 50>Prev</A 51></TD 52><TD 53WIDTH="80%" 54ALIGN="center" 55VALIGN="bottom" 56></TD 57><TD 58WIDTH="10%" 59ALIGN="right" 60VALIGN="bottom" 61><A 62HREF="r8242.htm" 63ACCESSKEY="N" 64>Next</A 65></TD 66></TR 67></TABLE 68><HR 69ALIGN="LEFT" 70WIDTH="100%"></DIV 71><H1 72><A 73NAME="VIDIOC-ENCODER-CMD" 74></A 75>ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</H1 76><DIV 77CLASS="REFNAMEDIV" 78><A 79NAME="AEN8091" 80></A 81><H2 82>Name</H2 83>VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD -- Execute an encoder command</DIV 84><DIV 85CLASS="REFSYNOPSISDIV" 86><A 87NAME="AEN8095" 88></A 89><H2 90>Synopsis</H2 91><DIV 92CLASS="FUNCSYNOPSIS" 93><P 94></P 95><A 96NAME="AEN8096" 97></A 98><P 99><CODE 100><CODE 101CLASS="FUNCDEF" 102>int ioctl</CODE 103>(int fd, int request, struct v4l2_encoder_cmd *argp);</CODE 104></P 105><P 106></P 107></DIV 108></DIV 109><DIV 110CLASS="REFSECT1" 111><A 112NAME="AEN8106" 113></A 114><H2 115>Arguments</H2 116><P 117></P 118><DIV 119CLASS="VARIABLELIST" 120><DL 121><DT 122><CODE 123CLASS="PARAMETER" 124>fd</CODE 125></DT 126><DD 127><P 128>File descriptor returned by <A 129HREF="r14090.htm" 130><CODE 131CLASS="FUNCTION" 132>open()</CODE 133></A 134>.</P 135></DD 136><DT 137><CODE 138CLASS="PARAMETER" 139>request</CODE 140></DT 141><DD 142><P 143>VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</P 144></DD 145><DT 146><CODE 147CLASS="PARAMETER" 148>argp</CODE 149></DT 150><DD 151><P 152></P 153></DD 154></DL 155></DIV 156></DIV 157><DIV 158CLASS="REFSECT1" 159><A 160NAME="AEN8126" 161></A 162><H2 163>Description</H2 164><DIV 165CLASS="NOTE" 166><BLOCKQUOTE 167CLASS="NOTE" 168><P 169><B 170>Experimental: </B 171>This is an <A 172HREF="x16453.htm" 173>experimental</A 174> 175interface and may change in the future.</P 176></BLOCKQUOTE 177></DIV 178><P 179>These ioctls control an audio/video (usually MPEG-) encoder. 180<CODE 181CLASS="CONSTANT" 182>VIDIOC_ENCODER_CMD</CODE 183> sends a command to the 184encoder, <CODE 185CLASS="CONSTANT" 186>VIDIOC_TRY_ENCODER_CMD</CODE 187> can be used to 188try a command without actually executing it.</P 189><P 190>To send a command applications must initialize all fields of a 191 struct <A 192HREF="r8087.htm#V4L2-ENCODER-CMD" 193>v4l2_encoder_cmd</A 194> and call 195 <CODE 196CLASS="CONSTANT" 197>VIDIOC_ENCODER_CMD</CODE 198> or 199 <CODE 200CLASS="CONSTANT" 201>VIDIOC_TRY_ENCODER_CMD</CODE 202> with a pointer to this 203 structure.</P 204><P 205>The <CODE 206CLASS="STRUCTFIELD" 207>cmd</CODE 208> field must contain the 209command code. The <CODE 210CLASS="STRUCTFIELD" 211>flags</CODE 212> field is currently 213only used by the STOP command and contains one bit: If the 214<CODE 215CLASS="CONSTANT" 216>V4L2_ENC_CMD_STOP_AT_GOP_END</CODE 217> flag is set, 218encoding will continue until the end of the current <I 219CLASS="WORDASWORD" 220>Group 221Of Pictures</I 222>, otherwise it will stop immediately.</P 223><P 224>A <CODE 225CLASS="FUNCTION" 226>read</CODE 227>() call sends a START command to 228the encoder if it has not been started yet. After a STOP command, 229<CODE 230CLASS="FUNCTION" 231>read</CODE 232>() calls will read the remaining data 233buffered by the driver. When the buffer is empty, 234<CODE 235CLASS="FUNCTION" 236>read</CODE 237>() will return zero and the next 238<CODE 239CLASS="FUNCTION" 240>read</CODE 241>() call will restart the encoder.</P 242><P 243>A <CODE 244CLASS="FUNCTION" 245>close</CODE 246>() call sends an immediate STOP 247to the encoder, and all buffered data is discarded.</P 248><P 249>These ioctls are optional, not all drivers may support 250them. They were introduced in Linux 2.6.21.</P 251><DIV 252CLASS="TABLE" 253><A 254NAME="V4L2-ENCODER-CMD" 255></A 256><P 257><B 258>Table 1. struct <CODE 259CLASS="STRUCTNAME" 260>v4l2_encoder_cmd</CODE 261></B 262></P 263><TABLE 264BORDER="0" 265FRAME="void" 266WIDTH="100%" 267CLASS="CALSTABLE" 268><COL 269WIDTH="25%" 270TITLE="C1"><COL 271WIDTH="25%" 272TITLE="C2"><COL 273WIDTH="50%" 274TITLE="C3"><TBODY 275VALIGN="TOP" 276><TR 277><TD 278>__u32</TD 279><TD 280><CODE 281CLASS="STRUCTFIELD" 282>cmd</CODE 283></TD 284><TD 285>The encoder command, see <A 286HREF="r8087.htm#ENCODER-CMDS" 287>Table 2</A 288>.</TD 289></TR 290><TR 291><TD 292>__u32</TD 293><TD 294><CODE 295CLASS="STRUCTFIELD" 296>flags</CODE 297></TD 298><TD 299>Flags to go with the command, see <A 300HREF="r8087.htm#ENCODER-FLAGS" 301>Table 3</A 302>. If no flags are defined for 303this command, drivers and applications must set this field to 304zero.</TD 305></TR 306><TR 307><TD 308>__u32</TD 309><TD 310><CODE 311CLASS="STRUCTFIELD" 312>data</CODE 313>[8]</TD 314><TD 315>Reserved for future extensions. Drivers and 316applications must set the array to zero.</TD 317></TR 318></TBODY 319></TABLE 320></DIV 321><DIV 322CLASS="TABLE" 323><A 324NAME="ENCODER-CMDS" 325></A 326><P 327><B 328>Table 2. Encoder Commands</B 329></P 330><TABLE 331BORDER="0" 332FRAME="void" 333WIDTH="100%" 334CLASS="CALSTABLE" 335><COL 336WIDTH="38%" 337TITLE="C1"><COL 338WIDTH="12%" 339TITLE="C2"><COL 340WIDTH="50%" 341TITLE="C3"><TBODY 342VALIGN="TOP" 343><TR 344><TD 345><CODE 346CLASS="CONSTANT" 347>V4L2_ENC_CMD_START</CODE 348></TD 349><TD 350>0</TD 351><TD 352>Start the encoder. When the encoder is already 353running or paused, this command does nothing. No flags are defined for 354this command.</TD 355></TR 356><TR 357><TD 358><CODE 359CLASS="CONSTANT" 360>V4L2_ENC_CMD_STOP</CODE 361></TD 362><TD 363>1</TD 364><TD 365>Stop the encoder. When the 366<CODE 367CLASS="CONSTANT" 368>V4L2_ENC_CMD_STOP_AT_GOP_END</CODE 369> flag is set, 370encoding will continue until the end of the current <I 371CLASS="WORDASWORD" 372>Group 373Of Pictures</I 374>, otherwise encoding will stop immediately. 375When the encoder is already stopped, this command does 376nothing.</TD 377></TR 378><TR 379><TD 380><CODE 381CLASS="CONSTANT" 382>V4L2_ENC_CMD_PAUSE</CODE 383></TD 384><TD 385>2</TD 386><TD 387>Pause the encoder. When the encoder has not been 388started yet, the driver will return an <SPAN 389CLASS="ERRORCODE" 390>EPERM</SPAN 391> error code. When the encoder is 392already paused, this command does nothing. No flags are defined for 393this command.</TD 394></TR 395><TR 396><TD 397><CODE 398CLASS="CONSTANT" 399>V4L2_ENC_CMD_RESUME</CODE 400></TD 401><TD 402>3</TD 403><TD 404>Resume encoding after a PAUSE command. When the 405encoder has not been started yet, the driver will return an <SPAN 406CLASS="ERRORCODE" 407>EPERM</SPAN 408> error code. 409When the encoder is already running, this command does nothing. No 410flags are defined for this command.</TD 411></TR 412></TBODY 413></TABLE 414></DIV 415><DIV 416CLASS="TABLE" 417><A 418NAME="ENCODER-FLAGS" 419></A 420><P 421><B 422>Table 3. Encoder Command Flags</B 423></P 424><TABLE 425BORDER="0" 426FRAME="void" 427WIDTH="100%" 428CLASS="CALSTABLE" 429><COL 430WIDTH="38%" 431TITLE="C1"><COL 432WIDTH="12%" 433TITLE="C2"><COL 434WIDTH="50%" 435TITLE="C3"><TBODY 436VALIGN="TOP" 437><TR 438><TD 439><CODE 440CLASS="CONSTANT" 441>V4L2_ENC_CMD_STOP_AT_GOP_END</CODE 442></TD 443><TD 444>0x0001</TD 445><TD 446>Stop encoding at the end of the current <I 447CLASS="WORDASWORD" 448>Group Of 449Pictures</I 450>, rather than immediately.</TD 451></TR 452></TBODY 453></TABLE 454></DIV 455></DIV 456><DIV 457CLASS="REFSECT1" 458><A 459NAME="AEN8224" 460></A 461><H2 462>Return Value</H2 463><P 464>On success <SPAN 465CLASS="RETURNVALUE" 466>0</SPAN 467> is returned, on error <SPAN 468CLASS="RETURNVALUE" 469>-1</SPAN 470> and the <CODE 471CLASS="VARNAME" 472>errno</CODE 473> variable is set appropriately:</P 474><P 475></P 476><DIV 477CLASS="VARIABLELIST" 478><DL 479><DT 480><SPAN 481CLASS="ERRORCODE" 482>EINVAL</SPAN 483></DT 484><DD 485><P 486>The driver does not support this ioctl, or the 487<CODE 488CLASS="STRUCTFIELD" 489>cmd</CODE 490> field is invalid.</P 491></DD 492><DT 493><SPAN 494CLASS="ERRORCODE" 495>EPERM</SPAN 496></DT 497><DD 498><P 499>The application sent a PAUSE or RESUME command when 500the encoder was not running.</P 501></DD 502></DL 503></DIV 504></DIV 505><DIV 506CLASS="NAVFOOTER" 507><HR 508ALIGN="LEFT" 509WIDTH="100%"><TABLE 510SUMMARY="Footer navigation table" 511WIDTH="100%" 512BORDER="0" 513CELLPADDING="0" 514CELLSPACING="0" 515><TR 516><TD 517WIDTH="33%" 518ALIGN="left" 519VALIGN="top" 520><A 521HREF="r7900.htm" 522ACCESSKEY="P" 523>Prev</A 524></TD 525><TD 526WIDTH="34%" 527ALIGN="center" 528VALIGN="top" 529><A 530HREF="book1.htm" 531ACCESSKEY="H" 532>Home</A 533></TD 534><TD 535WIDTH="33%" 536ALIGN="right" 537VALIGN="top" 538><A 539HREF="r8242.htm" 540ACCESSKEY="N" 541>Next</A 542></TD 543></TR 544><TR 545><TD 546WIDTH="33%" 547ALIGN="left" 548VALIGN="top" 549>ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER</TD 550><TD 551WIDTH="34%" 552ALIGN="center" 553VALIGN="top" 554><A 555HREF="r7624.htm" 556ACCESSKEY="U" 557>Up</A 558></TD 559><TD 560WIDTH="33%" 561ALIGN="right" 562VALIGN="top" 563>ioctl VIDIOC_ENUMAUDIO</TD 564></TR 565></TABLE 566></DIV 567></BODY 568></HTML 569> 570