
Recherche avancée
Médias (16)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Sur d’autres sites (1907)
-
ffmpeg used vda from os x
13 mai 2014, par user2618420I try to enable hardware decoding project earlier decoded using ffmpeg
ffmpeg has support in hard-copy decoding
Here documentation kotoroya I did https://github.com/dilaroga/ffmpeg-vda/wiki/FFmpeg-vda-usage
my codeenum AVPixelFormat myGetFormatCallback(struct AVCodecContext *ctx, const enum AVPixelFormat * fmt)
{
struct vda_context *vda_ctx;
vda_ctx = (struct vda_context *)malloc(sizeof(vda_context));
vda_ctx->decoder = NULL;
vda_ctx->width = ctx->width;
vda_ctx->height = ctx->height;
vda_ctx->format = 'avc1';
vda_ctx->use_ref_buffer = 1;
switch (ctx->pix_fmt) {
case PIX_FMT_UYVY422:{
vda_ctx->cv_pix_fmt_type = '2vuy';
break;
}
case PIX_FMT_YUYV422:{
vda_ctx->cv_pix_fmt_type = 'yuvs';
break;
}
case PIX_FMT_NV12:{
vda_ctx->cv_pix_fmt_type = '420v';
break;
}
case PIX_FMT_YUV420P:{
vda_ctx->cv_pix_fmt_type = 'y420';
break;
}
default:{
av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", ctx->pix_fmt);
Logger::debug(LOG_LEVEL_ERROR, "Unsupported pixel format: %d", ctx->pix_fmt);
throw AbstractException("Unsupported pixel format");
}
}
int status = ff_vda_create_decoder(vda_ctx, (unsigned char*)ctx->extradata,ctx->extradata_size);
if (status){
Logger::debug(LOG_LEVEL_ERROR, "Error create VDA decoder");
throw AbstractException("Error create VDA decoder");
}else{
ctx->hwaccel_context = vda_ctx;
}
return ctx->pix_fmt;
}
static void release_vda_context(void *opaque, uint8_t *data)
{
vda_buffer_context *vda_context = (vda_buffer_context *)opaque;
av_free(vda_context);
}
int myGetBufferCallback(struct AVCodecContext *s, AVFrame *av_frame, int flags)
{
vda_buffer_context *vda_context = (vda_buffer_context *)av_mallocz(sizeof(*vda_context));
AVBufferRef *buffer = av_buffer_create(NULL, 0, release_vda_context, vda_context, 0);
if( !vda_context || !buffer )
{
av_free(vda_context);
return -1;
}
av_frame->buf[0] = buffer;
av_frame->data[0] = (uint8_t*)1;
return 0;
}
static void release_buffer(struct AVCodecContext *opaque, AVFrame *pic)
{
vda_buffer_context *context = (vda_buffer_context*)opaque;
CVPixelBufferUnlockBaseAddress(context->cv_buffer, 0);
CVPixelBufferRelease(context->cv_buffer);
av_free(context);
}
main(){
//init ff context
if (avcodec_open2(mCodecContext, mCodec, NULL) < 0) throw AbstractException("Unable to open codec");
mCodecContext->get_format = myGetFormatCallback;
mCodecContext->get_buffer2 = myGetBufferCallback;
mCodecContext->release_buffer = release_buffer;
}but I did not myGetFormatCallback the method is called, and called myGetBufferCallback falls
why not called myGetFormatCallback ? what’s wrong ? may not work well at all -
libx264 encoder video plays too fast
23 avril 2014, par NickI’m trying to write a program that uses libx264 to encode the video frames. I’ve wrapped this code into a small class (see below). I have frames that are in YUV420 format. libx264 encodes the frames and I save them to a file. I can play the file back in VLC, all of the frames are there, but it plays back at several hundred times the actual frame rate. Currently I am capturing frames at 2.5 FPS, but they play back as if it was recorded at 250 or more FPS. I’ve tried to change the frame rate with no luck.
I’ve also tried to set
_param.b_vfr_input = 1
and then set the time bases appropriately, but that causes my program to crash. Any ideas ? My encode code is shown below. I’ve also included the output of ffprobe -show_frames
Wrapper Class :
x264wrapper::x264wrapper(int width, int height, int fps, int timeBaseNum, int timeBaseDen, int vfr)
{
x264_param_default_preset(&_param, "veryfast", "zerolatency");
_param.i_threads = 1;
_param.i_width = width;
_param.i_height = height;
_param.i_fps_num = fps;
_param.i_fps_den = 1;
// Intra refres:
_param.i_keyint_max = fps;
_param.b_intra_refresh = 1;
//Rate control:
_param.rc.i_rc_method = X264_RC_CRF;
//_param.rc.i_rc_method = X264_RC_CQP;
_param.rc.f_rf_constant = 25;
_param.rc.f_rf_constant_max = 35;
//For streaming:
_param.b_repeat_headers = 1;
_param.b_annexb = 1;
// misc
_param.b_vfr_input = vfr;
_param.i_timebase_num = timeBaseNum;
_param.i_timebase_den = timeBaseDen;
_param.i_log_level = X264_LOG_DEBUG;
_encoder = x264_encoder_open(&_param);
cout << "Timebase " << _param.i_timebase_num << "/" << _param.i_timebase_den << endl;
cout << "fps " << _param.i_fps_num << "/" << _param.i_fps_den << endl;
_ticks_per_frame = (int64_t)_param.i_timebase_den * _param.i_fps_den / _param.i_timebase_num / _param.i_fps_num;
cout << "ticks_per_frame " << _ticks_per_frame << endl;
int result = x264_picture_alloc(&_pic_in, X264_CSP_I420, width, height);
if (result != 0)
{
cout << "Failed to allocate picture" << endl;
throw(1);
}
_ofs = new ofstream("output.h264", ofstream::out | ofstream::binary);
_pts = 0;
}
x264wrapper::~x264wrapper(void)
{
_ofs->close();
}
void x264wrapper::encode(uint8_t * buf)
{
x264_nal_t* nals;
int i_nals;
convertFromBalserToX264(buf);
_pts += _ticks_per_frame;
_pic_in.i_pts = _pts;
x264_picture_t pic_out;
int frame_size = x264_encoder_encode(_encoder, &nals, &i_nals, &_pic_in, &pic_out);
if (frame_size >= 0)
{
_ofs->write((char*)nals[0].p_payload, frame_size);
}
else
{
cout << "error: x264_encoder_encode failed" << endl;
}
}Output of ffprobe -show_frames :
[FRAME]
media_type=video
key_frame=1
pkt_pts=N/A
pkt_pts_time=N/A
pkt_dts=N/A
pkt_dts_time=N/A
pkt_duration=48000
pkt_duration_time=0.040000
pkt_pos=0
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=I
coded_picture_number=0
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
reference=0
[/FRAME]
[FRAME]
media_type=video
key_frame=0
pkt_pts=N/A
pkt_pts_time=N/A
pkt_dts=N/A
pkt_dts_time=N/A
pkt_duration=N/A
pkt_duration_time=N/A
pkt_pos=54947
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=1
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
reference=0
[/FRAME]
[FRAME]
media_type=video
key_frame=0
pkt_pts=N/A
pkt_pts_time=N/A
pkt_dts=N/A
pkt_dts_time=N/A
pkt_duration=N/A
pkt_duration_time=N/A
pkt_pos=57899
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=2
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
reference=0
[/FRAME] -
OpenCV Java binds VideoCapture from file failing silently
8 décembre 2014, par muz0I’m using OpenCV 2.4.8 with the supplied Windows 64bit Java jar. I’ve been making full use of OpenCV in my current environment up until this point.
I’m unable to open video files using the
VideoCapture
class however webcam feeds work just fine.The below works as expected with
video.isOpened
returning trueVideoCapture video = new VideoCapture();
boolean result = video.open(0);The below fails with
video.isOpened
returning falseVideoCapture video = new VideoCapture();
boolean result = video.open("res/hand-test-1.mp4");Neither file formats seems to make a difference (These are converted, not just renamed in hope)
video.open("res/hand-test-1.mp4");
video.open("res/hand-test-1.avi");
video.open("res/hand-test-1.wmv");Location seems to matter not either.
video.open("C:/hand-test-1.mp4");
video.open("C:\\hand-test-1.mp4");
video.open("hand-test-1.mp4");Neither does garbage, no exception kicked up from OpenCV through Java either, seems to fail silently.
video.open("ashdkfhkajsjdfkhaksdf");
PATH contains the ffmpeg directory supplied with the opencv installation,
C:\dev\opencv\sources\3rdparty\ffmpeg
Right now I’ve run out of ideas, it seems like whatever I throw to the native via
video.open(String)
will return false.Any help would be much appreciated