I have a project, that i need to received data from a rtsp link, decode,resize video, encode it and save to .mp4 file.
- I Using ffmpeg from http://ffmpeg.zeranoe.com/builds/
- I am using visual studio 2010, run on windows 7 and windows 8.
- This is rtsp link i am using: rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov
- I decode and save to ppm file is ok. But encode isn't.
- I following there tutorials: http://dranger.com/ffmpeg/tutorial01.html
this is my code:
AVPacket destPacket;
av_init_packet(&destPacket);
destPacket.data = NULL;
destPacket.size = 0;
while(av_read_frame(i_format_context, &packet)>=0) {
if(packet.stream_index==video_stream_index) {
int rest = avcodec_decode_video2(copyInputCodec, pFrame, &frameFinished, &packet);
if(frameFinished) {
av_init_packet(&destPacket);
destPacket.data = NULL;
destPacket.size = 0;
av_free_packet(&destPacket);
//deocde here
int ret_scale = sws_scale(sws_ctx,pFrame->data,pFrame->linesize,0,copyInputCodec->height,encodeFrame->data,encodeFrame->linesize);
encodeFrame->pts=i;
int ret_enc = avcodec_encode_video2(copyOutputCodec,&destPacket,encodeFrame,&encodeFinishsed);//<--- Problem here.
getchar();
}
}
}
And this is output error
[swscaler @ 00607880] Warning: data is not aligned! This can lead to a speedlo ss Assertion avctx->codec->encode2 failed at /home/kyle/software/ffmpeg/source/ffmp eg-git/libavcodec/utils.c:2134
I try to run many sample code to encode video, the result is same.
Thanks for help.
PS: sorry about my English skill.
There are actually two issues here: