⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.lavpipe

📁 Motion JPEG编解码器源代码
💻 LAVPIPE
字号:
This README describes the lavpipe tools: how to use them,and how they work (partially).The current implementation still is not tested very well, so bewarned (and please report any errors you encounter).At the moment, there are only two filters for lavpipe,transist.flt and matteblend.flt, which means that you canuse it only to make simple blending transistions between twomovies or to blend one video over another using a predefinedmatte (yuv image or lav movie). But it is very easy to codenew filters or extend existing ones. Read on.Contents:1. What are the tools?2. What can we do with it?3. What else can we do with it?4. That's all?! How can we make them do more?_____________________________________________________________________________                                                                             \1. What are the tools?                                                       /____________________________________________________________________________/The tools that are involved so far are: - lav2yuv, which decompresses the given input files (or any portions            of them) and gives us raw yuv frame streams that can be            piped through the several tools. - lavpipe, which reads out a "LAV Pipe List" (e.g. *.pli) file, a            "recipe" which tells it how to combine several input            movies using several yuv stream filters. - transist.flt and matteblend.flt, all the filters that already exist. - yuv2lav or mpeg2enc, which compress the resulting yuv stream                        into an mjpeg or mpeg file._____________________________________________________________________________                                                                             \2. So hat can we do with it?                                                 /____________________________________________________________________________/Example one: Make a transistion from one movie to another one.Let's assume that we have got two 352x288 PAL files:intro.avi (1040 frames) and epilogue.qt (3920 frames). Now we wantto make a transistion between them that lasts for two seconds(2 sec = 50 frames, as they are PAL movies).We also have to take care that both share the same dimensions - ifthey are of different sizes, we can use lavscale once it is finished.Our task now is to write a "recipe" for lavpipe and thus tell it howto do the work. If we store our work as trans.pli, the final call willsimply be: "lavpipe trans.pli | yuv2lav -o result.avi" (lavpipewrites a yuv stream to stdout as lav2yuv does).The first line of trans.pli must be "LAV Pipe List".The second line contains one single number, the number of inputstreams that we will use. (In our case: "2")Now for each of the two input streams a line containing thecommand that produces the stream is added. First for intro.avi:"lav2yuv -o $o -f $n -n 1 intro.avi"The -o $o and -f $n parameters are necessary as lavpipe somehowhas to inform lav2yuv which frames it should output. $o willbe replaced by the offset and $n will be replaced by the numberof frames that lavpipe wants lav2yuv to output. The -n 1parameter is of course optional, and any other parameters tolav2yuv could be added. The second line for epilogue.qt mightlook like this: "lav2yuv -o $o -f $n epilogue.qt"Now follow all the sequences of the Pipe List, each of whichconsists of a listing of the input streams used and a commandline to the filter program.The first sequence will simply reproduce all but the last 50frames of intro.avi (that are 1040 - 50 = 990 frames). Itsfirst line only contains "990", the number of frames. Thesecond line is "1", the number of streams used.The next line contains the index of the stream to use and theoffset (how many frames to skip in the beginning).In our case both index and offset are 0, so the line would be:"0 0"Now we would add the command line of the filter program, butas we don't want to invoke any filter here, this line onlycontains "-", which causes lavpipe to simply output the contentsof the stream.The second sequence is the actual transistion. So the firstline is "50" (two seconds), the second one "2" (we use both streams).The following line will be "0 990" (intro.avi will be continuedat frame 990) and then "1 0" follows (epilogue.qt starts withframe 0).The next line is the filter command, in our case"transist.flt -s $o -n $n -o 0 -O 255 -d 50"The -s $o -n $n parameters equal to the -o $o -f $n parametersof lav2yuv, -o 0 means that at the beginning of the transistion,only intro.avi is visible (opacity of epilogue.qt = 0).As you would have expected, -O 255 means that at the end ofthe transistion, only epilogue.qt is visible (opacity ofepilogue.qt = 255 = 100%) - the opacity will be linearlyinterpolated inbetween. And finally -d 50 is the durationof the transistion in frames and should be equal to thefirst line (duration in frames) of the sequence in most cases.The last sequence continues with only epilogue.qt (the last3870 frames), thus the first line is "3870". The second lineis "1" (only one stream), then "1 50" follows (epilogue.qt,beginning with frame 50). The filter command line is "-" again.Finally, our Pipe List file should look like this:--------------------< trans.pli >--------------------------LAV Pipe List2lav2yuv -o $o -f $n -n 1 intro.avilav2yuv -o $o -f $n epilogue.qt99010 0-5020 9901 0transist.flt -s $o -n $n -o 0 -O 255 -d 25387011 50---------------------< end of file >------------------------Remember the call? "lavpipe trans.pli | yuv2lav -o result.avi"should now produce a nice avi file with a nice transistion._____________________________________________________________________________                                                                             \3. And what else can we do with it?                                          /____________________________________________________________________________/Example two: Blend one movie over another one, using a third one's luminance             channel as a matte (alpha channel) for the second one.matteblend.flt has no parameters until now, as its output is independent ofthe actual position in the stream (only depends on the input frames it is fed).If you read the first example and have understood the pipe list format, itwill be easy to write a pipe list for this task. As there still is nobluescreen.flt filter, and it is very time consuming to build an animatedmatte channel for a given input movie by hand, I will only describe how toblend a static picture (a title or static logo) over a movie.For this you need your input.avi, a picture with an alpha channel. Use forexample the GIMP to save the image as plain yuv (pic.yuv) and save itsalpha channel as a grayscale plain yuv (matte.yuv - its chrominance channelswill be ignored). Of course the must be of the right size.Now create this simple shell script that will output an infinite yuv streamthat only contains the given plain yuv picture:--------------------< foreveryuv >-------------------------#!/bin/shecho "YUV4MPEG 352 288 3"while truedo       echo "FRAME"       cat $1done--------------------< end of file >------------------------And write the pipe list:--------------------< title.pli >--------------------------LAV Pipe List3lav2yuv -o $o -f $n input.aviforeveryuv pic.yuvforeveryuv matte.yuv7530 01 02 0100000010 75matteblend.flt--------------------< end of file >------------------------As long as your input.avi is shorter than 1000076 frames,"lavpipe title.pli | yuv2lav -o result.avi" will outputthe whole movie with the given picture blended over itfor the first three seconds._____________________________________________________________________________                                                                             \4. That's all?! How can we make them do more?                                /____________________________________________________________________________/The solution is of course to code new filter programs. And of course thisis very easy. I want to annote here, that the whole system is not veryfool proof at the moment. So if you feed matteblend.flt the wrong numberof input streams via lavpipe, you will get funny results, if you getany results at all (without any hint from the programs). Perhaps thiscould be improved by adding additional (optional) parameters to theYUV4MPEG header line.A filter program consists only of 4 parts:1. Read input parameters (especially -o and -n, if the output is not only   dependent on the input frames but also on some variable parameters that   change over time) - optional.2. Read in and write out the YUV headers, could look like this:   int fd_in = 0, fd_out = 1; /* stdin, stdout */   y4m_stream_info_t istream, ostream;   int res, width, height, frame_rate_code;   y4m_init_stream_info(&istream);   y4m_init_frame_info(&iframe);   if (y4m_read_stream_header (fd_in, &istream) != Y4M_OK)      exit (1);   y4m_init_stream_info(&ostream);   y4m_copy_stream_info(&ostream,&istream);   y4m_write_stream_header (fd_out, width, heigth, frame_rate_code);   3. Allocate the YUV buffer(s) - one for each input stream and perhaps one   for the output or an arbitrary number of temporary buffers (no bloated   code, please ;-) )      char *yuv_buffer[3]; /* this is one yuv buffer */   yuv_buffer[0] = (char *) malloc(y4m_si_get_plane_length(&istream, 0)); /* Y' */   yuv_buffer[1] = (char *) malloc(y4m_si_get_plane_length(&istream, 1)); /* Cr */   yuv_buffer[2] = (char *) malloc(y4m_si_get_plane_length(&istream, 2)); /* Cb */4. The loop - while (number of frames processed) < (-n parameter)4.1. Read the input frames, one of those for each input stream (e.g. yuv_buffer[123])   while (y4m_read_frame (fd_in, &istream, &iframe, yuv_buffer) == Y4M_OK)         {4.2. Process the input buffers in any way you want.5. Write out the result:         y4m_write_frame(fd_out, &ostream, &iframe, yuv_buffer);         }6. Clean up:     y4m_fini_frame(&iframe);     y4m_fini_stream_info(&istream);     y4m_fini_stream_info(&ostream);That's all. You should in any case have a look at the existing filters,transist.flt.c and matteblend.flt.c.- pHilipp Zabel <pzabel@gmx.de>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -