Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Feasibility of Decoupling DVB subtitle functionality from ffmpeg
10 octobre 2011, par AlsWe are trying to implement a DVB subtitle decoder using ffmpeg, We only need to use this particular feature(subtitle-libav codec) of
ffmpeg
Since we already have our own implementations for the other features. We noticed that the code imlpementation which does this is limited to a few number of files, but we are not sure how easily this can be decoupled from theffmpeg
.
So, the Q is:
Is is it feasible to customize/refactor theffmpeg
so that we can decouple the DVB subtitle functionality for our use, And how advicable it is to do so? -
Converting YUV420SP to YUV420P
10 octobre 2011, par limitfanHow do I to convert YUV420SP to YUV420P using ffmpeg sws_scale or another efficient method?
-
iPhone ffmpeg dev using libav to decode from AMR to ACC codec
10 octobre 2011, par VictorTIt seems to be that, the AMR support of AudioQueue has been disappeared since iOS 4.3 was released. I can't use audio frame received from RSTP server with old way:
audioFormat.mFormatID = kAudioFormatAMR; int err = AudioQueueNewOutput(&audioFormat, MyAudioQueueOutputCallback, self, NULL, kCFRunLoopCommonModes, 0, &audioQueue);
As a result I received an error in last string.
Maybe someone know how to decode AMR AVPacket into raw buffer and encode it with AAC or MP3 using LIBAV?
I've tried to use
avcodec_decode_audio3
It works and I can get raw buffer but when I'm trying to encode it with
avcodec_encode_audio
I get 0 as result
This is my method to encode buffer:
- (AVPacket) encodeRawFrame:(const short *) in_buffer withSize:(unsigned int) in_buf_byte_size { AVPacket res; AVCodec *codec; AVCodecContext *c= NULL; int count, out_size, outbuf_size, frame_byte_size; uint8_t *outbuf; avcodec_init(); avcodec_register_all(); printf("Audio encoding\n"); codec = avcodec_find_encoder(CODEC_ID_AAC); if (!codec) { fprintf(stderr, "codec not found\n"); return res; } c= avcodec_alloc_context(); c->bit_rate = 64000; c->sample_rate = 24000; c->channels = 2; if (avcodec_open(c, codec) < 0) { fprintf(stderr, "could not open codec\n"); } else { frame_byte_size=c->frame_size*2*2; count = in_buf_byte_size/frame_byte_size; fprintf(stderr, "Number of frames: %d\n", count); outbuf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; outbuf = (uint8_t*) malloc(outbuf_size); out_size = avcodec_encode_audio(c, outbuf, outbuf_size, &in_buffer[frame_byte_size*i]); if(out_size >= 0) { res.size = outbuf_size; res.data = malloc(outbuf_size); } free(outbuf); } avcodec_close(c); av_free(c); return res; }
After encoding "out_size" is always 0 and result buffer is empty.
Thanks.
-
saving H.264 encoded images with libavcodec
8 octobre 2011, par user846400I am getting H.264 images from an IP camera and want to save the encoded images (without decoding). I am using output-example.c from ffmpeg (libavformat/output-example.c) for this purpose. For Saving the raw H.264 image, I do the following:
AVPacket pkt; av_init_packet(&pkt); if (c->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base); if(c->coded_frame->key_frame) pkt.flags |= PKT_FLAG_KEY; pkt.stream_index= st->index; pkt.data= (uint8_t *)ulAddr;//video_outbuf; pkt.size= out_size; save_image(pkt.data, out_size);
Where ulAddr is the address pointer to the image and out_size is the image size. Instead of saving the images to a media video file, I want to save the individual images. save_image function simply uses basic fopen and fwrite functions for saving the images. If I decode the frame and then save, everything works fine. But I have problem saving the encoded frames. The encoded frames are saved with a very small size and then they cannot be decoded. Is there anything wrong? I will really appreciate any help in this regard.
-
FFMpeg generating screenshots drop frames
6 octobre 2011, par MorganI'm using FFMpeg to extract frames from a video file, and for most videos it works flawlessly. But certain videos it seems to have to seek to the position that I want to take the screenshot from, and drops all the frames on the way there taking quite a while if the position i'm generating a screenshot from is near the end of the video. Here is the command I'm using to extract my screenshot.
ffmpeg -ss 60 -i input.mkv -vframes 1 -f image2 -an -r 1/5 output.jpg
and the output I receive
ffmpeg version 0.8.3, Copyright (c) 2000-2011 the FFmpeg developers built on Sep 20 2011 00:46:47 with clang 2.1 (tags/Apple/clang-163.7.1) configuration: --prefix=/Users/Morgan/Downloads/installed/ffmpeg --extra-libs=/Users/Morgan/Downloads/installed/lib/libfaac.a --enable-gpl --extra-cflags=-I/Users/Morgan/Downloads/installed/include --disable-ffplay --disable-ffserver --disable-shared --disable-debug --extra-ldflags=-L/Users/Morgan/Downloads/installed/lib --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-nonfree --cc=clang libavutil 51. 9. 1 / 51. 9. 1 libavcodec 53. 7. 0 / 53. 7. 0 libavformat 53. 4. 0 / 53. 4. 0 libavdevice 53. 1. 1 / 53. 1. 1 libavfilter 2. 23. 0 / 2. 23. 0 libswscale 2. 0. 0 / 2. 0. 0 libpostproc 51. 2. 0 / 51. 2. 0 [matroska,webm @ 0x7f9dd3007c00] Estimating duration from bitrate, this may be inaccurate Seems stream 0 codec frame rate differs from container frame rate: 47.95 (500000/10427) -> 23.98 (24000/1001) Input #0, matroska,webm, from 'input.mkv': Duration: 01:01:36.16, start: 0.000000, bitrate: 576 kb/s Stream #0.0(eng): Video: h264 (High), yuv420p, 1280x720, PAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: title : Input Video Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s (default) Metadata: title : English Dolby Digital 5.1 AC3 Stream #0.2(eng): Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s Metadata: title : Commentary Stream #0.3(eng): Subtitle: [0][0][0][0] / 0x0000 (default) Metadata: title : English Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p' [buffer @ 0x106c10c00] w:1280 h:720 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param: [buffersink @ 0x106c10e40] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out' [scale @ 0x106c11140] w:1280 h:720 fmt:yuv420p -> w:1280 h:720 fmt:yuvj420p flags:0x4 Output #0, image2, to 'output.jpg': Metadata: encoder : Lavf53.4.0 Stream #0.0(eng): Video: mjpeg, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 0.20 tbc (default) Metadata: title : Input Video Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop, [?] for help frame= 0 fps= 0 q=0.0 Lsize= -0kB time=00:00:00.00 bitrate= 0.0kbits/s dup=0 drop=275 video:0kB audio:0kB global headers:0kB muxing overhead -inf%