libavcodec

keyframe is not a keyframe? AV_PKT_FLAG_KEY does not decode to AV_PICTURE_TYPE_I

谁都会走 提交于 2019-12-04 14:14:23
问题 After decoding a packet containing AV_PKT_FLAG_KEY in the flags, I was expecting to get I-frames, but instead I got P-frames: After a call to: avcodec_decode_video2(codecCtx, frame, &frameFinished, &packet); // mpeg2 video I print out the following as a sanity check: printf("packet flags: %d picture type: %c\n", packet.flags, av_get_picture_type_char(frame->pict_type)); Returns the output: packet flags: 1 picture type: P When I was expecting: packet flags: 1 picture type: I Where '1' == AV

Decode MP3, then increase the audio volume, and then encode the new audio

眉间皱痕 提交于 2019-12-04 11:11:48
问题 I want to first decode a MP3 audio file, and then increase the volume of the audio, and then encode it again into a new MP3 file. I want to use libavformat or libavcodec for this. Can you help me how I can do this? Any example? 回答1: You can use the "-filter" parameter with the "volume" option to set a multiplier for the audio. More info: http://ffmpeg.org/ffmpeg-filters.html#volume Since you are dealing only with MP3 files (that have only one audio track), you can use the "-af" parameter,

How to choose between openH264 and x264 decoder

久未见 提交于 2019-12-03 20:35:44
I'm using the dev build from zeranoe.com which has OpenH264 and libx264 in it. How can i choose between these two Decoders to compare the decoding speed ? avcodec_find_decoder(AVCodecID.AV_CODEC_ID_H264); only gives me the name "h264" but which decoder is it ? And tries to force a specific decoder failed, like: codec = avcodec_find_decoder _by_name("x264"); codec = avcodec_find_decoder _by_name("libx264"); Which other options i have to improve the decoding speed of avcodec_decode_video2 for highres (4k and higher) RTSP video streams ? FFmpeg can use OpenH264 (named libopenh264 in FFmpeg) to

How to set decode pixel format in libavcodec?

大兔子大兔子 提交于 2019-12-03 16:49:38
问题 I decode video via libavcodec, using the following code: //Open input file if(avformat_open_input(&ctx, filename, NULL, NULL)!=0) return FALSE; // Couldn't open file if(avformat_find_stream_info(ctx, NULL)<0) return FALSE; // Couldn't find stream information videoStream = -1; //find video stream for(i=0; i<ctx->nb_streams; i++) { if((ctx->streams[i])->codec->codec_type==AVMEDIA_TYPE_VIDEO) { videoStream=i; break; } } if (videoStream == -1) return FALSE; // Didn't find a video stream video

Strange Sound produced by ffmpeg and SDL

穿精又带淫゛_ 提交于 2019-12-02 08:00:42
问题 I'm following the updated version of the original dranger.com/ffmpeg tutorial at https://github.com/mpenkov/ffmpeg-tutorial The third step(Source code: https://github.com/mpenkov/ffmpeg-tutorial/blob/master/tutorial03.c) adds sound, but the sound produced is strange. When the audio stream is AAC I only hear static. When the audio stream is MP3 I hear a very high pitched version of the sound. What's wrong? 回答1: I've had the same exact issue. After days of trying, I figured out it was something

Strange Sound produced by ffmpeg and SDL

拜拜、爱过 提交于 2019-12-02 06:52:56
I'm following the updated version of the original dranger.com/ffmpeg tutorial at https://github.com/mpenkov/ffmpeg-tutorial The third step(Source code: https://github.com/mpenkov/ffmpeg-tutorial/blob/master/tutorial03.c ) adds sound, but the sound produced is strange. When the audio stream is AAC I only hear static. When the audio stream is MP3 I hear a very high pitched version of the sound. What's wrong? I've had the same exact issue. After days of trying, I figured out it was something wrong with the latest build that I was using from Zeranoe. If you are using Zeranoe builds as well, try

How to convert YUV420P image to JPEG using ffmpeg's libraries?

帅比萌擦擦* 提交于 2019-12-02 06:31:55
I'm trying to convert a YUV420P image ( AV_PIX_FMT_YUV420P ) to a JPEG using ffmpeg's libavformat and libavcodec . This is my code so far: AVFormatContext* pFormatCtx; AVOutputFormat* fmt; AVStream* video_st; AVCodecContext* pCodecCtx; AVCodec* pCodec; uint8_t* picture_buf; AVFrame* picture; AVPacket pkt; int y_size; int got_picture=0; int size; int ret=0; FILE *in_file = NULL; //YUV source int in_w = 720, in_h = 576; //YUV's width and height const char* out_file = "encoded_pic.jpg"; //Output file in_file = fopen(argv[1], "rb"); av_register_all(); pFormatCtx = avformat_alloc_context(); fmt =

Pixel format conversion issue [FFMPEG]

*爱你&永不变心* 提交于 2019-12-02 04:14:11
问题 I wrote a small program using ffmpeg's libraries. which does the following- 1)decode a frame. 2)convert frame to rgb24 . 3)convert rgb24 frame back to yuv420p. 4)encode the yuv420p frame and pack it into video file. But the end video is not same as the input video. there is some artifacts in final video (horizontal lines).i also get a warning when the rgbToYuv method gets called - Warning: data is not aligned! This can lead to a speedloss i suspect something is wrong with my format conversion

How to decode AAC using avcodec_decode_audio4?

六月ゝ 毕业季﹏ 提交于 2019-12-01 07:13:04
I changed in my code avcodec_decode_audio3 to avcodec_decode_audio4 and added the frame handling. But now I cannot decode AAC frames anymore. Why does avcodec_decode_audio4 return -22 ( invalid argument )? Following the answer below, does this have something to do with the parameters in AVContext that need to be set? I had to use avcodec_decode_audio4 because I updated my ffmpeg and then got the following error: [NULL @ 0xb14f020] Custom get_buffer() for use withavcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer [NULL @ 0xb14f020] Please port your application to

How to decode AAC using avcodec_decode_audio4?

泪湿孤枕 提交于 2019-12-01 04:11:11
问题 I changed in my code avcodec_decode_audio3 to avcodec_decode_audio4 and added the frame handling. But now I cannot decode AAC frames anymore. Why does avcodec_decode_audio4 return -22 ( invalid argument )? Following the answer below, does this have something to do with the parameters in AVContext that need to be set? I had to use avcodec_decode_audio4 because I updated my ffmpeg and then got the following error: [NULL @ 0xb14f020] Custom get_buffer() for use withavcodec_decode_audio3()