[Libav-user] Muxing to file with unknown frame rate

Robert Jamieson bob_jam11 at hotmail.com
Wed Apr 12 17:29:47 EEST 2017


Hi,


I am attempting to mux footage from a variety of webcams into standards based files. The footage is spread over a large number of files (all from the same camera). The files are a proprietary format containing the encoded frames that came directly from the camera (in most cases it is H.264, MJPEG or MPEG4 with G.711 or PCM16 audio). Audio is optional.


I have created a pipeline for processing the footage that comprises of a reader for the files (this reads the frames and pushes them through the pipeline), a file sync that picks a suitable file format (based on the incoming video and audio formats) and writes the already encoded frames into the file. I am purposely not using a transcoder to save processing time.


This is working well with one exception, I can't tell what the frame rate is ahead of time because I can't read the files before I process them. If I set the frame rate to what I suspect the camera will give me (i.e. 30 fps) then I get collisions in PTS values if the camera has been bursty or the fps is actually higher and I drop frames (which may or may not be key frames).


I have tried setting the time_base of the video stream to 1/1000 and calculating the frame pts based on the millisecond timestamp. This works in theory but in practice the only player that can handle playing this back successfully is Media Player Classic and all the files report a frame rate of 1000 (which is understandable).


I am currently alternating between .mkv, .mp4 and .avi depending on the incoming codecs. .mp4 for h.264 or MPEG4 only, avi for h.264, MJEPG or MPEG4 with PCM audio and mkv as a fallback for all other cases.


1. Is there any way to achieve this?

2. Is there a particular container type that will enable me to achieve this?

3. Would I have any more success if I transcoded the frames to a guaranteed particular video and audio codecs?

4. Is there another way to achieve a variable frame rate?


Thanks for your help,

Robert

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170412/fc31d460/attachment.html>


More information about the Libav-user mailing list