问题
I have a set of images and I would like to generate a slideshow as a video file. I am using jcodec. When I encode a frame, is it possible to specify that that frame has to be shown for a certain amount of time (eg. 1 sec)?
回答1:
Yes,It's possible to specify the time for the frame. It's explained in 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
)
来源:https://stackoverflow.com/questions/20221836/android-jcodec-how-to-set-frame-rate