[Libav-user] Problem Generating B-Frames Using libavcodec/libx264
rob.f.schmidt86 at gmail.com
Fri Oct 25 17:50:38 CEST 2013
> i have your same goal, also I am writing a an application that encodes
> incoming video in H.264 using libavcodec and libx264. I don't know the
> solution for yuor problem, because i do not know how to encode.
> i have a avi or mp4 file as input. The *avcodec_encode_video2* function
> takes input raw video data from frame, so i demux my file and i obtain a
> raw video file; now i want encode it, so how i can open the raw file, read
> the raw frames and encode them into h264?? Is this the right wat yo encode
> in H.264? There are other solutions?? How do you encode?? Can you help me,
I'm not entirely certain what you are looking for, but for I basically
do the following for my transcoding test utility:
* Read a raw packet from the input file using av_read_frame (demux)
* Decode the packet into a frame using avcodec_decode_video2 (decode)
* Encode the frame using avcodec_encode_video2 (encode)
* Write the resulting packets using av_interleaved_write_frame (mux)
I found the examples at http://ffmpeg.org/doxygen/trunk/examples.html
helpful for understanding how to properly use the API calls. Also, if
you look up the relevant API calls in the FFmpeg Doxygen documenation
(http://ffmpeg.org/doxygen/trunk/index.html), there are
cross-references to where they are used in the examples that help
provide context and show how they're used.
If you want to use H.264 for encoding, you can specify "h264" as the
format if you call avformat_alloc_output_context2 to set up your
output muxer or use AV_CODEC_ID_H264 when a setting up your encoder.
My application receives its video data from a separate source, so I
have to manually set up the AVFrame structures to pass to the encoder
rather than rely on av_read_frame/avcodec_decode_video2, but otherwise
the process is basically the same.
I hope this helps.
More information about the Libav-user