0

I am going to record H264 encoded video stream data in iOS using swift. I am not familiar with video codec formats so don't know how to do this. But I've tried to write the H264 raw video data to the file sequently and see its file Info. I am surprised that it has almost video file info (compared with standard mp4, MOV file). The only missing info is video duration, file size, overall bit rate, encoded data, etc. So I am just wondering if video can play if I add the MOV file header to this file manually. Spent few hours to googling how to add MOV file header with ffmpeg but stacked. Any help would be appreciated. Thanks

gstream
  • 525
  • 6
  • 18

1 Answers1

1

You can nominally use ffmpeg to do this:

ffmpeg -i in.h264 -c copy out.mov

However, due to a bug in ffmpeg relating to generation of PTS for video streams with multiple B-frames, the output video may not play smoothly. Test and check.

If it doesn't there's a workaround which involves using mp4box from GPAC.

mp4box -add in.h264 -new out.mp4

and then

ffmpeg -i out.mp4 -c copy out.mov
Gyan
  • 85,394
  • 9
  • 169
  • 201