I am attempting to encode video using libavcodec/libavformat. I'm trying to change the standard output-example.c from ffmpeg source. The AVI file is created on the disk, but the only sound is encoded. I tried adding a lot of options for x264 from here. All the other codecs works fine, mpeg2, mpeg4, mjpeg, xvid.
In addition to specifying the parameters x264, I also set the codec to AVOutputFormat structure. That's all I've done.
AVOutputFormat *pOutFormat; // in header file
av_register_all();
AVCodec *codec = avcodec_find_encoder_by_name("libx264");
pOutFormat = guess_format("avi", NULL, NULL);
pOutFormat->video_codec = codec->id;
The debug output of my application:
Output #0, mp4, to 'D:\1.avi':
Stream #0.0: Video: libx264, yuv420p, 320x240, q=10-51, 500 kb/s, 90k tbn, 25 tbc
Stream #0.1: Audio: aac, 44100 Hz, 1 channels, s16, 128 kb/s
[libx264 @ 0x694010]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x694010]bitrate tolerance too small, using .01
[libx264 @ 0x694010]profile Main, level 2.0
[libx264 @ 0x694010]frame I:150 Avg QP:14.76 size: 2534
[libx264 @ 0x694010]mb I I16..4: 75.9% 0.0% 24.1%
[libx264 @ 0x694010]final ratefactor: 17.57
[libx264 @ 0x694010]coded y,uvDC,uvAC intra: 42.7% 92.4% 47.4%
[libx264 @ 0x694010]i16 v,h,dc,p: 11% 14% 2% 73%
[libx264 @ 0x694010]i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 18% 29% 5% 8% 10% 3% 3% 2%
[libx264 @ 0x694010]kb/s:506.79