我有一组图像,我想生成一个幻灯片作为视频文件。我正在使用jcodec。当我对一个帧进行编码时,是否可以指定该帧必须显示一定的时间(例如1秒)?

最佳答案

是的,可以指定帧的时间。在https://github.com/jcodec/jcodec/issues/21#issuecomment-23095738中有解释

     new MP4Packet(
result,      // Bytebuffer that contains encoded frame
i,             // Presentation timestamp ( think seconds ) expressed in timescale units ( just multiply second by
               // timescale value below. This is to avoid floats.
               // Example: timescale = 25, pts = 0, 1, 2, 3, 4, 5 .... ( PAL 25 fps )
               // Example: timescale = 30000, pts = 1001, 2002, 3003, 4004, 5005, 6006, 7007 ( NTSC 29.97 fps )
timescale, // See above
1,            // Duration of a frame in timescale units ( think seconds multiplied by number above)
               // Examlle: timescale = 25, duration = 1 ( PAL 25 fps )
               // Example: timescale = 30000, duration = 1001 ( NTSC 29.97 fps )
frameNo,  // Just a number of frame, doesn't have anything to do with timing
true,         // Is it an I-frame, i.e. is this a seek point? Players use this information to instantly know where to seek
null,         // just ignore, should be null. This is used by the older brother of MP4 - Apple Quicktime which supports
               // tape timecode
i,             // just put the same as pts above
0             // sample entry, should be 0
)

关于android - android jcodec:如何设置帧率,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20221836/

10-10 11:53