0
votes

I have raw h264 data of my frames and its presentationTimeUs and I want to mux data in mp4 container. How can I do it with ffmpeg or any library except MediaMuxer ?

Update: I need a command to write h264 data of just one frame to mp4 container including presentatoinTimeUs

1
Sounds like you're looking for examples of using the ffmpeg library to do .mp4 muxing?fadden
You can try ffmpeg -f h264 -i raw.264 out.mp4Gyan
I encoded byte[] to h264 with MediaCodec but I didn't want to use MediaMuxer for muxing data in mp4 container(because it's added from android 4.3). so when I write raw h264 to file it doesn't play well and playing too fast and this command: ffmpeg -f h264 -i raw.264 out.mp4 just put video in mp4 container and doesn't solve anything. I need a command of ffmpeg to write just one h264 frame in mp4 file including setting presentationTimeUs or any meta data that it needs.Sajad Norouzi

1 Answers

0
votes

You can't write arbitrary H264 raw data without associated meta-information, either with ffmpeg or any library. Container such as MP4 exist so that a player knows how to handle that raw data (e.g each frame's PTS, codec configuration, movie size, color format, etc), and more things that are not included in the raw compressed video stream.

You can however do the reverse, if you need to later analyze a compressor's bitstream:

ffmpeg -i file.mp4 -f h264 out.h264