How to get rid of ffmpeg pts has no value error
Solution 1:
First, a background on why this error exists. AVI does not support variable frame rate video. So somewhere at the start of the file the frame rate is recorded. mp4 does support variable frame rate, so it is required that the duration of each frame is known. In ffmpeg the pts generation for fixed frame rate video is usually handled by the decoder. but by using -codec copy
, you are bypassing the decoder.
The solution is specifying -fflags +genpts
(must be before the input file is specified with -i
).
Solution 2:
I found that hard-coding the frame rate solved this issue:
ffmpeg -r 25 -i test.h264 -codec copy testout25.mp4
(I still got the warning "Timestamps are unset in a packet in stream 0", but the resulting file was seekable in Quicktime Player on a Mac.)