libav

Segmentation fault while avcodec_encode_video2

那年仲夏 提交于 2019-11-30 14:20:42
问题 I have some problems while trying to encode a AVFrame to a packet. Before reading the whole code, the input stuff is working, I tested it. The output stuff is from an example here. I think there is the problem. But the segmentation fault occurs in the loop near the end. Here is my reduced code: void nmain() { // input stuff AVFormatContext *formatCtxIn=0; AVInputFormat *formatIn=0; AVCodecContext *codecCtxIn=0; AVCodec *codecIn; AVPacket *pktIn; av_register_all(); avdevice_register_all();

Segmentation fault while avcodec_encode_video2

可紊 提交于 2019-11-30 10:16:38
I have some problems while trying to encode a AVFrame to a packet. Before reading the whole code, the input stuff is working, I tested it. The output stuff is from an example here . I think there is the problem. But the segmentation fault occurs in the loop near the end. Here is my reduced code: void nmain() { // input stuff AVFormatContext *formatCtxIn=0; AVInputFormat *formatIn=0; AVCodecContext *codecCtxIn=0; AVCodec *codecIn; AVPacket *pktIn; av_register_all(); avdevice_register_all(); avcodec_register_all(); formatIn = av_find_input_format("dshow"); if(!formatIn) return; AVDictionary

How to encode h.264 with libavcodec/x264?

本秂侑毒 提交于 2019-11-30 10:16:18
问题 I am attempting to encode video using libavcodec/libavformat. Audio works great, but when I try to encode video I get the following errors: [libx264 @ 0x10182a000]broken ffmpeg default settings detected [libx264 @ 0x10182a000]use an encoding preset (vpre) easy to fix using the command line ffmpeg, but I am trying to do this in C. my options are AVStream *pVideoOutStream = av_new_stream(pOutFormatCtx, 0); AVCodecContext *pVideoOutCodecCtx = pVideoOutStream->codec; pVideoOutCodecCtx->codec_id =

FFMPEG audio transcoding using libav* libraries

拟墨画扇 提交于 2019-11-30 04:09:24
问题 I am writing an audio transcoding application using ffmpeg libraries. Here is my code /* * File: main.cpp * Author: vinod * Compile with "g++ -std=c++11 -o audiotranscode main.cpp -lavformat -lavcodec -lavutil -lavfilter" * */ #if !defined PRId64 || PRI_MACROS_BROKEN #undef PRId64 #define PRId64 "lld" #endif #define __STDC_FORMAT_MACROS #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <stdint.h> #include <libavutil/imgutils.h>

What is the difference between AV_SAMPLE_FMT_S16P and AV_SAMPLE_FMT_S16?

自闭症网瘾萝莉.ら 提交于 2019-11-30 03:36:12
What happens when you do a conversion from AV_SAMPLE_FMT_S16P to AV_SAMPLE_FMT_S16? How is the AVFrame structure going to contain the planar and non-planar data? Harit Vishwakarma AV_SAMPLE_FMT_S16P is planar signed 16 bit audio, i.e. 2 bytes for each sample which is same for AV_SAMPLE_FMT_S16 . The only difference is in AV_SAMPLE_FMT_S16 samples of each channel are interleaved i.e. if you have two channel audio then the samples buffer will look like c1 c2 c1 c2 c1 c2 c1 c2... where c1 is a sample for channel1 and c2 is sample for channel2. while for one frame of planar audio you will have

Calculate PTS before frame encoding in FFmpeg

假如想象 提交于 2019-11-30 03:29:35
How to calculate correct PTS value for frame before encoding in FFmpeg C API? For encoding I'm using function avcodec_encode_video2 and then write it by av_interleaved_write_frame . I found some formulas, but no one of them doesn't work. In doxygen example they are using frame->pts = 0; for (;;) { // encode & write frame // ... frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base); } This blog says that formula must be like this: (1 / FPS) * sample rate * frame number Someone uses only frame number to set pts: frame->pts = videoCodecCtx->frame_number; Or alternative

How to use libavformat to concat 2 video files with same codec (re-muxing)?

丶灬走出姿态 提交于 2019-11-29 22:14:36
问题 I have downloaded videos from CDN in flv format (video H264 and audio AAC) and remux to them to MP4 format. But videos are limited by length. So i've downloaded each video in several parts: started at start point, at point 1, at point 2 (by using seek parameter in url). Each point starts little earlier than ending of previous one. Using av_read_frame i scanned all parts and found that intersecting packets not only have same sizes and order but also their dts/pts shifted from each other by

How to encode h.264 with libavcodec/x264?

淺唱寂寞╮ 提交于 2019-11-29 19:39:21
I am attempting to encode video using libavcodec/libavformat. Audio works great, but when I try to encode video I get the following errors: [libx264 @ 0x10182a000]broken ffmpeg default settings detected [libx264 @ 0x10182a000]use an encoding preset (vpre) easy to fix using the command line ffmpeg, but I am trying to do this in C. my options are AVStream *pVideoOutStream = av_new_stream(pOutFormatCtx, 0); AVCodecContext *pVideoOutCodecCtx = pVideoOutStream->codec; pVideoOutCodecCtx->codec_id = CODEC_ID_H264; pVideoOutCodecCtx->codec_type = CODEC_TYPE_VIDEO; pVideoOutCodecCtx->bit_rate =

How to load correct libavcodec.so shared library version? (53)

早过忘川 提交于 2019-11-29 16:45:58
I am using libavcodec and libavformat in my project but when I execute a binary which was built on another machine, I get the following error: error while loading shared libraries: libavcodec.so.53: cannot open shared object file: No such file or directory I installed ffmpeg with libav and trying the following commands: sudo apt-get install ffmpeg libavcodec-dev libavformat-dev sudo apt-get install ffmpeg libavcodec-extra-53 sudo apt-get install libav-tools The error doesnt show up when I build the binary on the same machine, but it would be much faster to compile on a second machine. UDPATE:

ffmpeg: RGB to YUV conversion loses color and scale

巧了我就是萌 提交于 2019-11-29 08:51:03
I am trying to convert RGB frames to YUV420P format in ffmpeg/libav. Following is the code for conversion and also the images before and after conversion. The converted image loses all color information and also the scale changes significantly. Does anybody have idea how to handle this? I am completely new to ffmpeg/libav! // Did we get a video frame? if(frameFinished) { i++; sws_scale(img_convert_ctx, (const uint8_t * const *)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize); //============================================================== AVFrame