1
votes

i just have h.264 encoded video stream and i want to make mp4 file.

/* find output format for mp4 */

m_pOutputFormat= av_guess_format("mp4", NULL, NULL);

if (!m_pOutputFormat) return FALSE; // could not find suitable output format(mp4).

on this code, i get mpeg for video codec not h264, i think that's because i build ffmpeg without libx264. (and i dont want to build ffmpeg with libx264 for license)

m_pOutputFormat->video_codec= CODEC_ID_H264;

when i change its video_codec to CODEC_ID_H264, it works fine some player(kmplayer). but it's not work on ipod, QuickTime.

this code maybe wrong because it could not change codec_tag value(this variable has const property).


1. how can i get other result for av_guess_format("mp4",NULL,NULL) without recompile libav+libx264?

2. how can i make mp4 file properly?

1

1 Answers

0
votes

I think you don't need libx264 to properly work with h264 stream because libx264 is encoder, and I've worked with h264 packets using libav compiled without libx264. It works fine for reading packets from file and writing it to another file.

As for call to av_guess_format you can either provide appropriate MIME type for h264 (video/h264 for example or any other) or just give function another short type name. This must be correct: av_guess_format("h264",NULL, NULL).

Look here for some code example (objective-C): http://libav-users.943685.n4.nabble.com/Libavcodec-encoding-with-libx264-td3250373.html