Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
rtmp Videos encoded with FFmpeg play too fast
30 janvier 2016, par 江嘉荣play back too fast and loading Every once in a while
here is the code ... please help...
pFormatCtx = avformat_alloc_context(); out_filename = "rtmp://192.168.1.105:1935/jc"; avformat_alloc_output_context2(&pFormatCtx, ofmt, "flv", out_filename); ofmt = pFormatCtx->oformat; if (avio_open(&pFormatCtx->pb,out_filename, AVIO_FLAG_WRITE) < 0){ printf("Failed to open output file! \n"); return -1; } video_st = avformat_new_stream(pFormatCtx, 0); video_st->time_base.num = 1; video_st->time_base.den = 30; br = 400 * 1000; pCodecCtx = video_st->codec; pCodecCtx->codec_id = AV_CODEC_ID_H264; pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO; pCodecCtx->pix_fmt = PIX_FMT_YUV420P; pCodecCtx->gop_size = 12; pCodecCtx->max_qdiff = 4; pCodecCtx->qmin = 0; pCodecCtx->qmax = 51; pCodecCtx->bit_rate = br; pCodecCtx->rc_min_rate =br; pCodecCtx->rc_max_rate = br; pCodecCtx->bit_rate_tolerance = br; pCodecCtx->rc_buffer_size=br; pCodecCtx->rc_initial_buffer_occupancy = pCodecCtx->rc_buffer_size*3/4; pCodecCtx->time_base.num = 1; pCodecCtx->time_base.den = 30; start_time = 0; pCodecCtx->max_b_frames = 3; AVDictionary *param = 0; if(pCodecCtx->codec_id == AV_CODEC_ID_H264) { av_dict_set(¶m, "preset", "ultrafast", 0); av_dict_set(¶m, "tune", "zerolatency", 0); av_dict_set(¶m, "max_delay", "500", 0); } av_dump_format(pFormatCtx, 0, out_filename, AVIO_FLAG_WRITE); pCodec = avcodec_find_encoder(AV_CODEC_ID_H264); avformat_write_header(pFormatCtx, NULL); y_size = pCodecCtx->width * pCodecCtx->height; return 0;
get pFrame
pFrame->width = encoder_h264_frame_width; pFrame->height = encoder_h264_frame_height; pFrame->format = PIX_FMT_YUV420P;
I don't know if it's right way to set the pFrame->pts here...
pFrame->pts = av_rescale_q(framecnt, pCodecCtx->time_base, video_st- >codec->time_base); avpicture_fill((AVPicture *)pFrame, picture_buf, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height); pkt.data = NULL; pkt.size = 0; int got_picture = 0; int ret = avcodec_encode_video2(pCodecCtx, &pkt, pFrame, &got_picture); framecnt++; if(ret < 0) { } if (got_picture=) { pkt.stream_index = video_st->index;
is it right ?
pkt.pts = av_rescale_q(pkt.pts, video_st->codec->time_base, video_st->time_base); pkt.dts = av_rescale_q(pkt.dts, video_st->codec->time_base, video_st->time_base); ret = av_interleaved_write_frame(pFormatCtx, &pkt); } av_frame_free(&pFrame); av_free_packet(&pkt); free(yuv420_data);
This problem has troubled me for a lot of days....
-
Installing ffmpeg on CentOS 6.6
30 janvier 2016, par Kristaps DrozdovskisIm trying to install ffmpeg,.. When I write comand:
git clone --depth 1 http://source.ffmpeg.org/git/ffmpeg.git
I got this error.. why??
Initialized empty Git repository in /root/ffmpeg_sources/ffmpeg/ffmpeg/.git/ fatal: dumb http transport does not support --depth
Installing from this source.. https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
-
How to convert the MP4 video file from images without audio using FFMPEG ?
30 janvier 2016, par Rama LingamI am converting the MP4 video file
$output
from some images and one audio file. But now I want to convert the same MP4 video file without audio. How to do it?Here is my sample code:
// Convert Video from audio and images exec("$ffmpeg -framerate 1/5 -i $convImgPath -i $convAudioPath -c:v libx264 -c:a aac -strict experimental -b:a 16k -shortest $output");
Please update my code where I am change.
-
Is it possible install only ffprobe ? [on hold]
30 janvier 2016, par Kristaps Drozdovskisi have installed ffmpeg. But missed ffprobe. Is it posible to install only ffprobe? I have looked all around.. but can't find a answer.
-
Compile error when using ffmpeg
30 janvier 2016, par polinI've found a strange problem during the compile of an example of ffmpeg in Qt Mac.
I have installed the ffmpeg library and I have tested the examples of this with cc and gcc compiler on the terminal, and I don't have any problem in the case of compile and run.
But when I call the library (ffmpeg are C library) in Qt for compile the same code of the example, the g++ compiler give me many error.
I have used this structure in the main.cpp code:
#include "mainwindow.h" #include "ui_mainwindow.h" #include
extern "C" { #include imgutils.h> #include samplefmt.h> #include timestamp.h> #include avformat.h> } #include and the Compile Output gives me:
In file included from ../audvid/main.cpp:7: /opt/local/include/libavutil/timestamp.h: In function 'char* av_ts_make_string(char*, int64_t)': /opt/local/include/libavutil/timestamp.h:48: warning: comparison between signed and unsigned integer expressions /opt/local/include/libavutil/timestamp.h:49: error: expected `)' before 'PRId64' /opt/local/include/libavutil/timestamp.h:49: warning: spurious trailing '%' in format /opt/local/include/libavutil/timestamp.h:49: warning: too many arguments for format /opt/local/include/libavutil/timestamp.h: At global scope: /opt/local/include/libavutil/timestamp.h:68: error: 'AVRational' has not been declared /opt/local/include/libavutil/timestamp.h: In function 'char* av_ts_make_time_string(char*, int64_t, int*)': /opt/local/include/libavutil/timestamp.h:70: warning: comparison between signed and unsigned integer expressions /opt/local/include/libavutil/timestamp.h:71: error: 'av_q2d' was not declared in this scope ../audvid/main.cpp: In function 'int decode_packet(int*, int)': ../audvid/main.cpp:50: error: cannot convert 'AVRational*' to 'int*' for argument '3' to 'char* av_ts_make_time_string(char*, int64_t, int*)' ../audvid/main.cpp:73: error: cannot convert 'AVRational*' to 'int*' for argument '3' to 'char* av_ts_make_time_string(char*, int64_t, int*)' ../audvid/main.cpp:75: error: 'struct AVFrame' has no member named 'channels' ../audvid/main.cpp:84: error: 'struct AVFrame' has no member named 'channels' ../audvid/main.cpp:90: error: 'struct AVFrame' has no member named 'channels' ../audvid/main.cpp: In function 'int open_codec_context(int*, AVFormatContext*, AVMediaType)': ../audvid/main.cpp:112: error: 'av_get_media_type_string' was not declared in this scope ../audvid/main.cpp:123: error: 'av_get_media_type_string' was not declared in this scope ../audvid/main.cpp:129: error: 'av_get_media_type_string' was not declared in this scope ../audvid/main.cpp: In function 'int get_format_from_sample_fmt(const char**, AVSampleFormat)': ../audvid/main.cpp:152: warning: comparison between signed and unsigned integer expressions ../audvid/main.cpp: In function 'int main(int, char**)': ../audvid/main.cpp:239: error: invalid conversion from 'void*' to 'uint8_t**' make: *** [main.o] Error 1 make: Leaving directory `/Users/polin/Desktop/audvid/audvid-build- Qt_4_8_0_qt_everywhere_opensource_src_4_8_0_tp-Release' 10:44:37: The process "/usr/bin/make" exited with code 2. Error while building/deploying project audvid (target: Qt 4.8.0 (qt-everywhere-opensource-src-4.8.0-tp)) When executing step 'Make'
I don't understand if I make a mistake in the code or if I must change the Qt compiler? (and I don't know how can do this)