From cehoyos at ag.or.at Sat Dec 1 00:30:02 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 30 Nov 2012 23:30:02 +0000 (UTC) Subject: [Libav-user] Uploading large video files to bugtracker/ftp? References: Message-ID: Matthew Einhorn writes: > There's an option to attach a file to the bug report, > but I imagine 300MB is too much. It is not, there is no hard filesize limit. To elaborate a bit what is written on http://ffmpeg.org/bugreports.html : There were many bugreports in the past (esp. crashes) were 10MB is far too much, 100k were often enough. I remember a bug about a buggy first frame in a an asf stream, the user uploaded 30MB, one would have been more than enough. Otoh, if you want to report A/V sync issues with a HD stream, 100MB can be appropriate (or even not enough). So you should upload enough to (very easily) reproduce your problem, not ten times as much. Use tools/qt-faststart to produce a mov file that you can cut with dd. Carl Eugen From secu_tech at yahoo.com Sat Dec 1 08:43:29 2012 From: secu_tech at yahoo.com (amir amir) Date: Fri, 30 Nov 2012 23:43:29 -0800 (PST) Subject: [Libav-user] Request Message-ID: <1354347809.92641.YahooMailNeo@web164506.mail.gq1.yahoo.com> Dear Sir/Madam, Hello, Is there any plugin or API Ref or any vendor that enables the FFMPEG run on GPU in order to make use of the GPU acceleration? Best Regards, Reza Hosseini -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Sat Dec 1 11:59:29 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sat, 1 Dec 2012 10:59:29 +0000 (UTC) Subject: [Libav-user] Request References: <1354347809.92641.YahooMailNeo@web164506.mail.gq1.yahoo.com> Message-ID: amir amir writes: > Is there any plugin or API Ref or any vendor that enables > the FFMPEG run on GPU in order to make use of the GPU > acceleration? FFmpeg contains code to support VDPAU, VA-API, DXVA2 and vda, see MPlayer and vlc for examples on how to use them. libstagefright is supported for h264. Carl Eugen From secu_tech at yahoo.com Sat Dec 1 12:15:13 2012 From: secu_tech at yahoo.com (amir amir) Date: Sat, 1 Dec 2012 03:15:13 -0800 (PST) Subject: [Libav-user] Request In-Reply-To: References: <1354347809.92641.YahooMailNeo@web164506.mail.gq1.yahoo.com> Message-ID: <1354360513.28198.YahooMailNeo@web164505.mail.gq1.yahoo.com> Dear Carl, I am really new to FFMPEG. it is a very comprehensive project. could you please give me links of Mplayer and VLC and examples how to use the GPU-acceleration? Many thanks ________________________________ From: Carl Eugen Hoyos To: libav-user at ffmpeg.org Sent: Saturday, December 1, 2012 2:29 PM Subject: Re: [Libav-user] Request amir amir writes: > Is there any plugin or API Ref or any vendor that enables > the FFMPEG run on GPU in order to make use of the GPU > acceleration? FFmpeg contains code to support VDPAU, VA-API, DXVA2 and vda, see MPlayer and vlc for examples on how to use them. libstagefright is supported for h264. Carl Eugen _______________________________________________ Libav-user mailing list Libav-user at ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Sat Dec 1 15:52:51 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sat, 1 Dec 2012 14:52:51 +0000 (UTC) Subject: [Libav-user] Request References: <1354347809.92641.YahooMailNeo@web164506.mail.gq1.yahoo.com> <1354360513.28198.YahooMailNeo@web164505.mail.gq1.yahoo.com> Message-ID: amir amir writes: > I am really new to FFMPEG. it is a very comprehensive project. > could you please give me links of Mplayer and VLC www.mplayerhq.hu www.videolan.org > and examples how to use the GPU-acceleration? For vdpau, look at libvo/vo_vdpau.c in MPlayer, I don't know where you find the relevant code in vlc. Carl Eugen From igorm at stats.com Sat Dec 1 00:41:15 2012 From: igorm at stats.com (Morduhaev, Igor (igorm@stats.com)) Date: Fri, 30 Nov 2012 23:41:15 +0000 Subject: [Libav-user] How to create video using avcodec from OpenCV::Mat? Message-ID: I get colored jpeg images of OpenCV::Mat type and I create from them video using avcodec. The video that I get is upside-down, black & white and each row of each frame is shifted and I got diagonal line. What could be the reason for such output? Follow this link (https://picasaweb.google.com/lh/photo/ZNQeoPw8YFBa-iFpzuYi4dMTjNZETYmyPJy0liipFm0?feat=directlink) to watch the video I get using avcodec. I'm using acpicture_fill to create avFrame from cv::Mat frame! P.S. Each cv::Mat cvFrame has width=810, height=610, step=2432 I noticed that avFrame (that is filled by acpicture_fill) has linesize[0]=2430 I tried manually setting avFrame->linesizep0]=2432 and not 2430 but it still didn't helped. ======== CODE ========================================================= AVCodec *encoder = avcodec_find_encoder(AV_CODEC_ID_H264); AVStream *outStream = avformat_new_stream(outContainer, encoder); avcodec_get_context_defaults3(outStream->codec, encoder); outStream->codec->pix_fmt = AV_PIX_FMT_YUV420P; outStream->codec->width = 810; outStream->codec->height = 610; //... SwsContext *swsCtx = sws_getContext(outStream->codec->width, outStream->codec->height, PIX_FMT_RGB24, outStream->codec->width, outStream->codec->height, outStream->codec->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL); for (uint i=0; i < frameNums; i++) { // get frame at location I using OpenCV cv::Mat cvFrame; myReader.getFrame(cvFrame, i); cv::Size frameSize = cvFrame.size(); //Each cv::Mat cvFrame has width=810, height=610, step=2432 // create AVPicture from cv::Mat frame avpicture_fill((AVPicture*)avFrame, cvFrame.data, PIX_FMT_BGR24, outStream->codec->width, outStream->codec->height); avFrame->width = frameSize.width; avFrame->height = frameSize.height; // rescale to outStream format sws_scale(swsCtx, avFrame->data, avFrame->linesize, 0, outStream->codec->height, avFrameRescaledFrame->data, avFrameRescaledFrame ->linesize); encoderRescaledFrame->pts=i; avFrameRescaledFrame->width = frameSize.width; avFrameRescaledFrame->height = frameSize.height; av_init_packet(&avEncodedPacket); avEncodedPacket.data = NULL; avEncodedPacket.size = 0; // encode rescaled frame if(avcodec_encode_video2(outStream->codec, &avEncodedPacket, avFrameRescaledFrame, &got_frame) < 0) exit(1); if(got_frame) { if (avEncodedPacket.pts != AV_NOPTS_VALUE) avEncodedPacket.pts = av_rescale_q(avEncodedPacket.pts, outStream->codec->time_base, outStream->time_base); if (avEncodedPacket.dts != AV_NOPTS_VALUE) avEncodedPacket.dts = av_rescale_q(avEncodedPacket.dts, outStream->codec->time_base, outStream->time_base); // outContainer is "mp4" av_write_frame(outContainer, & avEncodedPacket); av_free_packet(&encodedPacket); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: From rjvbertin at gmail.com Sun Dec 2 17:16:09 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Sun, 2 Dec 2012 17:16:09 +0100 Subject: [Libav-user] ffmpeg default for -b:v ? Message-ID: <0C6D0D09-7F61-419B-AF5C-6F140A28E646@gmail.com> Hello list, A couple of questions about the way ffmpeg handles bit rates while converting: I'm using ffmpeg to convert a raw m4v file into a .mov container. The input file does not have any information about its frequency, size or bitrate in the header, so everything comes from the individual packets (frames). When I repackage (-vcodec copy), I obtain a .mov at 12Hz, with a bitrate of approximately 4000kb/s. Questions: - when encoding, say to mjpeg, what is the bitrate chosen by ffmpeg when one doesn't specify a rate explicitely? - to obtain a .mov with approximately 4000kb/s, I need to add -b:v 1000k under Mac OS X, but -b:v 2000kb/s on win32 ... why this difference (and why don't I get a rate closer to the requested rate)? Thanks in advance, Ren? From cehoyos at ag.or.at Sun Dec 2 17:27:40 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sun, 2 Dec 2012 16:27:40 +0000 (UTC) Subject: [Libav-user] ffmpeg default for -b:v ? References: <0C6D0D09-7F61-419B-AF5C-6F140A28E646@gmail.com> Message-ID: Ren? J.V. Bertin writes: > - when encoding, say to mjpeg, what is the bitrate chosen > by ffmpeg when one doesn't specify a rate explicitely? 200kb > - to obtain a .mov with approximately 4000kb/s, I need to > add -b:v 1000k under Mac OS X, but -b:v 2000kb/s on win32 Sounds unlikely / command line(s) and complete, uncut console output missing. > why this difference > (and why don't I get a rate closer to the requested rate)? Are you using 1-pass or 2-pass encoding? Carl Eugen From adrozdoff at gmail.com Mon Dec 3 08:59:58 2012 From: adrozdoff at gmail.com (hatred) Date: Mon, 3 Dec 2012 18:59:58 +1100 Subject: [Libav-user] AVFilterGraph, AVFilterContext and AVFilterInOut together Message-ID: Hi List! AVFilterInOut is linked list that we can pass to avfilter_graph_parse/avfilter_graph_parse2. More interesting use case where we pass this list to avfilter_graph_parse(): as I understand I must fill fields with valid values, so I have a question: Does filter context that stored in 'filter_ctx' field should be also registered in FilterGraph (like with avfilter_graph_create_filter(), avfilter_graph_add_filter())? -------------- next part -------------- An HTML attachment was scrubbed... URL: From aw.wisch at googlemail.com Mon Dec 3 15:55:16 2012 From: aw.wisch at googlemail.com (Alexander Wischnewski) Date: Mon, 3 Dec 2012 22:55:16 +0800 Subject: [Libav-user] How to connect to an IP camera in libav In-Reply-To: <005301cdce32$7705fc20$6511f460$@caelumspace.com> References: <005301cdce32$7705fc20$6511f460$@caelumspace.com> Message-ID: Hello Brian, not long ago i ran into a similar problem so i have a clue what it could be. In some cases, when it comes to receiving a live stream, you have to tell ffmpeg which format the input should have. Attached you find some code how to do that, i am using it for several mjpeg cameras. AVInputFormat* avInformat = NULL; avInformat = av_find_input_format("mjpeg"); if(avformat_open_input(&pFormatCtx, path, avInformat, NULL)!=0) { ... Best regards, Alex Am 29.11.2012 21:07 schrieb "Brian Martin" : > Hello,**** > > ** ** > > I?m trying to connect to a Foscam MJpeg IP camera (http) using libav on > Windows and am getting an error code of -5 after **** > > ** ** > > AVFormatContext *pFormatCtx=NULL;**** > > int i, videoStream;**** > > AVCodecContext *pCodecCtx;**** > > AVCodec *pCodec;**** > > AVFrame *pFrame; **** > > AVFrame *pFrameRGB;**** > > AVPacket packet;**** > > int frameFinished;**** > > int numBytes;**** > > uint8_t *buffer;**** > > struct SwsContext *img_convert_ctx;**** > > int frameCount=0;**** > > ** ** > > if(!videoStreamAddress) {**** > > printf("Please provide a movie file\n");** > ** > > return -1;**** > > }**** > > // Register all formats and codecs**** > > av_register_all();**** > > avformat_network_init();**** > > ** ** > > //Open video file**** > > if(avformat_open_input(&pFormatCtx, videoStreamAddress, > NULL, NULL)!=0)**** > > {**** > > printf("Couldn't open file %s\n", > videoStreamAddress);**** > > return -1; // Couldn't open file**** > > }**** > > ** ** > > I tried to get the string value of this error but am getting a write > protected memory error using the built-in av_strerror command.**** > > Any ideas would be appreciated. Thanks!**** > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rafi.fisher at wywy.com Mon Dec 3 16:52:57 2012 From: rafi.fisher at wywy.com (Rafi Fisher) Date: Mon, 3 Dec 2012 17:52:57 +0200 Subject: [Libav-user] problem while using swresample library Message-ID: hello i'm using *swresample lib*. my code is used to convert mp2 or mp4 into wav file. the code fragment : ....... SwrContext *swr = swr_alloc(); ret = av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_STEREO, 0); ret = av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, 0); ret = av_opt_set_int(swr, "in_sample_rate", IN_SAMPLE_RATE, 0); ret = av_opt_set_int(swr, "out_sample_rate", OUT_SAMPLE_RATE, 0); ret = av_opt_set_int(swr, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0); ret = av_opt_set_int(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); ret = swr_init(swr); ....... out_samples = swr_convert(swr, output, out_samples,(const uint8_t **) (inframe->data), in_samples); if out_channel_layout = AV_CH_LAYOUT_ STEREO resampling works fine if out_channel_layout = AV_CH_LAYOUT_MONO & other set options remain same it fails that is: the swr_convert fails that is somwhere inside the code of this function there is a call to* exit* which is problematic by itself (exit a program from av. library) instead of returning some error code. help will be appreciated thanks rafi -------------- next part -------------- An HTML attachment was scrubbed... URL: From moiein2000 at gmail.com Mon Dec 3 22:26:11 2012 From: moiein2000 at gmail.com (Matthew Einhorn) Date: Mon, 3 Dec 2012 16:26:11 -0500 Subject: [Libav-user] Uploading large video files to bugtracker/ftp? In-Reply-To: References: Message-ID: On Fri, Nov 30, 2012 at 6:30 PM, Carl Eugen Hoyos wrote: > Matthew Einhorn writes: > > > There's an option to attach a file to the bug report, > > but I imagine 300MB is too much. > > It is not, there is no hard filesize limit. > > To elaborate a bit what is written on > http://ffmpeg.org/bugreports.html : > There were many bugreports in the past (esp. > crashes) were 10MB is far too much, 100k were > often enough. I remember a bug about a buggy > first frame in a an asf stream, the user > uploaded 30MB, one would have been more than > enough. Otoh, if you want to report A/V sync > issues with a HD stream, 100MB can be appropriate > (or even not enough). So you should upload enough > to (very easily) reproduce your problem, not ten > times as much. > > Use tools/qt-faststart to produce a mov file > that you can cut with dd. > qt-faststart with dd did the trick. On a side note, I initially tried to make qt-faststart on Windows in cygwin, however, I kept getting this error "make: *** No rule to make target `tools/qt-faststart'. Stop." But when I did the identical think on ubuntu it worked perfectly. I'm not that good with scripts so I'm not exactly sure how to debug this. But I did run configure successfully in cygwin. But it's not that important. Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Mon Dec 3 23:30:41 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Mon, 3 Dec 2012 22:30:41 +0000 (UTC) Subject: [Libav-user] Uploading large video files to bugtracker/ftp? References: Message-ID: Matthew Einhorn writes: > On a side note, I initially tried to make > qt-faststart on Windows in cygwin, however, > I kept getting this error "make: *** No rule > to make target `tools/qt-faststart'.? Stop." My guess is that you have to do: $ make tools/qt-faststart.exe Carl Eugen From moiein2000 at gmail.com Tue Dec 4 00:37:38 2012 From: moiein2000 at gmail.com (Matthew Einhorn) Date: Mon, 3 Dec 2012 18:37:38 -0500 Subject: [Libav-user] Uploading large video files to bugtracker/ftp? In-Reply-To: References: Message-ID: On Mon, Dec 3, 2012 at 5:30 PM, Carl Eugen Hoyos wrote: > > Matthew Einhorn writes: > > > On a side note, I initially tried to make > > qt-faststart on Windows in cygwin, however, > > I kept getting this error "make: *** No rule > > to make target `tools/qt-faststart'. Stop." > > My guess is that you have to do: > $ make tools/qt-faststart.exe You're right, that did the trick. Thanks, Matt From stefasab at gmail.com Tue Dec 4 11:14:59 2012 From: stefasab at gmail.com (Stefano Sabatini) Date: Tue, 4 Dec 2012 11:14:59 +0100 Subject: [Libav-user] problem while using swresample library In-Reply-To: References: Message-ID: <20121204101458.GG2959@arborea> On date Monday 2012-12-03 17:52:57 +0200, Rafi Fisher encoded: > hello > > i'm using *swresample lib*. my code is used to convert mp2 or mp4 into > wav file. > the code fragment : > ....... > > SwrContext *swr = swr_alloc(); > ret = av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_STEREO, 0); > ret = av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, > 0); > ret = av_opt_set_int(swr, "in_sample_rate", IN_SAMPLE_RATE, 0); > ret = av_opt_set_int(swr, "out_sample_rate", OUT_SAMPLE_RATE, 0); > ret = av_opt_set_int(swr, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0); > ret = av_opt_set_int(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); > ret = swr_init(swr); > > ....... > > out_samples = swr_convert(swr, output, out_samples,(const uint8_t **) > (inframe->data), in_samples); > if out_channel_layout = AV_CH_LAYOUT_ STEREO resampling works fine > > if out_channel_layout = AV_CH_LAYOUT_MONO & other set options remain > same it fails that is: > > the swr_convert fails that is somwhere inside the code of this function > there is a call to* exit* which is problematic by itself (exit a program from av. library) > instead of returning some error code. > There is no call to exit() in libswresample, it seems more likely like a crash. Make sure that you correctly allocated the samples buffers. Also check my recently posted resampling example: http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/155151 > help will be appreciated thanks rafi -- FFmpeg = Forgiving and Fostering Mega Puristic Explosive Genius From stefasab at gmail.com Tue Dec 4 11:29:50 2012 From: stefasab at gmail.com (Stefano Sabatini) Date: Tue, 4 Dec 2012 11:29:50 +0100 Subject: [Libav-user] How to create video using avcodec from OpenCV::Mat? In-Reply-To: References: Message-ID: <20121204102950.GH2959@arborea> On date Friday 2012-11-30 23:41:15 +0000, Morduhaev, Igor (igorm at stats.com) encoded: > I get colored jpeg images of OpenCV::Mat type and I create from them video using avcodec. The video that I get is upside-down, black & white and each row of each frame is shifted and I got diagonal line. What could be the reason for such output? > Follow this link (https://picasaweb.google.com/lh/photo/ZNQeoPw8YFBa-iFpzuYi4dMTjNZETYmyPJy0liipFm0?feat=directlink) to watch the video I get using avcodec. > I'm using acpicture_fill to create avFrame from cv::Mat frame! > > P.S. > Each cv::Mat cvFrame has width=810, height=610, step=2432 > I noticed that avFrame (that is filled by acpicture_fill) has linesize[0]=2430 > I tried manually setting avFrame->linesizep0]=2432 and not 2430 but it still didn't helped. > > > ======== CODE ========================================================= > > AVCodec *encoder = avcodec_find_encoder(AV_CODEC_ID_H264); > AVStream *outStream = avformat_new_stream(outContainer, encoder); > avcodec_get_context_defaults3(outStream->codec, encoder); > > outStream->codec->pix_fmt = AV_PIX_FMT_YUV420P; > outStream->codec->width = 810; > outStream->codec->height = 610; > //... > > SwsContext *swsCtx = sws_getContext(outStream->codec->width, outStream->codec->height, PIX_FMT_RGB24, > outStream->codec->width, outStream->codec->height, outStream->codec->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL); > > for (uint i=0; i < frameNums; i++) > { > // get frame at location I using OpenCV > cv::Mat cvFrame; > myReader.getFrame(cvFrame, i); > cv::Size frameSize = cvFrame.size(); > //Each cv::Mat cvFrame has width=810, height=610, step=2432 > > > // create AVPicture from cv::Mat frame > avpicture_fill((AVPicture*)avFrame, cvFrame.data, PIX_FMT_BGR24, outStream->codec->width, outStream->codec->height); avpicture_fill() assumes aligned data, which is not your case. Check av_image_fill_arrays(), or simply set the linesize to the correct value (which is 2432 if I understand correctly). Also this code is potentially inconsistent, since you read the size from outStream (which may be totally unrelated). > avFrame->width = frameSize.width; > avFrame->height = frameSize.height; > > // rescale to outStream format > sws_scale(swsCtx, avFrame->data, avFrame->linesize, 0, outStream->codec->height, avFrameRescaledFrame->data, avFrameRescaledFrame ->linesize); From rafi.fisher at wywy.com Tue Dec 4 17:29:42 2012 From: rafi.fisher at wywy.com (Rafi Fisher) Date: Tue, 4 Dec 2012 18:29:42 +0200 Subject: [Libav-user] problem while using swresample library In-Reply-To: <20121204101458.GG2959@arborea> References: <20121204101458.GG2959@arborea> Message-ID: hello the above problem was solved. since i did not have the latest ffmpeg libs version downloaded. still i have some problem when for example transcoding : from: mp4 file 48khz 16bit stereo downsampled to to : wav file 11khz 16bit stereo i dont get the same wav file compared to the wav file i got by ruuning the ffmpeg.exe utility my file size is smaller & the quality of the audio less good compared to the ffmpeg.exe wav file. do you have an idea why i get different results ? because when i transcode without downsampling i get excatlly the same wav file. thanks a lot rafi On Tue, Dec 4, 2012 at 12:14 PM, Stefano Sabatini wrote: > On date Monday 2012-12-03 17:52:57 +0200, Rafi Fisher encoded: > > hello > > > > i'm using *swresample lib*. my code is used to convert mp2 or mp4 into > > wav file. > > the code fragment : > > ....... > > > > SwrContext *swr = swr_alloc(); > > ret = av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_STEREO, > 0); > > ret = av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, > > 0); > > ret = av_opt_set_int(swr, "in_sample_rate", IN_SAMPLE_RATE, > 0); > > ret = av_opt_set_int(swr, "out_sample_rate", OUT_SAMPLE_RATE, > 0); > > ret = av_opt_set_int(swr, "in_sample_fmt", AV_SAMPLE_FMT_S16, > 0); > > ret = av_opt_set_int(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, > 0); > > ret = swr_init(swr); > > > > ....... > > > > out_samples = swr_convert(swr, output, out_samples,(const uint8_t **) > > (inframe->data), in_samples); > > if out_channel_layout = AV_CH_LAYOUT_ STEREO resampling works fine > > > > if out_channel_layout = AV_CH_LAYOUT_MONO & other set options remain > > same it fails that is: > > > > > the swr_convert fails that is somwhere inside the code of this > function > > there is a call to* exit* which is problematic by itself (exit a > program from av. library) > > instead of returning some error code. > > > > There is no call to exit() in libswresample, it seems more likely like > a crash. Make sure that you correctly allocated the samples buffers. > > Also check my recently posted resampling example: > http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/155151 > > > help will be appreciated thanks rafi > -- > FFmpeg = Forgiving and Fostering Mega Puristic Explosive Genius > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwoods at vaytek.com Tue Dec 4 22:05:39 2012 From: rwoods at vaytek.com (Ron Woods) Date: Tue, 4 Dec 2012 15:05:39 -0600 Subject: [Libav-user] warbly audio playback when syncing to video Message-ID: <27FB82F7EB0DA04C92361A01E7BA9A9301A71DF829A5@GODFATHERII.vaytek2003.local> In a video previewer that I am writing, I am trying to synchronize the audio to the video as in ffplay.c with av_sync_type = AV_SYNC_VIDEO_MASTER. The resulting audio seems to be in sync with the video; however, it is warbly, like it's playing through water or something. Obviously, I am missing something in mimicking the technique from ffplay.c In synchronize_audio() of ffplay.c, there is this line: diff = get_audio_clock(is) - get_master_clock(is); I am using the get_audio_clock() as in ffplay, but for the get_master_clock(), I am using a custom get_video_clock() directly, as I will always be syncing to the video. However, I am not using the same function as in ffplay.c, because I am not handling the video stream through a PacketQueue. My app performs video analysis on the video frames as they are decoded and then passes them to a Windows C# UI for display and optional saving to disk. The throughput of the video analysis drives the video playback. That is, when it is done processing a frame, then it requests the next one. If the processing takes less time than a frame interval, then I insert a delay to ensure that the playback is close to real time for the user. (Maybe this is not the best design?) Therefore, I would like the audio to follow the video. The problem seems to be in getting the proper value for the video "clock". To this end, I have been using a function as in Dranger's tutorial06.c: double get_video_clock(VideoState *is) { double delta; delta = (av_gettime() - video_current_pts_time) / 1000000.0; return video_current_pts + delta; } where delta is amount of time since the video_current_pts was obtained. Seems to me that this should work in my context, yet the result is not yet acceptable. If I change the function to simply return video_current_pts; Then the warble is more pronounced. How do I get the audio to properly synchronize with the video? -------------- next part -------------- An HTML attachment was scrubbed... URL: From barikondunar at hotmail.com Wed Dec 5 11:51:12 2012 From: barikondunar at hotmail.com (Dolevo Jay) Date: Wed, 5 Dec 2012 10:51:12 +0000 Subject: [Libav-user] avcodec_decode_video2 problem Message-ID: Hi experts, I am having a problem when I am decoding my encoded data which is done by x264_encoder_encode. Basically, I get a frame and encode it with h264_encoder_encode. Then I send the NAL to the decoder and there I try to decode it with avcodec_decode_video2. The problem is, lenDecoded = avcodec_decode_video2(c1, av_pic, &got_picture, &pkt); lenDecoded returns always -1 and got_picture returns always 0 while "no frame!" error appears on the screen. I waited some time, I thought that it needs some time to decode but no joy. I will provide you all the code here and I am expecting your priceless guidance and help. Thank you. //ENCODING PARAMETERS, It is currently set for zero latency and ultra fast encoding. void SetParameters(EncoderType et, int aWidth, int aHeight, int quantizationFactor, int gopSize ) { //////// convertCtx = sws_getContext(aWidth, aHeight, PIX_FMT_RGB24, aWidth, aHeight, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL); x264_picture_alloc(&pic_in, X264_CSP_I420, aWidth, aHeight); //memory allocation for being encoded data. srcstride = aWidth*3; //RGB stride is just 3*width //////// Framebuffersize=0; x264_param_default( ?m ); x264_param_default_preset(?m, "veryfast", "zerolatency"); //Default preset. Framebuffer = (uint8_t*) malloc(MAX_FRAME_SIZE); mux_buffer_size = 0; mux_buffer = NULL; //Set video resolution param.i_width = aWidth; param.i_height = aHeight; //We don't need bframe param.i_bframe = 0; //param.i_bframe_adaptive = 0; //Maximum dimension of the gop param.i_keyint_min = 2; param.i_keyint_max = 5; param.rc.i_lookahead = 0; param.i_threads = 1; //param.i_sync_lookahead = 0; //More high, more compressed but loss quality quantization_factor = 30; //Setting CRF param.rc.i_rc_method = X264_RC_CRF; //Specify quality of encoding param.rc.f_rf_constant = quantization_factor; //only pass1 mode for low latency param.rc.b_stat_read = 0; param.rc.b_stat_write = 1; param.i_threads = 1; //The number of threads that x264 will use param.i_width = aWidth; param.i_height = aHeight; param.i_fps_num = 5; //Apparently GOP size param.i_fps_den = 1; // Intra refres: param.b_intra_refresh = 1; //Rate control: param.rc.i_rc_method = X264_RC_CRF; param.rc.f_rf_constant = 25; param.rc.f_rf_constant_max = 35; //For streaming: param.b_annexb = 1; param.b_repeat_headers = 1; //my params: param.i_log_level = X264_LOG_DEBUG; //AA added param.i_bframe_adaptive = 0; param.rc.i_lookahead = 0; param.i_bframe = 0; param->i_frame_reference = 1; param->i_scenecut_threshold = 0; param->b_deblocking_filter = 0; param->b_cabac = 0; param->i_bframe = 0; param->analyse.intra = 0; param->analyse.inter = 0; param->analyse.b_transform_8x8 = 0; param->analyse.i_me_method = X264_ME_DIA; param->analyse.i_subpel_refine = 0; param->rc.i_aq_mode = 0; param->analyse.b_mixed_references = 0; param->analyse.i_trellis = 0; x264_param_apply_profile(?m, "baseline"); //baseline profile is selected. //If ultrafast flag is enabled the transcoding latency is reduced, //the bandwith of the encoder is also duplicated, but the dimension //of the encoded frame increase, also by a factor of 2 if(et == X264_ULTRAFAST) { setParamForUltrafastEncoding( ?m ); } //Open the encoder if( ( h = x264_encoder_open( ?m ) ) == NULL ) { fprintf( stderr, "x264 [error]: x264_encoder_open failed\n" ); exit(1); } this->quantization_factor = quantizationFactor; //param.i_keyint_max = gopSize; } //ENCODING STARTS HERE void mpStartEncodingFrame(const char ** bits, int aWidth, int aHeight, int mvGOPsize, qint32 tstamp) { sws_scale(convertCtx, (uint8_t**)bits, &srcstride, 0, aHeight, pic_in.img.plane, pic_in.img.i_stride); pic_in.i_dts=tstamp; pic_in.i_type = X264_TYPE_I; pic_in.i_qpplus1 = 0; int a = Encode_frame( h , &pic_in ); //The encoded data (Framebuffer) is here sent to the decoder side, free(pBits); } //Actual encoding, int Encode_frame( x264_t *h, x264_picture_t *pic ) { int i_nal, i_nalu_size; i_nalu_size = 0; int frame_size=x264_encoder_encode( h, &nal, &i_nal, pic, &pic_out ); if(i_nal>1) int yy=1; if( frame_size < 0 ) { fprintf( stderr, "x264 [error]: x264_encoder_encode failed\n" ); return -1; } memcpy(Framebuffer, nal[0].p_payload, frame_size); Framebuffersize = frame_size; return Framebuffersize; } //DECODING int decoderDecodeFrame(uint8_t* buffer, int buffersize) { AVPacket pkt; int got_picture = 0, lenDecoded; av_init_packet(&pkt); AVFormatContext *a; AVCodecContext *c1; avcodec_register_all(); av_init_packet(&pkt); codec = avcodec_find_decoder(CODEC_ID_H264); if ( !codec ) { fprintf(stderr, "[avcodec][Err] codec not found!\n"); exit(1); } c1 = avcodec_alloc_context3(codec); c1->width = 1600; c1->height = 900; c1->codec_id = CODEC_ID_H264; c1->codec_type = AVMEDIA_TYPE_VIDEO; av_pic = avcodec_alloc_frame(); if(codec->capabilities&CODEC_CAP_TRUNCATED) c1->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ /* open it */ if (avcodec_open2(c1, codec, NULL) < 0) { fprintf(stderr, "[avcodec][Err] could not open codec\n"); exit(1); } pkt.data=buffer; pkt.size=buffersize; lenDecoded = avcodec_decode_video2(c1, av_pic, &got_picture, &pkt); if (lenDecoded < 0) { fprintf(stderr, "Error while decoding frame %d\n %d", av_pic, lenDecoded); exit(1); } if (got_picture) printf("OK"); return 1; return 0; } -------------- next part -------------- An HTML attachment was scrubbed... URL: From rafi.fisher at wywy.com Wed Dec 5 14:51:17 2012 From: rafi.fisher at wywy.com (Rafi Fisher) Date: Wed, 5 Dec 2012 15:51:17 +0200 Subject: [Libav-user] some problem in using swresample library Message-ID: hello hello i have some problem when for example transcoding : from: mp4 file 48khz 16bit stereo downsampled to to : wav file 11khz 16bit stereo using swresample functions. i dont get the same wav file compared to the wav file i got by running the ffmpeg.exe utility i use ffmpeg.exe as the standart. my file size is smaller & the quality of the audio less good compared to the ffmpeg.exe wav file. do you have an idea why i get different results ? but when i transcode from mp2/mp4 to wav file without downsampling i get excatlly the same wav file as i get from the ffmpeg utility thanks a lot rafi -------------- next part -------------- An HTML attachment was scrubbed... URL: From panzhaotai at gmail.com Wed Dec 5 07:02:41 2012 From: panzhaotai at gmail.com (zt p) Date: Wed, 5 Dec 2012 14:02:41 +0800 Subject: [Libav-user] example code of H264 decoder using ffmpeg 1.0 Message-ID: Dear all, Is there any example code to decode H264 video using ffmpeg 1.0? It seems the interfaces of ffmpeg 1.0 are different from ffmpeg 0.7. Best regards, Zhaotai -------------- next part -------------- An HTML attachment was scrubbed... URL: From panzhaotai at gmail.com Wed Dec 5 14:51:05 2012 From: panzhaotai at gmail.com (zt p) Date: Wed, 5 Dec 2012 21:51:05 +0800 Subject: [Libav-user] avcodec_decode_video2 gets wrong frame dimensions Message-ID: Hi, I'm using ffmpeg1.0 (with code name of "Angle") as H264 decoder, following the sample code in doc/examples/decoding_encoding.c. I use it to decode a compressed H264 bit stream. The resolution is 1280x800. However, after calling avcodec_decode_video2, coded_width = 800 and codec_height = 1280, while width = 0 and height = 1280. It seems that the values of width and height are exchanged. Is it a bug? Regards, Zhaotai -------------- next part -------------- An HTML attachment was scrubbed... URL: From billconan at gmail.com Wed Dec 5 23:52:56 2012 From: billconan at gmail.com (Shi Yan) Date: Wed, 5 Dec 2012 14:52:56 -0800 Subject: [Libav-user] unable to decode h264 video within mp4 Message-ID: May I ask you a question regarding h264 decoding with libavcodec? I?m working on a launch animation for our application. The animation is a h264 mp4 file. I?m not very familiar with video decoding, I started by following this tutorial: http://blog.tomaka17.com/2012/03/libavcodeclibavformat-tutorial/ I verified the tutorial can work fine on other video formats, for example mpeg, but can?t work on h264. The reason is that a call to this function: const auto processedLength = avcodec_decode_video2(avCodecContext, avFrame, &isFrameAvailable, &packetToSend); if (processedLength < 0) { av_free_packet(&packet); qDebug() << "Error while processing the data"; exit(0); } Always returns -1. libav prints an error "no frame!" or "nal is a large number". I know that there could be missing nal header that I need to tell the decoder. But I couldn't find any articles about how to do it. I?m stuck here. Thank you, This is my code: avcodec_init(); av_register_all(); av_log_set_callback(my_log_callback); av_log_set_level(AV_LOG_DEBUG); AVFormatContext *formatContext = avformat_alloc_context(); if (av_open_input_file(&formatContext, "C:\\ani.mp4", NULL, NULL, NULL) != 0) { qDebug() << "can't open animation"; } if (av_find_stream_info(formatContext) < 0) { qDebug() << "can't find stream info"; } AVStream* videoStream; for (unsigned int i = 0; i < formatContext->nb_streams; ++i) { AVStream *stream = formatContext->streams[i]; // pointer to a structure about the stream AVMediaType codecType = stream->codec->codec_type; // the type of data in this stream, notable values are AVMEDIA_TYPE_VIDEO and AVMEDIA_TYPE_AUDIO CodecID codecID = stream->codec->codec_id; // identifier for the codec qDebug() <<"media type"<< codecType << "codec_id:" << codecID; if (codecType == AVMEDIA_TYPE_VIDEO) { videoStream = stream; } } AVCodec *codec = avcodec_find_decoder(videoStream->codec->codec_id); if (codec == NULL) { qDebug() << "can't create codec"; } AVCodecContext *avCodecContext = avcodec_alloc_context2(videoStream->codec->codec_type); avCodecContext->width = 1920; avCodecContext->height = 1080; //avCodecContext->flags2 |= CODEC_FLAG2_FAST; avCodecContext->pix_fmt = (enum PixelFormat)29; if (avcodec_open(avCodecContext,codec ) < 0) { qDebug() << "can't open animation file"; } qDebug() << "codec width:" << avCodecContext->width << "height:" << avCodecContext->height <pix_fmt ; AVFrame * avFrame =avcodec_alloc_frame(); if (avFrame == NULL) { qDebug() << "can't allocation avFrame"; } avcodec_get_frame_defaults(avFrame); // the current packet of data AVPacket packet; av_init_packet(&packet); packet.size = 0; // data in the packet of data already processed size_t offsetInData = 0; // the decoding loop, running until EOF while (true) { // reading a packet using libavformat if (offsetInData >= packet.size) { av_free_packet(&packet); while (true) { if (av_read_frame(formatContext, &packet) < 0) { qDebug() << "EOF"; goto finished; } if (packet.stream_index == videoStream->index) break; av_free_packet(&packet); } } qDebug() << "packet" << packet.size; // preparing the packet that we will send to libavcodec AVPacket packetToSend; packetToSend.data = packet.data + offsetInData; packetToSend.size = packet.size - offsetInData; // sending data to libavcodec int isFrameAvailable = 0; const auto processedLength = avcodec_decode_video2(avCodecContext, avFrame, &isFrameAvailable, &packetToSend); if (processedLength < 0) { av_free_packet(&packet); qDebug() << "Error while processing the data"; exit(0); } qDebug() << "processed Length:" << processedLength; offsetInData += processedLength; // processing the image if available if (isFrameAvailable) { qDebug() << "one frame is ready!"; } } finished: -------------- next part -------------- An HTML attachment was scrubbed... URL: From drrobison at openroadsconsulting.com Fri Dec 7 00:35:21 2012 From: drrobison at openroadsconsulting.com (David R Robison) Date: Thu, 06 Dec 2012 18:35:21 -0500 Subject: [Libav-user] Duplicate frames? Message-ID: <50C12BB9.6010907@openroadsconsulting.com> I am having a problem with poor quality of H.264 video. I've turned on some debugging and I'm getting the following output from within decode_slice_header in h264.c [8288] slice:1 T mb:0 P fix pps:0 frame:23 poc:65582/2147483647/65582 ref:1/1 qp:24 loop:1:0:0 weight:0 [8288] slice:1 B mb:0 P fix pps:0 frame:23 poc:65582/65583/65582 ref:1/1 qp:24 loop:1:0:0 weight:0 [8288] slice:1 T mb:0 P fix pps:0 frame:24 poc:65584/2147483647/65584 ref:1/1 qp:24 loop:1:0:0 weight:0 [8288] slice:1 T mb:0 P fix pps:0 frame:24 poc:65584/2147483647/65584 ref:1/1 qp:24 loop:1:0:0 weight:0 [8288] mmco: unref short failure [8288] mmco: unref short failure I've added the current POC at the end of POC[0] and POC[1]. Am I correct in assuming that the last two slices are the same slice being processed twice? David -- David R Robison Open Roads Consulting, Inc. 103 Watson Road, Chesapeake, VA 23320 phone: (757) 546-3401 e-mail: drrobison at openroadsconsulting.com web: http://openroadsconsulting.com blog: http://therobe.blogspot.com book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526 This email communication (including any attachments) may contain confidential and/or privileged material intended solely for the individual or entity to which it is addressed. If you are not the intended recipient, please delete this email immediately. From cehoyos at ag.or.at Fri Dec 7 00:37:16 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 6 Dec 2012 23:37:16 +0000 (UTC) Subject: [Libav-user] Duplicate frames? References: <50C12BB9.6010907@openroadsconsulting.com> Message-ID: David R Robison writes: > I am having a problem with poor quality of H.264 video. Can you reproduce the poor quality with ffmpeg (the application)? If yes, please provide command line together with complete, uncut console output. Carl Eugen From amir.rouhi at rmit.edu.au Fri Dec 7 00:37:50 2012 From: amir.rouhi at rmit.edu.au (Rouhi Amirhossein2) Date: Fri, 7 Dec 2012 10:37:50 +1100 Subject: [Libav-user] Mapping functions of intra-prediction Message-ID: Hi Guys I need just those functions of ffmpeg, that produces intra-prediction modes. Do you know which functions are they? i want to use them separately in another program. Cheers Amir -------------- next part -------------- An HTML attachment was scrubbed... URL: From phamsyquybk at gmail.com Fri Dec 7 01:50:18 2012 From: phamsyquybk at gmail.com (Quy Pham Sy) Date: Fri, 7 Dec 2012 09:50:18 +0900 Subject: [Libav-user] How can i suspend ffmpeg's file reading? Message-ID: Hi, My ffmpeg-based player plays a mpeg-ts file that downloaded from a server. I want my player be able to play the video file even when it is being downloaded. There is no problem if the download speed is faster than reading speed, otherwise, it just stop playing. My question is that is there anyway to suspend ffmpeg file reading to wait for data available to proceed? Thanks Jack -------------- next part -------------- An HTML attachment was scrubbed... URL: From jettoblack at gmail.com Fri Dec 7 04:05:39 2012 From: jettoblack at gmail.com (Jason Livingston) Date: Thu, 6 Dec 2012 22:05:39 -0500 Subject: [Libav-user] Options to minimize decoder CPU use Message-ID: Hello, When decoding MPEG-2 or H.264 video with lavc, what decoder flags or options can I use to decode as quickly as possible? I have zero concern for the quality of the decoded picture (my application does not even need the image), just as long as no frames are dropped or skipped. I see AVCodecContext has some options such as skip_idct and skip_loop_filter, which I set to AVDISCARD_ALL, but at least for MPEG-2 the decode is not significantly faster. Are there any other good options to use? Thanks! From cehoyos at ag.or.at Fri Dec 7 09:33:25 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 7 Dec 2012 08:33:25 +0000 (UTC) Subject: [Libav-user] Options to minimize decoder CPU use References: Message-ID: Jason Livingston writes: > When decoding MPEG-2 or H.264 video with lavc, what decoder > flags or options can I use to decode as quickly as possible? Do I understand you correctly that you want to maximize CPU use? [...] > I see AVCodecContext has some options such as skip_idct and > skip_loop_filter, which I set to AVDISCARD_ALL, but at least > for MPEG-2 the decode is not significantly faster. Could you elaborate? Skipping idct makes a large difference here for mpeg-2 decoding. Perhaps test with the cli (ffmpeg -benchmark -skip_idct) and post some output. > Are there any other good options to use? You can use "fast" if you know that the input is valid (not corrupt) but it does not add much additional speedup. Carl Eugen From rjvbertin at gmail.com Fri Dec 7 11:32:15 2012 From: rjvbertin at gmail.com (=?ISO-8859-1?Q?Ren=E9_J=2EV=2E_Bertin?=) Date: Fri, 07 Dec 2012 11:32:15 +0100 Subject: [Libav-user] How can i suspend ffmpeg's file reading? In-Reply-To: References: Message-ID: Hello Jack How do you launch ffmpeg and on what os? If you have a process id for it, you could sigstop/suspend it while you wait for data, but that too would of course halt the playing. I've never tried, but I suspect that it would however resume playing when you sigcont/release the process. Alternatively, buffer your stream, measuring download speed and expected bitrate during playback, so that you can launch ffmpeg only when you have downloaded enough content to be reasonably sure that you won't catch up with the download head. This is more or less how QuickTime handles streaming playback, but it isn't failure proof against net congestion or other unforeseen events. Ren? Quy Pham Sy wrote: >Hi, > >My ffmpeg-based player plays a mpeg-ts file that downloaded from a >server. >I want my player be able to play the video file >even when it is being downloaded. > >There is no problem if the download speed is faster than reading speed, >otherwise, it just stop playing. >My question is that is there anyway to suspend ffmpeg file reading to >wait >for data available to proceed? > >Thanks >Jack > > >------------------------------------------------------------------------ > >_______________________________________________ >Libav-user mailing list >Libav-user at ffmpeg.org >http://ffmpeg.org/mailman/listinfo/libav-user From rjvbertin at gmail.com Fri Dec 7 12:35:12 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Fri, 7 Dec 2012 12:35:12 +0100 Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? Message-ID: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> I discovered yesterday that it's possible to split an input movie (a raw m4v stream) into 4 separate output movies (.mov) each containing a quarter of the original image (obtained with -vf crop=w/2:h/2:x:y), using a single invocation of ffmpeg. Is it possible to generate a single output movie with 4 tracks instead, either in that same invocation (would make most sense, I presume) or else by piping the output into a separate ffmpeg command? Thanks in advance! Ren? From cehoyos at ag.or.at Fri Dec 7 13:19:02 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 7 Dec 2012 12:19:02 +0000 (UTC) Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> Message-ID: Ren? J.V. Bertin writes: > I discovered yesterday that it's possible to split an input > movie (a raw m4v stream) into 4 separate output movies (.mov) > each containing a quarter of the original image (obtained with > -vf crop=w/2:h/2:x:y), using a single invocation of ffmpeg. > Is it possible to generate a single output movie with 4 > tracks instead The complex filter allows this, please RTFM for examples. Carl Eugen From rjvbertin at gmail.com Fri Dec 7 16:33:28 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Fri, 7 Dec 2012 16:33:28 +0100 Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? In-Reply-To: References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> Message-ID: Are we really speaking about the same thing, generating multiple tracks in a QuickTime movie, and not a track with 4 overlays or a multi-channel (audio) track? May I ask what the name of the filter is that merges the crop filter outputs in 4 tracks in a single output (not overlay, not amerge ... I must have overlooked the relevant one)? For reference, what I'm doing now is create a pipe to ffmpeg -y -v 1 -i - -vf crop=360:288:0:0 -b:v 500k -vcodec mjpeg cam1.mov -vcodec mjpeg -vf crop=360:288:360:0 -b:v 500k cam2.mov -vf crop=360:288:0:288 -vcodec mjpeg -b:v 500k cam3.mov -vf crop=360:288:360:288 -vcodec mjpeg -b:v 500k cam4.mov to generate single-track 4 quicktime movies from an m4v 4000kbit/s stream that contains the recorded output of 4 cameras, in 'quad' arrangement. I then combine those 4 movies into a single QuickTime movie with 4 tracks using QuickTime SDK functions. NB: at 12Hz there isn't much gain of mpeg4 encoding over mjpeg encoding, which however plays back much smoother on a wider range of hardware. Ren? On Dec 07, 2012, at 13:19, Carl Eugen Hoyos wrote: > Ren? J.V. Bertin writes: > >> I discovered yesterday that it's possible to split an input >> movie (a raw m4v stream) into 4 separate output movies (.mov) >> each containing a quarter of the original image (obtained with >> -vf crop=w/2:h/2:x:y), using a single invocation of ffmpeg. >> Is it possible to generate a single output movie with 4 >> tracks instead > > The complex filter allows this, please RTFM for examples. > > Carl Eugen From drrobison at openroadsconsulting.com Fri Dec 7 16:41:48 2012 From: drrobison at openroadsconsulting.com (David R Robison) Date: Fri, 07 Dec 2012 10:41:48 -0500 Subject: [Libav-user] Duplicate frames? In-Reply-To: References: <50C12BB9.6010907@openroadsconsulting.com> Message-ID: <50C20E3C.6010300@openroadsconsulting.com> Hmm... So I cannot reproduce it with ffplay. I am using ffmpeg though the ffdshow DirectShow filters. It does appear to be some kind of buffering issue as if I buffer 500ms of video it plays fine, otherwise I get video quality issues. Maybe I need to discuss this with the ffdshow folks. David David R Robison Open Roads Consulting, Inc. 103 Watson Road, Chesapeake, VA 23320 phone: (757) 546-3401 e-mail: drrobison at openroadsconsulting.com web: http://openroadsconsulting.com blog: http://therobe.blogspot.com book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526 On 12/6/2012 6:37 PM, Carl Eugen Hoyos wrote: > David R Robison writes: > >> I am having a problem with poor quality of H.264 video. > Can you reproduce the poor quality with ffmpeg (the application)? > If yes, please provide command line together with complete, uncut > console output. > > Carl Eugen > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user This email communication (including any attachments) may contain confidential and/or privileged material intended solely for the individual or entity to which it is addressed. If you are not the intended recipient, please delete this email immediately. From cehoyos at ag.or.at Fri Dec 7 17:10:45 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 7 Dec 2012 16:10:45 +0000 (UTC) Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> Message-ID: Ren? J.V. Bertin writes: > Are we really speaking about the same thing, generating > multiple tracks in a QuickTime movie, and not a > track with 4 overlays or a multi-channel (audio) track? > May I ask what the name of the filter is that merges > the crop filter outputs in 4 tracks in a single output > (not overlay, not amerge ... I must have overlooked > the relevant one)? $ ffmpeg -i - -filter_complex "split=4 [a][b][c][d]; \ [a]crop=360:288:0:0;[b]crop=360:288:360:0; \ [c]crop=360:288:0:288;[d]crop=360:288:360:288" \ -vcodec mjpeg cam.mov Please do not top-post here, it is considered rude, Carl Eugen From cehoyos at ag.or.at Fri Dec 7 17:14:48 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 7 Dec 2012 16:14:48 +0000 (UTC) Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> Message-ID: Ren? J.V. Bertin writes: > NB: at 12Hz there isn't much gain of mpeg4 encoding over > mjpeg encoding Depending on what you mean with "gain", this is not correct. (Your sentence is equivalent to "intra-only codecs have no real disadvantage over using P and B-frames for sufficiently small fps." And this does not even take into account that I suspect ASP compresses better than jpeg even for images.) Carl Eugen From drrobison at openroadsconsulting.com Fri Dec 7 17:36:09 2012 From: drrobison at openroadsconsulting.com (David R Robison) Date: Fri, 07 Dec 2012 11:36:09 -0500 Subject: [Libav-user] Duplicate frames? In-Reply-To: <50C20E3C.6010300@openroadsconsulting.com> References: <50C12BB9.6010907@openroadsconsulting.com> <50C20E3C.6010300@openroadsconsulting.com> Message-ID: <50C21AF9.8060608@openroadsconsulting.com> After further review, it appears that the problem ceneters around interlaced video. From the logging, the Top field is processed twice (lines 3 & 4) and this seems to cause problems when the Bottom field finally arrives (line 8). Does this make since? Should/could this cause video quality problems? [4064] slice:1 T mb:0 P fix pps:0 frame:8 poc:65552/2147483647/65552 ref:1/1 qp:24 loop:1:0:0 weight:0 [4064] slice:1 B mb:0 P fix pps:0 frame:8 poc:65552/65553/65552 ref:1/1 qp:24 loop:1:0:0 weight:0 [4064] slice:1 T mb:0 P fix pps:0 frame:9 poc:65554/2147483647/65554 ref:1/1 qp:24 loop:1:0:0 weight:0 [4064] slice:1 T mb:0 P fix pps:0 frame:9 poc:65554/2147483647/65554 ref:1/1 qp:24 loop:1:0:0 weight:0 [4064] mmco: unref short failure [4064] mmco: unref short failure [4064] illegal short term buffer state detected [4064] slice:1 B mb:0 P fix pps:0 frame:9 poc:65554/65555/65554 ref:1/1 qp:24 loop:1:0:0 weight:0 David David R Robison Open Roads Consulting, Inc. 103 Watson Road, Chesapeake, VA 23320 phone: (757) 546-3401 e-mail: drrobison at openroadsconsulting.com web: http://openroadsconsulting.com blog: http://therobe.blogspot.com book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526 On 12/7/2012 10:41 AM, David R Robison wrote: > Hmm... So I cannot reproduce it with ffplay. I am using ffmpeg though > the ffdshow DirectShow filters. It does appear to be some kind of > buffering issue as if I buffer 500ms of video it plays fine, otherwise I > get video quality issues. Maybe I need to discuss this with the ffdshow > folks. David > > David R Robison > Open Roads Consulting, Inc. > 103 Watson Road, Chesapeake, VA 23320 > phone: (757) 546-3401 > e-mail: drrobison at openroadsconsulting.com > web: http://openroadsconsulting.com > blog: http://therobe.blogspot.com > book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526 > > On 12/6/2012 6:37 PM, Carl Eugen Hoyos wrote: >> David R Robison writes: >> >>> I am having a problem with poor quality of H.264 video. >> Can you reproduce the poor quality with ffmpeg (the application)? >> If yes, please provide command line together with complete, uncut >> console output. >> >> Carl Eugen >> >> _______________________________________________ >> Libav-user mailing list >> Libav-user at ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/libav-user > > > This email communication (including any attachments) may contain confidential and/or privileged material intended solely for the individual or entity to which it is addressed. > If you are not the intended recipient, please delete this email immediately. > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user This email communication (including any attachments) may contain confidential and/or privileged material intended solely for the individual or entity to which it is addressed. If you are not the intended recipient, please delete this email immediately. From rjvbertin at gmail.com Fri Dec 7 19:00:38 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Fri, 7 Dec 2012 19:00:38 +0100 Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? In-Reply-To: References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> <9925CF46-57D5-45D2-AA98-E9B7E336C6B7@gmail.com> Message-ID: Top-hi :P On Dec 07, 2012, at 18:42, Carl Eugen Hoyos wrote: >> What I mean is the size of the files I get on my sample videos. Guess I should have made that clearer. And of course I never meant to say it depends on the framerate only, evidently it depends on how much the images vary between frames. > > Allow me to repeat that what you believe is simply not true. > If you want me to elaborate, please post on the mailing list. Ok, please do elaborate - but also please accept the fact that I know what I observe ... if you have an alternate explanation I'd love to hear it. > Allow me to add that I had neither used complex_filter nor split filter before, I only used the documentation. > (And it was your luck that I had not read your private mail before searching for an answer.) May I presume that you're both familiar with the general filter syntax and the documentation? I'm not. >> Am I right that there's no filter to control the offsets of the 4 tracks > > There are filters that allow to manipulate the timestamps, yes. That I saw. I'm not talking about temporal offset, but spatial ones (that would allow to layout the tracks such that the original quad image is restored). R. From mpupilli at gmail.com Fri Dec 7 19:51:08 2012 From: mpupilli at gmail.com (Mark Pupilli) Date: Fri, 7 Dec 2012 18:51:08 +0000 Subject: [Libav-user] Double free/corruption problem. Message-ID: I get a double free or corruption problem, should really do a bug report but don't have time to decipher the FFmpeg bug reporting page. I'll post it here in case anyone is interested, feel free to ignore. When using custom IO for reading involves something like the following when creating a context: buffer = (uint8_t*)av_malloc( BUFFER_SIZE ); ctxt = avio_alloc_context( buffer, BUFFER_SIZE, 0, this, read_function, NULL, NULL ); and then to free it: av_free( ctxt ); av_free( buffer ); However, if BUFFER_SIZE > 32768 bytes then av_free( buffer ) results in a crash due to invalid free/delete (which can also be detected by valgrind). Not calling av_free( buffer ) leads to a memory leak (reported by valgrind). In the case of calling av_free() Valgrind reports the buffer as already being free'd in: ==5471== Address 0x9181680 is 0 bytes inside a block of size 32,784 free'd ==5471== at 0x4C2A82E: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5471== by 0x712EC6F: av_free (mem.c:186) ==5471== by 0x6DBEFC4: ffio_set_buf_size (aviobuf.c:707) ==5471== by 0x6DBE1E5: fill_buffer (aviobuf.c:408) ==5471== by 0x6DBE570: avio_read (aviobuf.c:495) ==5471== by 0x6DE8971: ff_id3v2_read (id3v2.c:748) ==5471== by 0x6EA4F42: avformat_open_input (utils.c:638) which if you follow the call in a debugger leads to the culprit at aviobuf.c:408: /* make buffer smaller in case it ended up large after probing */ if (s->read_packet && s->buffer_size > max_buffer_size) { ffio_set_buf_size(s, max_buffer_size); s->checksum_ptr = dst = s->buffer; len = s->buffer_size; } This only gets called when we are reading. So in the case of using custom input libav takes it upon itself to tinker with the user supplied buffer. The crash only occurs if the buffer size is larger than 32KB which in my case it was because I was trying to follow some examples which show allocating (32768 + FF_INPUT_BUFFER_PADDING_SIZE) bytes. I don't know if the bug is that libav is supposed to give an error if the buffer is larger than 32KB, or not tinker with user supplied buffers, or avio_alloc_context should take a ** to the buffer so it can reallocate properly and clients don't have to choose between a double free or a memory leak, but its definitely wrong one way or another. I actually do not understand why the user needs to pass in the buffer at all as it seems avio_alloc_context could do it internally if it is going to reallocate it on a whim anyway. regards, Mark From cehoyos at ag.or.at Sat Dec 8 00:06:12 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 7 Dec 2012 23:06:12 +0000 (UTC) Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> <9925CF46-57D5-45D2-AA98-E9B7E336C6B7@gmail.com> Message-ID: Ren? J.V. Bertin writes: > >> What I mean is the size of the files I get on my sample videos. > >> Guess I should have made that clearer. And of course I never > >> meant to say it depends on the framerate only, evidently it > >> depends on how much the images vary between frames. ("Guess" is probably the right word since it is not easy for me to understand above.) Allow me to repeat: mpeg-4 asp is (at least) one generation ahead of jpeg encoding, I strongly suspect it has advantages when encoding still images (although I don't know of any tests), the two encoders certainly cannot be compared for encoding of a real-world video stream (no matter the framerate) because mpeg-4 will always win a quality / size comparison by a large margin. My guess now is that you argue that for two given codecs (no matter if mjpeg, mpeg-4 asp, mpeg2video, flv1 or snow), the following command line always produces files of nearly identical size: $ ffmpeg -i input -vcodec xxx out.avi This is certainly correct, the reason is that ffmpeg defaults to -vb 200k, so all codecs try to reach the same filesize (that may or may not be reached for given input etc.), the quality will vary significantly because the codecs do not have the same quality. (The order is probably mjpeg->mpeg2video->flv1->mpeg4, with snow having great advantage for small bitrates.) Carl Eugen From rjvbertin at gmail.com Sat Dec 8 02:07:33 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Sat, 8 Dec 2012 02:07:33 +0100 Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? In-Reply-To: References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> <9925CF46-57D5-45D2-AA98-E9B7E336C6B7@gmail.com> Message-ID: <072932B6-EF4B-46C7-B5F9-B8CF0AF7F8B1@gmail.com> On Dec 08, 2012, at 00:06, Carl Eugen Hoyos wrote: > My guess now is that you argue that for two given codecs (no > matter if mjpeg, mpeg-4 asp, mpeg2video, flv1 or snow), the > following command line always produces files of nearly identical > size: > $ ffmpeg -i input -vcodec xxx out.avi No, not always, but for the files I'm working with. When I compare > ffmpeg -i 4000kbaud.m4v -vcodec copy out1.mov > ffmpeg -i 4000kbaud.m4v -vcodec mpeg4 -b:v 4000k out2.mov > ffmpeg -i 4000kbaud.m4v -vcodec mjpeg -b:v 1150k out3.mov I get 3 output movies that are all at (approximately) 4000kbits/s, and all approximately the same size as the input. You may not agree, but it my experience that material that has already been compressed with a lossy codec is often hard to compress further - and in this case the input already shows visible blocking artefacts. In fact, 720x576 @ 12Hz, that gives almost 5000k pixels/s, so if I'm not missing something the content is already compressed to less than a bit per pixel ... and I have no idea if that's stretching it or not, in fact. 'night! R. From cehoyos at ag.or.at Sat Dec 8 19:53:35 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sat, 8 Dec 2012 18:53:35 +0000 (UTC) Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> <9925CF46-57D5-45D2-AA98-E9B7E336C6B7@gmail.com> <072932B6-EF4B-46C7-B5F9-B8CF0AF7F8B1@gmail.com> Message-ID: Ren? J.V. Bertin writes: > On Dec 08, 2012, at 00:06, Carl Eugen Hoyos wrote: > > My guess now is that you argue that for two given codecs (no > > matter if mjpeg, mpeg-4 asp, mpeg2video, flv1 or snow), the > > following command line always produces files of nearly identical > > size: > > $ ffmpeg -i input -vcodec xxx out.avi > > No, not always, but for the files I'm working with. When I compare > > > ffmpeg -i 4000kbaud.m4v -vcodec copy out1.mov > > ffmpeg -i 4000kbaud.m4v -vcodec mpeg4 -b:v 4000k out2.mov > > ffmpeg -i 4000kbaud.m4v -vcodec mjpeg -b:v 1150k out3.mov (I don't think -vcodec mjpeg supports setting a bitrate, sorry I did not really consider this.) > I get 3 output movies that are all at (approximately) > 4000kbits/s, and all approximately the same size as > the input. > You may not agree, but it my experience that material > that has already been compressed with a lossy codec is > often hard to compress further This is true for material that has been compressed with maximum quantiser but this does not seem like a typical use-case to me. Carl Eugen From cehoyos at ag.or.at Sat Dec 8 19:55:20 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sat, 8 Dec 2012 18:55:20 +0000 (UTC) Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> <9925CF46-57D5-45D2-AA98-E9B7E336C6B7@gmail.com> <072932B6-EF4B-46C7-B5F9-B8CF0AF7F8B1@gmail.com> Message-ID: Carl Eugen Hoyos writes: > > You may not agree, but it my experience that material > > that has already been compressed with a lossy codec is > > often hard to compress further > > This is true for material that has been compressed with > maximum quantiser but this does not seem like a typical > use-case to me. And you can of course further compress such material by using some of the picture processing abilities that FFmpeg offers... Carl Eugen From rjvbertin at gmail.com Sat Dec 8 20:14:13 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Sat, 8 Dec 2012 20:14:13 +0100 Subject: [Libav-user] ffmpeg ; splitting an input movie into multiple tracks in a single output movie, possible? In-Reply-To: References: <593F4504-0126-424F-AB65-A38EE4DA0790@gmail.com> <9925CF46-57D5-45D2-AA98-E9B7E336C6B7@gmail.com> <072932B6-EF4B-46C7-B5F9-B8CF0AF7F8B1@gmail.com> Message-ID: <3734DCA9-F0BB-4F6A-91DD-2745B67D73E0@gmail.com> On Dec 08, 2012, at 19:55, Carl Eugen Hoyos wrote: > Carl Eugen Hoyos writes: > >>> You may not agree, but it my experience that material >>> that has already been compressed with a lossy codec is >>> often hard to compress further >> >> This is true for material that has been compressed with >> maximum quantiser but this does not seem like a typical >> use-case to me. > > And you can of course further compress such material by > using some of the picture processing abilities that > FFmpeg offers... > Possibly, but that's not the point here, nor necessary. Maybe for those recordings that approach the maximum size (4Gb), but in that case there'd also be the issue of the transcoding duration. Given the (mediocre) image quality I'd be more interested in an approach without transcoding, but that turns out not to be feasible for playback using the existing QuickTime-based player on win32. It really surprised me that some of the code path could be that badly optimised, but that isn't the point here either :) > (I don't think -vcodec mjpeg supports setting a bitrate, sorry > I did not really consider this.) It clearly doesn't support it as expected, but the option does have an effect. Fortunately ... I don't know if you're the one to suggest this too, but I really feel something like a -b:v auto or -b:v copy is missing (but maybe you'll tell me that it doesn't make sense to transcode while maintaining the original bit rate?) Ren? From bilthon at gmail.com Sun Dec 9 01:19:02 2012 From: bilthon at gmail.com (Nelson Perez) Date: Sat, 8 Dec 2012 22:19:02 -0200 Subject: [Libav-user] Problem with rtmp stream Message-ID: Hi there, I've been experiencing some trouble with a few rtmp streams lately. The context is that I'm trying to capture some streams from street cameras avaiable in the interent. Some cameras are not working though but their streams have not been shut down. What happens then is that since these streams have no data, the play command doesnt do anything. I suppose some socket calls a blocking read somewhere and the program just hangs there. What I would like to have is some sort of timeout of some kind for these "faulty streams". To give you guys an example, here's the command to grab video from a camera that works. ffmpeg -i "rtmp://200.141.78.68:1935/cet-rio/1.stream pageUrl= http://transito.rio.rj.gov.br --live" -vcodec copy -an out.flv And here is an example of the problematic one: ffmpeg -i "rtmp://200.141.78.68:1935/cet-rio/74.stream pageUrl= http://transito.rio.rj.gov.br --live" -vcodec copy -an out.flv Does somebody have a suggestion to fix this issue? Nelson -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Sun Dec 9 10:49:45 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sun, 9 Dec 2012 09:49:45 +0000 (UTC) Subject: [Libav-user] Problem with rtmp stream References: Message-ID: Nelson Perez writes: > ffmpeg -i "rtmp://200.141.78.68:1935/cet-rio/74.stream > pageUrl=http://transito.rio.rj.gov.br --live" -vcodec copy -an out.flv > > > Does somebody have a suggestion to fix this issue? Since I cannot reproduce your issue: Please provide complete, uncut console output. Carl Eugen From donmoir at comcast.net Sun Dec 9 18:04:00 2012 From: donmoir at comcast.net (Don Moir) Date: Sun, 9 Dec 2012 12:04:00 -0500 Subject: [Libav-user] How to connect to an IP camera in libav References: <005301cdce32$7705fc20$6511f460$@caelumspace.com> Message-ID: <892934367069402A98161DBD557A4CEF@MANLAP> > I?m trying to connect to a Foscam MJpeg IP camera (http) using libav on Windows and am getting an error code of -5 after For the foscam F18918W the default http string is: (dont forget &pwd=) http://x.x.x.x/videostream.asf?user=admin&pwd= For a list of possible strings for foscam cameras goto: http://www.ispyconnect.com/man.aspx?n=foscam I dont have any problem connecting but the time is way off like 6 seconds plus so large delay in animation. I am assuming there is a way to control this but after looking around still don't know. If I just ignore the timing its perfect. ffplay has the same problem. I dont care about ffplay and this for internal code. Alex, you got any info on this ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From aw.wisch at googlemail.com Mon Dec 10 03:43:52 2012 From: aw.wisch at googlemail.com (Alexander Wischnewski) Date: Mon, 10 Dec 2012 10:43:52 +0800 Subject: [Libav-user] How to connect to an IP camera in libav In-Reply-To: <892934367069402A98161DBD557A4CEF@MANLAP> References: <005301cdce32$7705fc20$6511f460$@caelumspace.com> <892934367069402A98161DBD557A4CEF@MANLAP> Message-ID: Hello Don, is the *avformat_open_input *function* *taking long or maybe the * avformat_find_stream_info* ? In the second case you have to reduce the maximal analyze duration of the AVFormatContext, you can do it like this: pFormatCtx->max_analyze_duration = 1.0 * AV_TIME_BASE; // Retrieve stream information avformat_find_stream_info(pFormatCtx, NULL) Seems that the default value is set to a very high value to make sure there are all important informations gathered, but this is not necessary for a simple mjpeg stream. I even use this setting for decoding h264 streams and had no problems so far. Best regards, Alex 2012/12/10 Don Moir > ** > > I?m trying to connect to a Foscam MJpeg IP camera (http) using libav on > Windows and am getting an error code of -5 after > > For the foscam F18918W the default http string is: (dont forget &pwd=) > > http://x.x.x.x/videostream.asf?user=admin&pwd= > > For a list of possible strings for foscam cameras goto: > > http://www.ispyconnect.com/man.aspx?n=foscam > > I dont have any problem connecting but the time is way off like 6 seconds > plus so large delay in animation. > > I am assuming there is a way to control this but after looking around > still don't know. > > If I just ignore the timing its perfect. ffplay has the same problem. > > I dont care about ffplay and this for internal code. > > Alex, you got any info on this ? > > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bilthon at gmail.com Mon Dec 10 05:03:07 2012 From: bilthon at gmail.com (Nelson Perez) Date: Mon, 10 Dec 2012 02:03:07 -0200 Subject: [Libav-user] Problem with rtmp stream In-Reply-To: References: Message-ID: My bad, I used the wrong address to illustrate the problem. It actually happens with camera 71. So you should type: ffmpeg -i "rtmp://200.141.78.68:1935/cet-rio/71.stream pageUrl=http://transito.rio.rj.gov.br --live" -vcodec copy -an out.flv I just did it again, this time with a more verbose output, and this is what I get: ---------------------------------------- nelson at rigel:/opt/ffmpeg/ffmpeg$ sudo ./ffmpeg -i "rtmp:// 200.141.78.68:1935/cet-rio/71.stream pageUrl=http://transito.rio.rj.gov.br--live" -vcodec copy -an -loglevel verbose out.flv ffmpeg version N-47645-gf494647 Copyright (c) 2000-2012 the FFmpeg developers built on Dec 8 2012 21:54:25 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1) configuration: --enable-gpl --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3 libavutil 52. 12.100 / 52. 12.100 libavcodec 54. 79.100 / 54. 79.100 libavformat 54. 48.100 / 54. 48.100 libavdevice 54. 3.102 / 54. 3.102 libavfilter 3. 26.101 / 3. 26.101 libswscale 2. 1.103 / 2. 1.103 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 Parsing... Parsed protocol: 0 Parsed host : 200.141.78.68 Parsed app : cet-rio RTMP_Connect1, ... connected, handshaking HandShake: Type Answer : 03 HandShake: Server Uptime : 96850052 HandShake: FMS Version : 3.0.1.1 HandShake: Handshaking finished.... RTMP_Connect1, handshaked Invoking connect HandleServerBW: server BW = 2500000 HandleClientBW: client BW = 2500000 2 HandleCtrl, received ctrl. type: 0, len: 6 HandleCtrl, Stream Begin 0 HandleChangeChunkSize, received: chunk size change to 512 RTMP_ClientPacket, received: invoke 259 bytes (object begin) Property: Property: Property: (object begin) Property: Property: Property: (object end) Property: (object begin) Property: Property: Property: Property: (object begin) Property: (object end) Property: Property: (object end) (object end) HandleInvoke, server invoking <_result> HandleInvoke, received result for method call sending ctrl. type: 0x0003 Invoking createStream RTMP_ClientPacket, received: invoke 29 bytes (object begin) Property: Property: Property: NULL Property: (object end) HandleInvoke, server invoking <_result> HandleInvoke, received result for method call SendPlay, seekTime=0, stopTime=0, sending play: 71.stream Invoking play sending ctrl. type: 0x0003 HandleCtrl, received ctrl. type: 6, len: 6 HandleCtrl, Ping 21175 sending ctrl. type: 0x0007 HandleCtrl, received ctrl. type: 6, len: 6 HandleCtrl, Ping 41580 sending ctrl. type: 0x0007 HandleCtrl, received ctrl. type: 6, len: 6 HandleCtrl, Ping 61860 sending ctrl. type: 0x0007 HandleCtrl, received ctrl. type: 6, len: 6 HandleCtrl, Ping 82265 sending ctrl. type: 0x0007 HandleCtrl, received ctrl. type: 6, len: 6 HandleCtrl, Ping 102857 -------------------------------------- And this goes on forever. I also found this post http://lists.mplayerhq.hu/pipermail/rtmpdump/2010-March/000622.html, which describes the exact problem. But it doesn't look like the problem has been fixed, as the same thing happens even when I try it with rtmpdump v2.4. Any ideas? Nelson On Sun, Dec 9, 2012 at 7:49 AM, Carl Eugen Hoyos wrote: > Nelson Perez writes: > > > ffmpeg -i "rtmp://200.141.78.68:1935/cet-rio/74.stream > > pageUrl=http://transito.rio.rj.gov.br --live" -vcodec copy -an out.flv > > > > > > Does somebody have a suggestion to fix this issue? > > Since I cannot reproduce your issue: > Please provide complete, uncut console output. > > Carl Eugen > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Mon Dec 10 12:14:12 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Mon, 10 Dec 2012 11:14:12 +0000 (UTC) Subject: [Libav-user] Problem with rtmp stream References: Message-ID: Nelson Perez writes: > My bad, I used the wrong address to illustrate the problem. > It actually happens with camera 71. So you should type: > > > ffmpeg -i "rtmp://200.141.78.68:1935/cet-rio/71.stream?pageUrl=http://transito.rio.rj.gov.br?--live" -vcodec copy -an out.flv I originally could not reproduce the problem (ffmpeg immediately exits for me with an appropriate error message), I recompiled with --enable-librtmp and it appears that the bug is in librtmp (which does not return). rtmpdump also hangs: $ rtmpdump -i "rtmp://200.141.78.68:1935/cet-rio/71.stream pageUrl=http://transito.rio.rj.gov.br --live" Carl Eugen From donmoir at comcast.net Mon Dec 10 19:29:48 2012 From: donmoir at comcast.net (Don Moir) Date: Mon, 10 Dec 2012 13:29:48 -0500 Subject: [Libav-user] How to connect to an IP camera in libav References: <005301cdce32$7705fc20$6511f460$@caelumspace.com><892934367069402A98161DBD557A4CEF@MANLAP> Message-ID: <05728DAB83454BD6BC1565011C7E05CD@MANLAP> > From: Alexander Wischnewski > To: This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter. > Sent: Sunday, December 09, 2012 9:43 PM > Subject: Re: [Libav-user] How to connect to an IP camera in libav > > Hello Don, > > is the avformat_open_input function taking long or maybe the avformat_find_stream_info ? > > In the second case you have to reduce the maximal analyze duration of the AVFormatContext, you can do it like this: > > pFormatCtx->max_analyze_duration = 1.0 * AV_TIME_BASE; > > // Retrieve stream information > avformat_find_stream_info(pFormatCtx, NULL) > > Seems that the default value is set to a very high value to make sure there are all important informations gathered, > but this is not necessary for a simple mjpeg stream. I even use this setting for decoding h264 streams and had no problems so far. > > Best regards, > Alex Hi Alex, That helps but doesn't completely resolve it. Even if I ignore timing completely it's about 1/4 second off. The software that came with it is right on. Arrgh more work :) Also the framerate guessed by ffmpeg is always 25 fps in this case which is wrong so need to do something about that. I would be interested in a database of strings to control a variety of IP cameras. Note that I just care about the various strings for acquisition and controlling pan/tilt/zoom for various IP cameras and not interested in controlling software so much. I know it exist but mostly packaged up with a program. I would be willing to purchase such a thing. Would you happen to know where I could my hands on that ?' I have the strings for my foscam but thats just one camera. I would need them for many. Thanks, Don -------------- next part -------------- An HTML attachment was scrubbed... URL: From aw.wisch at googlemail.com Tue Dec 11 14:21:23 2012 From: aw.wisch at googlemail.com (Alexander Wischnewski) Date: Tue, 11 Dec 2012 21:21:23 +0800 Subject: [Libav-user] How to connect to an IP camera in libav In-Reply-To: <05728DAB83454BD6BC1565011C7E05CD@MANLAP> References: <005301cdce32$7705fc20$6511f460$@caelumspace.com> <892934367069402A98161DBD557A4CEF@MANLAP> <05728DAB83454BD6BC1565011C7E05CD@MANLAP> Message-ID: Hi Don, take a look at the open source project iSpy (Connect), it is a free software for network cameras and recorders supporting all kind of manufactors. If you are lucky you will find the database of .cgi commands they are using in the source code. Best regards, Alex 2012/12/11 Don Moir > ** > > From: Alexander Wischnewski > > To: This list is about using libavcodec, libavformat, > libavutil,libavdevice and libavfilter. > > Sent: Sunday, December 09, 2012 9:43 PM > > Subject: Re: [Libav-user] How to connect to an IP camera in libav > > > > Hello Don, > > > > is the avformat_open_input function taking long or maybe the > avformat_find_stream_info ? > > > > In the second case you have to reduce the maximal analyze duration of > the AVFormatContext, you can do it like this: > > > > pFormatCtx->max_analyze_duration = 1.0 * AV_TIME_BASE; > > > > // Retrieve stream information > > avformat_find_stream_info(pFormatCtx, NULL) > > > > Seems that the default value is set to a very high value to make sure > there are all important informations gathered, > > but this is not necessary for a simple mjpeg stream. I even use this > setting for decoding h264 streams and had no problems so far. > > > > Best regards, > > Alex > > Hi Alex, > > That helps but doesn't completely resolve it. Even if I ignore timing > completely it's about 1/4 second off. The software that came with it is > right on. Arrgh more work :) > > Also the framerate guessed by ffmpeg is always 25 fps in this case which > is wrong so need to do something about that. > > I would be interested in a database of strings to control a variety of IP > cameras. Note that I just care about the various strings for acquisition > and controlling pan/tilt/zoom for various IP cameras and not interested in > controlling software so much. > > I know it exist but mostly packaged up with a program. I would be willing > to purchase such a thing. > > Would you happen to know where I could my hands on that ?' > > I have the strings for my foscam but thats just one camera. I would need > them for many. > > Thanks, > > Don > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at mikeversteeg.com Tue Dec 11 17:40:44 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Tue, 11 Dec 2012 17:40:44 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: Using the famous (and only) output example I developed an MPEG-2 recorder for audio and video. Both come from different sources with their own clock (audio as PCM and video as bitmaps) and as a result over time audio will get out of sync due to small differences in the two clocks. To compensate I figured to tweak the audio PTS, but it appears not to be used (it is marked no pts value). What would be the proper way to keep A & V in sync? Thanks, Mike From phamsyquybk at gmail.com Wed Dec 12 05:35:52 2012 From: phamsyquybk at gmail.com (Quy Pham Sy) Date: Wed, 12 Dec 2012 13:35:52 +0900 Subject: [Libav-user] [libav-users] How to detect max packet size for audio stream Message-ID: Hi, How to get the maximum audio packet size for an audio stream to properly allocate audio buffer? (i my audio stream encode in AAC) Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From hwcy at hotmail.com Wed Dec 12 17:03:11 2012 From: hwcy at hotmail.com (Yoon Chris) Date: Wed, 12 Dec 2012 11:03:11 -0500 Subject: [Libav-user] ffmpeg - Where can I find rtpvideo.cpp? Message-ID: Hi, I'm looking for a file named "rtpvideo.cpp" that is supposedly a part of ffmpeg. I couldn't find the file in the latest version of ffmpeg code I downloaded. Do you know where I can get this file? Thanks. Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Wed Dec 12 19:34:49 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Wed, 12 Dec 2012 18:34:49 +0000 (UTC) Subject: [Libav-user] ffmpeg - Where can I find rtpvideo.cpp? References: Message-ID: Yoon Chris writes: > Hi,I'm looking for a file named "rtpvideo.cpp" that is > supposedly a part of ffmpeg. The file is definitely not part of FFmpeg and I would be very surprised if it ever has been. (I suspect it is part of an inactive (spanish) open-souce project called teartp.) Carl Eugen From mike at mikeversteeg.com Thu Dec 13 11:36:35 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 13 Dec 2012 11:36:35 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: Anyone? From mark.kenna at sureviewsystems.com Thu Dec 13 11:48:31 2012 From: mark.kenna at sureviewsystems.com (Mark Kenna) Date: Thu, 13 Dec 2012 10:48:31 +0000 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: On 13 December 2012 10:36, Mike Versteeg wrote: > Anyone? > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > Try this: http://dranger.com/ffmpeg/tutorial05.html Slightly out of date but still a great tutorial -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at mikeversteeg.com Thu Dec 13 12:26:03 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 13 Dec 2012 12:26:03 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: Thanks, but that's for decoding, not encoding. From info at denisgottardello.it Thu Dec 13 15:53:08 2012 From: info at denisgottardello.it (Denis) Date: Thu, 13 Dec 2012 15:53:08 +0100 Subject: [Libav-user] av_opt_set, x264 Message-ID: <201212131553.09147.info@denisgottardello.it> In order to reduce the latency of a live x264 video stream I have tested these rows: if (pAVStreamVideo->codec->codec_id== CODEC_ID_H264) { qDebug() << "CODEC_ID_H264"; av_opt_set(pAVFormatContext->priv_data, "preset", "veryfast", 0); av_opt_set(pAVFormatContext->priv_data, "tune", "zerolatency", 0); av_opt_set(pAVFormatContext->priv_data, "x264opts", "no-mbtree:sliced-threads:sync-lookahead=0", 0); } Without any effect. Is there another way for pass a parameter or must I use another api? Regards. -- www.denisgottardello.it Skype: mrdebug Videosurveillance and home automation! http://www.denisgottardello.it/DomusBoss/DomusBossIndice.php From mike at mikeversteeg.com Thu Dec 13 16:42:57 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 13 Dec 2012 16:42:57 +0100 Subject: [Libav-user] Commercial support Message-ID: Anyone willing & able to offer me (paid) support? Thanks, Mike From nitinkumgoyal at gmail.com Thu Dec 13 17:27:36 2012 From: nitinkumgoyal at gmail.com (NITIN GOYAL) Date: Thu, 13 Dec 2012 21:57:36 +0530 Subject: [Libav-user] Commercial support In-Reply-To: References: Message-ID: I think if you can explain your requirement it will be much better and what kind of support you are actually looking for? On Thu, Dec 13, 2012 at 9:12 PM, Mike Versteeg wrote: > Anyone willing & able to offer me (paid) support? > > Thanks, > > Mike > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at mikeversteeg.com Thu Dec 13 17:36:04 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 13 Dec 2012 17:36:04 +0100 Subject: [Libav-user] Commercial support In-Reply-To: References: Message-ID: > I think if you can explain your requirement it will be much better and what > kind of support you are actually looking for? > > > > On Thu, Dec 13, 2012 at 9:12 PM, Mike Versteeg > wrote: >> >> Anyone willing & able to offer me (paid) support? These would be questions related to the use of the libav API, particularly questions that relate to my lack of knowledge of the API (due to lack of documentation and examples). A good example would be this question: http://libav-users.943685.n4.nabble.com/Libav-user-How-to-perform-drift-compensation-in-MPEG-2-recorder-td4656246.html. From cehoyos at ag.or.at Thu Dec 13 18:07:53 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 13 Dec 2012 17:07:53 +0000 (UTC) Subject: [Libav-user] Commercial support References: Message-ID: Mike Versteeg writes: > These would be questions related to the use of the libav API, > particularly questions that relate to my lack of knowledge of the API > (due to lack of documentation and examples). Did you look into the doc/examples directory? It also contains an encoding example which iirc is what you have asked for. Was your original question about two independent inputs (like alsa and v4l) that do not use the same time-source or do you have a file that is converted fine with ffmpeg (the command line application) but not with your app? Carl Eugen From cehoyos at ag.or.at Thu Dec 13 18:10:38 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 13 Dec 2012 17:10:38 +0000 (UTC) Subject: [Libav-user] =?utf-8?q?av=5Fopt=5Fset=2C_x264?= References: <201212131553.09147.info@denisgottardello.it> Message-ID: Denis writes: > if (pAVStreamVideo->codec->codec_id== CODEC_ID_H264) { > qDebug() << "CODEC_ID_H264"; > av_opt_set(pAVFormatContext->priv_data, "preset", "veryfast", 0); > av_opt_set(pAVFormatContext->priv_data, "tune", "zerolatency", 0); > av_opt_set(pAVFormatContext->priv_data, "x264opts", > "no-mbtree:sliced-threads:sync-lookahead=0", 0); > } > > Without any effect. How do you mean "Without any effect"? I wonder if "priv_data" is the right parameter though, shouldn't this be something like "st->codec" ? Carl Eugen From effemm at mykmk.com Thu Dec 13 19:03:17 2012 From: effemm at mykmk.com (mattes) Date: Thu, 13 Dec 2012 10:03:17 -0800 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: , Message-ID: I assume that you notice the drift during playback. Many player are using different approaches in how to sync the two streams (AV). You might encounter different results with different players. One way is to stuff the continuous audio stream in the audio channel and then sync in the video frames. Playing back the audio, you have to take two clocks into account and compensate for it. The clock of the recorder and the playback host will slightly different. A simple way on the recorder site is to stuff an additional frame or toss one. You could soft 'calibrate' it against the real time clock. This might ease the AV sync on the playback site. But nevertheless playback needs to compensate on its own in similar fashion. On Tue, 11 Dec 2012 17:40:44 +0100 Mike Versteeg wrote > Using the famous (and only) output example I developed an MPEG-2 > recorder for audio and video. Both come from different sources with > their own clock (audio as PCM and video as bitmaps) and as a result > over time audio will get out of sync due to small differences in the > two clocks. To compensate I figured to tweak the audio PTS, but it > appears not to be used (it is marked no pts value). > > What would be the proper way to keep A & V in sync? > > Thanks, > > Mike > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user From info at denisgottardello.it Thu Dec 13 19:03:36 2012 From: info at denisgottardello.it (Denis) Date: Thu, 13 Dec 2012 19:03:36 +0100 Subject: [Libav-user] av_opt_set, x264 In-Reply-To: References: <201212131553.09147.info@denisgottardello.it> Message-ID: <201212131903.36859.info@denisgottardello.it> In data gioved? 13 dicembre 2012 18:10:38, Carl Eugen Hoyos ha scritto: > How do you mean "Without any effect"? > I wonder if "priv_data" is the right parameter though, > shouldn't this be something like "st->codec" ? Which is the right way for change the profile? Have you got an example? I need a no latency solution. See the ffmpeg dump: [libx264 @ 0x92497c0] using cpu capabilities: none! [libx264 @ 0x92497c0] profile High, level 1.2 [libx264 @ 0x92497c0] frame I:4 Avg QP:21,97 size: 8554 [libx264 @ 0x92497c0] frame P:59 Avg QP:22,14 size: 1394 -- www.denisgottardello.it Skype: mrdebug Videosurveillance and home automation! http://www.denisgottardello.it/DomusBoss/DomusBossIndice.php -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at mikeversteeg.com Thu Dec 13 19:41:17 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 13 Dec 2012 19:41:17 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: > I assume that you notice the drift during playback. > Many player are using different approaches in how to sync > the two streams (AV). You might encounter different results > with different players. > > One way is to stuff the continuous audio stream in the audio channel > and then sync in the video frames. Playing back the audio, you have to > take two clocks into account and compensate for it. The clock of the > recorder and the playback host will slightly different. > > A simple way on the recorder site is to stuff an additional frame > or toss one. You could soft 'calibrate' it against the real time clock. > This might ease the AV sync on the playback site. But nevertheless > playback needs to compensate on its own in similar fashion. Thanks. But as I mentioned both sources have their own clock and doubling or omitting frames is unacceptable in the world of broadcasting. The problem is also not at playback but at recording, as one can easily detect in the changing size of the audio buffer. I can overcome this by changing the sample rate of the audio slightly so the buffer's size will remain constant, but figured there would be an easier way by modulating the PTS appropriately. At least I figured that's what it's for. The question here is how to change it in this particular case. From mike at mikeversteeg.com Thu Dec 13 19:50:45 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 13 Dec 2012 19:50:45 +0100 Subject: [Libav-user] Commercial support In-Reply-To: References: Message-ID: >> These would be questions related to the use of the libav API, >> particularly questions that relate to my lack of knowledge of the API > >> (due to lack of documentation and examples). > > Did you look into the doc/examples directory? Yes. > It also contains an encoding example which iirc > is what you have asked for. No, it does not do any drift compensation if you feed it with two independently clocked streams. > Was your original question about two independent inputs > (like alsa and v4l) that do not use the same time-source > or do you have a file that is converted fine with ffmpeg > (the command line application) but not with your app? Totally independent. Problem with the output example is that it assumes the audio is in complete sync with the video (for each frame a fixed number of audio samples is taken in). I need to modulate that number, and I assume that can be done by changing the PTS. But I do not know how, and in fact when I examine it is seems not to be used at all. Anyway, this it rather OT and should go to the other thread. This one is about the availability of someone who knows all about stuff like this and is willing to help me for an hourly fee. Considering libav* is (almost) free I gladly support this financially. From cmst at live.com Wed Dec 12 20:32:54 2012 From: cmst at live.com (Dolevo Jay) Date: Wed, 12 Dec 2012 19:32:54 +0000 Subject: [Libav-user] ffmpeg - Where can I find rtpvideo.cpp? In-Reply-To: References: Message-ID: Can it be this one? http://teartp.googlecode.com/svn-history/r9/trunk/Comun/Video/RTPVideo.cpp From: hwcy at hotmail.com To: libav-user at ffmpeg.org Date: Wed, 12 Dec 2012 11:03:11 -0500 Subject: [Libav-user] ffmpeg - Where can I find rtpvideo.cpp? Hi, I'm looking for a file named "rtpvideo.cpp" that is supposedly a part of ffmpeg. I couldn't find the file in the latest version of ffmpeg code I downloaded. Do you know where I can get this file? Thanks. Chris _______________________________________________ Libav-user mailing list Libav-user at ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From gohar_h at instigatemobile.com Thu Dec 13 13:57:32 2012 From: gohar_h at instigatemobile.com (Gohar Hovhannisyan) Date: Thu, 13 Dec 2012 16:57:32 +0400 Subject: [Libav-user] Decoding HD videos on iPad devices Message-ID: Dear FFMpeg team, We are creating player for iPad and using FFMPeg with libavcodec to decode video frames. FFMpeg helped to process a lot of formats and really reduced the development time. Unfortunately with HD videos we experience a poor performance and the video playback is breaking up. According to profile stats the decode time is taking longer then the playback Profile shows ~100% CPU usage on the call to avcodec_decode_video2 function. In the same time the GPU is almost not used. We wonder whether it is possible to perform decoding on iPad GPU to speed up decoding process (by compiling it with special flags, or with some patches) or run it parallel on dual core (iPad2) / quad-core (new iPad) or are there any other methods to speed up decoding process? Thanks in advance. Regards, Gohar From info at denisgottardello.it Fri Dec 14 14:11:05 2012 From: info at denisgottardello.it (Denis) Date: Fri, 14 Dec 2012 14:11:05 +0100 Subject: [Libav-user] av_opt_set, x264 In-Reply-To: <201212131903.36859.info@denisgottardello.it> References: <201212131553.09147.info@denisgottardello.it> <201212131903.36859.info@denisgottardello.it> Message-ID: <201212141411.05879.info@denisgottardello.it> In data gioved? 13 dicembre 2012 19:03:36, Denis ha scritto: > Which is the right way for change the profile? Have you got an example? > I need a no latency solution. > > > > > See the ffmpeg dump: > > > [libx264 @ 0x92497c0] using cpu capabilities: none! > [libx264 @ 0x92497c0] profile High, level 1.2 > [libx264 @ 0x92497c0] frame I:4 Avg QP:21,97 size: 8554 > [libx264 @ 0x92497c0] frame P:59 Avg QP:22,14 size: 1394 Nobody? -- www.denisgottardello.it Skype: mrdebug Videosurveillance and home automation! http://www.denisgottardello.it/DomusBoss/DomusBossIndice.php From flamz3d at gmail.com Fri Dec 14 17:38:53 2012 From: flamz3d at gmail.com (Dominic Laflamme) Date: Fri, 14 Dec 2012 11:38:53 -0500 Subject: [Libav-user] what's wrong with this loop? Message-ID: Hello, I am attempting to sequentially fetch frames from a movie encoded with libx264. I am using a typical av_read_frame / av_decode_video2 loop (found in most demos out there) to fetch each frames. Like this: int nbFrames = 0; while ( av_read_frame () >= 0 ) { av_decode_video2(&frameFinished); if ( frameFinished ) { nbFrames++; } } Now, my video file has 1000 frames, but after the loop runs, nbFrames only got incremented to 994. So, my question is this: why would I only get 994 complete frames out of 1000? Clearly this has to do with some sort of DTS / PTS issue, but I was under the impression that this type of loop ensured that frames would be reordered properly (hence if(frameFinished)). (btw, if I dump all frames using cmdline ffmpeg, I get 1000 files..., so my video file is not corrupted or anything like that); Any insight would be greatly appreciated! regards, ?Dominic -------------- next part -------------- An HTML attachment was scrubbed... URL: From jettoblack at gmail.com Fri Dec 14 18:30:17 2012 From: jettoblack at gmail.com (Jason Livingston) Date: Fri, 14 Dec 2012 12:30:17 -0500 Subject: [Libav-user] what's wrong with this loop? In-Reply-To: References: Message-ID: On Fri, Dec 14, 2012 at 11:38 AM, Dominic Laflamme wrote: > Hello, > I am attempting to sequentially fetch frames from a movie encoded with > libx264. I am using a typical av_read_frame / av_decode_video2 loop (found > in most demos out there) to fetch each frames. Like this: > > int nbFrames = 0; > while ( av_read_frame () >= 0 ) > { > av_decode_video2(&frameFinished); > if ( frameFinished ) > { > nbFrames++; > } > } > > Now, my video file has 1000 frames, but after the loop runs, nbFrames only > got incremented to 994. > Hi Dominic, Your loop stops when av_read_frame() returns an error such as EOF. There may still be decoded frames in memory. To get those frames out, pass an empty AVPacket (size = 0, data = NULL) into av_decode_video2() until frameFinished returns 0. -------------- next part -------------- An HTML attachment was scrubbed... URL: From flamz3d at gmail.com Fri Dec 14 18:57:13 2012 From: flamz3d at gmail.com (Dominic Laflamme) Date: Fri, 14 Dec 2012 12:57:13 -0500 Subject: [Libav-user] what's wrong with this loop? In-Reply-To: References: Message-ID: that did it. Thanks Jason! ?Dominic -------------- next part -------------- An HTML attachment was scrubbed... URL: From nkipe at tatapowersed.com Mon Dec 17 11:19:56 2012 From: nkipe at tatapowersed.com (Navin) Date: Mon, 17 Dec 2012 15:49:56 +0530 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify Message-ID: <50CEF1CC.50308@tatapowersed.com> I've got a piece of code which extracts every rgb pixel from a video and displays it without any problem. But when I ran it with Purify, I got these errors: * [E] ABR: Array bounds read in GetFrame {197 occurrences} Reading 1 byte from 0x04ae0040 (1 byte at 0x04ae0040 illegal) Address 0x04ae0040 is 16 bytes before the beginning of a 1769472 byte block at 0x04ae0050 Address 0x04ae0040 points to a malloc'd block in heap 0x003a0000 Thread ID: 0x17c4* So I reduced the code to just this *pAreaInMemory[0] = g_pFrameRGB->data[0][0];* and I'm still getting the error (which I've shown above). The code goes something like this (I've shown many of the initializations in GetFrame itself although they're supposed to be outside): bool GetFrame() { ...blah... AVFrame* g_pFrameRGB = NULL; avpicture_fill_proc((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); ...blah... sws_scale_proc(g_sws_ctx, (uint8_t const * const *)g_pFrame->data, g_pFrame->linesize, 0, g_metadata->HEIGHT, g_pFrameRGB->data, g_pFrameRGB->linesize ); ...blah... unsigned char* pAreaInMemory = (unsigned char*) malloc( sizeof(unsigned char) * 1024 * 768 ); ...get the video data here... pAreaInMemory[0] = g_pFrameRGB->data[0][0]; ...blah... free(pAreaInMemory); } Why is there a bounds problem when reading from data[0][0] ? I noticed the way data is initialized in ffmpeg. Is this purify error something I can ignore (there's no memory leak. Just the bounds error) or can it lead to serious problems? -- Navin -------------- next part -------------- An HTML attachment was scrubbed... URL: From rjvbertin at gmail.com Mon Dec 17 11:43:37 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Mon, 17 Dec 2012 11:43:37 +0100 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: <50CEF1CC.50308@tatapowersed.com> References: <50CEF1CC.50308@tatapowersed.com> Message-ID: Just some general thoughts: On Dec 17, 2012, at 11:19, Navin wrote: > I've got a piece of code which extracts every rgb pixel from a video and displays it without any problem. But when I ran it with Purify, I got these errors: > > [E] ABR: Array bounds read in GetFrame {197 occurrences} > Reading 1 byte from 0x04ae0040 (1 byte at 0x04ae0040 illegal) > Address 0x04ae0040 is 16 bytes before the beginning of a 1769472 byte block at 0x04ae0050 > Address 0x04ae0040 points to a malloc'd block in heap 0x003a0000 > Thread ID: 0x17c4 > > So I reduced the code to just this > pAreaInMemory[0] = g_pFrameRGB->data[0][0]; > and I'm still getting the error (which I've shown above). > The code goes something like this (I've shown many of the initializations in GetFrame itself although they're supposed to be outside): Are you compiling in 32 or 64 bits, i.e. are you reading 1 or 2 addresses ahead of the allocated block? 2 address locations ahead could mean that the data matrix indexing is 1-based and not 0-based, for instance. Checking avcodec/avcodec.h, there's the following doxygen comment associated with the AVFrame->data member: /** * pointer to the picture/channel planes. * This might be different from the first allocated byte * - encoding: Set by user * - decoding: set by AVCodecContext.get_buffer() */ Maybe you're seeing exactly what's stated, that data[0][0] is different from the first allocated byte? > Why is there a bounds problem when reading from data[0][0] ? I noticed the way data is initialized in ffmpeg. Is this purify error something I can ignore (there's no memory leak. Just the bounds error) or can it lead to serious problems? A leak error you could chose to ignore as they're often false alarms (memory deallocated elsewhere). A bounds error is another issue because in this case you're not just checking the location for a specific value but you're assuming it contains a valid pixel. Which it most likely will not if the location is indeed not within the allocated block. Whether that can lead to serious problems only you can assess, but on some platforms you'd get an exception even for reading an illegal address. Ren? From cmst at live.com Mon Dec 17 09:59:01 2012 From: cmst at live.com (Dolevo Jay) Date: Mon, 17 Dec 2012 08:59:01 +0000 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: , , Message-ID: Hello all, I am having a very similar problem in my project. I capture the video frame by frame from the desktop screen and send them over network after encoding. This happens on the PC processor and I have no problem with this. It works perfect for now. However, I capture the audio separately with the help of an HID device which has its own processor. I can send the audio even without encoding but still the problem is the video and audio get out of sync and drift occurs although I sync the processors at the very beginning. Could anyone shed any light on this issue? Thanks. Jay > Date: Thu, 13 Dec 2012 11:36:35 +0100 > From: mike at mikeversteeg.com > To: libav-user at ffmpeg.org > Subject: Re: [Libav-user] How to perform drift compensation in MPEG-2 recorder > > Anyone? > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From perez.didac at gmail.com Mon Dec 17 09:31:06 2012 From: perez.didac at gmail.com (=?ISO-8859-1?Q?D=EDdac_P=E9rez?=) Date: Mon, 17 Dec 2012 09:31:06 +0100 Subject: [Libav-user] Syncronize RTSP with computer time Message-ID: I am successfully using libav to receive the video stream from an RTSP network source. The point is that I need to syncronize my computer's time with the video capturing, meaning that I need to know which datetime of my computer corresponds to the first frame (pts = 0). My API calls are the following ones: av_register_all() avcodec_register_all() avformat_network_init() avformat_open_input() avformat_find_stream_info() av_read_play() loop av_init_packet() av_read_frame() [...] av_free_packet end loop With the calls above, I successfully read frames, but I do need to know how can I know the exact absolute datetime that corresponds to the first frame, since it has a pts of 0. Maybe I can use a time() function or GetSystemTime (I am using Windows) between two calls of the above, but do not really know how libav works. I will appreciate your help, Kind regards, -- D?dac P?rez -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexcohn at netvision.net.il Tue Dec 18 10:27:38 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Tue, 18 Dec 2012 11:27:38 +0200 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: <50CEF1CC.50308@tatapowersed.com> References: <50CEF1CC.50308@tatapowersed.com> Message-ID: On Mon, Dec 17, 2012 at 12:19 PM, Navin wrote: > So I reduced the code to just this > pAreaInMemory[0] = g_pFrameRGB->data[0][0]; > and I'm still getting the error (which I've shown above). > The code goes something like this (I've shown many of the initializations in > GetFrame itself although they're supposed to be outside): > > bool GetFrame() > { > ...blah... > AVFrame* g_pFrameRGB = NULL; > avpicture_fill_proc((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, > g_metadata->WIDTH, g_metadata->HEIGHT); avipicture_fill does not expect NULL pointer to AVPicture as first parameter. The pointer must be initialized (see doc/examples/muxing.c for the correct usage). BR, Alex From mtaha.ansari at gmail.com Tue Dec 18 12:06:27 2012 From: mtaha.ansari at gmail.com (Taha Ansari) Date: Tue, 18 Dec 2012 16:06:27 +0500 Subject: [Libav-user] Webcam streaming - network transfer rate does not change irrespective of decoder resolution Message-ID: Hi, I am streaming webcam over udp using h264 raw format (Windows). When I try this: ffmpeg -f dshow -r 25 -s 160x120 -i video="A4 tech USB2.0 Camera" udp://:8888/a.h264 Changing from 160x120 to 640x480 (different allowable resolutions), I see there is significant change in data transmitted over network per minute that I have monitored. But, when I try to do the same from my code, either by: i- opening up decoder at native resolution (640x480 default), then scaling it to required resolution, then stream this scaled frame to network, or ii- opening up decoder at different resolution, using AVDictionary, like: av_dict_set( &dict, "video_size", "320x240",0); if(avformat_open_input(&this-> pFormatCtx, this->finalInputName.c_str(), pInputFormat, &dict)!=0) return -1; // Couldn't open file so I am capturing at 320x240 resolution from example above, monitoring for above both cases, I get approximately the same data transmission rate, i.e. around 2.7 MB per minute. I use baseline profile and ultrafast preset. I think using -s 320x240 is the same as setting up dictionary options to open up a decoder stream with a smaller resolution, but it doesn't seem to work. Logically, capturing at any resolution, then scaling it, and sending the scaled frame over network should be taking up less space as well, but that's not the case observed here. Can anyone provide some guidance what I may be doing wrong? Thanks for your time! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rjvbertin at gmail.com Tue Dec 18 13:02:31 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Tue, 18 Dec 2012 13:02:31 +0100 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: References: <50CEF1CC.50308@tatapowersed.com> Message-ID: On Dec 18, 2012, at 10:27, Alex Cohn wrote: > On Mon, Dec 17, 2012 at 12:19 PM, Navin wrote: >> So I reduced the code to just this >> pAreaInMemory[0] = g_pFrameRGB->data[0][0]; >> and I'm still getting the error (which I've shown above). >> The code goes something like this (I've shown many of the initializations in >> GetFrame itself although they're supposed to be outside): >> >> bool GetFrame() >> { >> ...blah... >> AVFrame* g_pFrameRGB = NULL; >> avpicture_fill_proc((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, >> g_metadata->WIDTH, g_metadata->HEIGHT); > > avipicture_fill does not expect NULL pointer to AVPicture as first > parameter. The pointer must be initialized (see doc/examples/muxing.c > for the correct usage). > Doh, everyone could have seen that g_pFrameRGB can't possibly be initialised in the snippet above, so much for my general suggestions :) R. From alexcohn at netvision.net.il Tue Dec 18 13:32:05 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Tue, 18 Dec 2012 14:32:05 +0200 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: On Mon, Dec 17, 2012 at 10:59 AM, Dolevo Jay wrote: > I capture the video frame by frame from the desktop screen and send them > over network after encoding. This happens on the PC processor and I have no > problem with this. It works perfect for now. However, I capture the audio > separately with the help of an HID device which has its own processor. I can > send the audio even without encoding but still the problem is the video and > audio get out of sync and drift occurs although I sync the processors at the > very beginning. Could anyone shed any light on this issue? You can set the video PTS in sync with the current audio "clock". Most likely, your audio packets arrive at fixed nominal frequency which is not precise (from the point of view of your PC clock). In this case you should calculate PTS by multiplying the expected audio packet duration by number of actual audio packets received. BR, Alex From rjvbertin at gmail.com Tue Dec 18 13:44:49 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Tue, 18 Dec 2012 13:44:49 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: On Dec 18, 2012, at 13:32, Alex Cohn wrote: > On Mon, Dec 17, 2012 at 10:59 AM, Dolevo Jay wrote: >> I capture the video frame by frame from the desktop screen and send them >> over network after encoding. This happens on the PC processor and I have no >> problem with this. It works perfect for now. However, I capture the audio >> separately with the help of an HID device which has its own processor. I can >> send the audio even without encoding but still the problem is the video and >> audio get out of sync and drift occurs although I sync the processors at the >> very beginning. Could anyone shed any light on this issue? > > You can set the video PTS in sync with the current audio "clock". Most > likely, your audio packets arrive at fixed nominal frequency which is > not precise (from the point of view of your PC clock). In this case > you should calculate PTS by multiplying the expected audio packet > duration by number of actual audio packets received. Even if a nominal fixed frequency were precise enough with respect to the video frequency it seems you're probably looking at transport delays that are neither constant nor identical (enough) for the two streams. It's not clear if you send video and audio over the same network stream if you maybe even capture the audio on a separate host (possibly the remote)? How big is the drift, I suppose we're not talking about a 1 or 2 frames jitter? R. From david.longest at apx-labs.com Tue Dec 18 23:14:33 2012 From: david.longest at apx-labs.com (David Longest) Date: Tue, 18 Dec 2012 22:14:33 +0000 Subject: [Libav-user] H263 dts from avformat_find_stream_info Message-ID: Hello All, I am trying to use libav to decode an h263 stream. While I can successfully decode the stream and display decoded frames, I have found that I get about a 5 second stall in avformat_find_stream_info. After further investigation, it seems that the AVStream's first_dts is always set to AV_NOPTS_VALUE and the for loop in avformat_find_stream_info attempts to wait for that data to be populated. The only conclusion I have come to is that the h263 parser does not ever populate the "dts" portion of the incoming packets. What is the proper way to handle setting the decompression timestamp on h263 data? Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From mtaha.ansari at gmail.com Tue Dec 18 12:07:29 2012 From: mtaha.ansari at gmail.com (Taha Ansari) Date: Tue, 18 Dec 2012 16:07:29 +0500 Subject: [Libav-user] Scaled down h264 video has almost same size as normal sized video; why? Message-ID: Hi, I have modified muxer program that saves h264 video to disk of 01 minute duration, as follows: ****************************** ************************************************************ /* * Copyright (c) 2001 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /** * @file * libavcodec API use example. * * Note that libavcodec only handles codecs (mpeg, mpeg4, etc...), * not file formats (avi, vob, mp4, mov, mkv, mxf, flv, mpegts, mpegps, etc...). See library 'libavformat' for the * format handling */ #include #include extern "C" { #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libavutil/dict.h" #include "libavutil/error.h" #include "libavutil/opt.h" } #define DECODER_WIDTH 640 #define DECODER_HEIGHT 480 #define ENCODER_WIDTH 640 #define ENCODER_HEIGHT 480 /* 5 seconds stream duration */ #define STREAM_DURATION 60.0 #define STREAM_FRAME_RATE 25 /* 25 images/s */ #define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE)) #define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */ static int sws_flags = SWS_BICUBIC; /**************************************************************/ /* audio output */ static float t, tincr, tincr2; static int16_t *samples; static int audio_input_frame_size; /* Add an output stream. */ static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id) { AVCodecContext *c; AVStream *st; /* find the encoder */ *codec = avcodec_find_encoder(codec_id); if (!(*codec)) { fprintf(stderr, "Could not find codec\n"); exit(1); } st = avformat_new_stream(oc, *codec); if (!st) { fprintf(stderr, "Could not allocate stream\n"); exit(1); } st->id = oc->nb_streams-1; c = st->codec; switch ((*codec)->type) { case AVMEDIA_TYPE_AUDIO: st->id = 1; c->sample_fmt = AV_SAMPLE_FMT_S16; c->bit_rate = 64000; c->sample_rate = 44100; c->channels = 2; break; case AVMEDIA_TYPE_VIDEO: avcodec_get_context_defaults3(c, *codec); c->codec_id = codec_id; c->bit_rate = 400000; /* Resolution must be a multiple of two. */ c->width = ENCODER_WIDTH; c->height = ENCODER_HEIGHT; /* timebase: This is the fundamental unit of time (in seconds) in terms * of which frame timestamps are represented. For fixed-fps content, * timebase should be 1/framerate and timestamp increments should be * identical to 1. */ c->time_base.den = STREAM_FRAME_RATE; c->time_base.num = 1; c->gop_size = 12; /* emit one intra frame every twelve frames at most */ c->pix_fmt = STREAM_PIX_FMT; if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) { /* just for testing, we also add B frames */ c->max_b_frames = 2; } if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) { /* Needed to avoid using macroblocks in which some coeffs overflow. * This does not happen with normal video, it just happens here as * the motion of the chroma plane does not match the luma plane. */ c->mb_decision = 2; } break; default: break; } /* Some formats want stream headers to be separate. */ if (oc->oformat->flags & AVFMT_GLOBALHEADER) c->flags |= CODEC_FLAG_GLOBAL_HEADER; return st; } /**************************************************************/ /* audio output */ static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st) { AVCodecContext *c; c = st->codec; /* open it */ if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open audio codec\n"); exit(1); } /* init signal generator */ t = 0; tincr = 2 * M_PI * 110.0 / c->sample_rate; /* increment frequency by 110 Hz per second */ tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate; if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) audio_input_frame_size = 10000; else audio_input_frame_size = c->frame_size; samples = (int16_t *) av_malloc(audio_input_frame_size * av_get_bytes_per_sample(c->sample_fmt) * c->channels); if (!samples) { fprintf(stderr, "Could not allocate audio samples buffer\n"); exit(1); } } /* Prepare a 16 bit dummy audio frame of 'frame_size' samples and * 'nb_channels' channels. */ static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels) { int j, i, v; int16_t *q; q = samples; for (j = 0; j < frame_size; j++) { v = (int)(sin(t) * 10000); for (i = 0; i < nb_channels; i++) *q++ = v; t += tincr; tincr += tincr2; } } static void write_audio_frame(AVFormatContext *oc, AVStream *st) { AVCodecContext *c; AVPacket pkt = { 0 }; // data and size must be 0; AVFrame *frame = avcodec_alloc_frame(); int got_packet, ret; av_init_packet(&pkt); c = st->codec; get_audio_frame(samples, audio_input_frame_size, c->channels); frame->nb_samples = audio_input_frame_size; avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt, (uint8_t *)samples, audio_input_frame_size * av_get_bytes_per_sample(c->sample_fmt) * c->channels, 1); ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet); if (ret < 0) { fprintf(stderr, "Error encoding audio frame\n"); exit(1); } if (!got_packet) return; pkt.stream_index = st->index; /* Write the compressed frame to the media file. */ if (av_interleaved_write_frame(oc, &pkt) != 0) { fprintf(stderr, "Error while writing audio frame\n"); exit(1); } avcodec_free_frame(&frame); } static void close_audio(AVFormatContext *oc, AVStream *st) { avcodec_close(st->codec); av_free(samples); } /**************************************************************/ /* video output */ static AVFrame *frame; static AVPicture src_picture, dst_picture; static int frame_count; static void open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st) { int ret; AVCodecContext *c = st->codec; /* open the codec */ if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open video codec\n"); exit(1); } /* allocate and init a re-usable frame */ frame = avcodec_alloc_frame(); if (!frame) { fprintf(stderr, "Could not allocate video frame\n"); exit(1); } /* Allocate the encoded raw picture. */ ret = avpicture_alloc(&dst_picture, c->pix_fmt, c->width, c->height); if (ret < 0) { fprintf(stderr, "Could not allocate picture\n"); exit(1); } /* If the output format is not YUV420P, then a temporary YUV420P * picture is needed too. It is then converted to the required * output format. */ if (1) { ret = avpicture_alloc(&src_picture, PIX_FMT_YUV420P, DECODER_WIDTH, DECODER_HEIGHT); if (ret < 0) { fprintf(stderr, "Could not allocate temporary picture\n"); exit(1); } } //if (c->pix_fmt != AV_PIX_FMT_YUV420P) { // ret = avpicture_alloc(&src_picture, AV_PIX_FMT_YUV420P, c->width, c->height); // if (ret < 0) { // fprintf(stderr, "Could not allocate temporary picture\n"); // exit(1); // } //} /* copy data and linesize picture pointers to frame */ *((AVPicture *)frame) = dst_picture; } /* Prepare a dummy image. */ static void fill_yuv_image(AVPicture *pict, int frame_index, int width, int height) { int x, y, i; i = frame_index; /* Y */ for (y = 0; y < height; y++) for (x = 0; x < width; x++) pict->data[0][y * pict->linesize[0] + x] = x + y + i * 3; /* Cb and Cr */ for (y = 0; y < height / 2; y++) { for (x = 0; x < width / 2; x++) { pict->data[1][y * pict->linesize[1] + x] = 128 + y + i * 2; pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5; } } } static void write_video_frame(AVFormatContext *oc, AVStream *st) { int ret; static struct SwsContext *sws_ctx; AVCodecContext *c = st->codec; if (frame_count >= STREAM_NB_FRAMES) { /* No more frames to compress. The codec has a latency of a few * frames if using B-frames, so we get the last frames by * passing the same picture again. */ } else { if (c->pix_fmt != AV_PIX_FMT_YUV420P) { /* as we only generate a YUV420P picture, we must convert it * to the codec pixel format if needed */ if (!sws_ctx) { sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P, c->width, c->height, c->pix_fmt, sws_flags, NULL, NULL, NULL); if (!sws_ctx) { fprintf(stderr, "Could not initialize the conversion context\n"); exit(1); } } fill_yuv_image(&src_picture, frame_count, c->width, c->height); sws_scale(sws_ctx, (const uint8_t * const *)src_picture.data, src_picture.linesize, 0, c->height, dst_picture.data, dst_picture.linesize); } else { /* as we only generate a YUV420P picture, we must convert it * to the codec pixel format if needed */ if (!sws_ctx) { sws_ctx = sws_getContext( DECODER_WIDTH, DECODER_HEIGHT, PIX_FMT_YUV420P, c->width, c->height, c->pix_fmt, sws_flags, NULL, NULL, NULL); if (!sws_ctx) { fprintf(stderr, "Could not initialize the conversion context\n"); exit(1); } } fill_yuv_image(&src_picture, frame_count, DECODER_WIDTH, DECODER_HEIGHT); sws_scale(sws_ctx, (const uint8_t * const *)src_picture.data, src_picture.linesize, 0, DECODER_WIDTH, dst_picture.data, dst_picture.linesize); //fill_yuv_image(&dst_picture, frame_count, c->width, c->height); } } if (oc->oformat->flags & AVFMT_RAWPICTURE) { /* Raw video case - directly store the picture in the packet */ AVPacket pkt; av_init_packet(&pkt); pkt.flags |= AV_PKT_FLAG_KEY; pkt.stream_index = st->index; pkt.data = dst_picture.data[0]; pkt.size = sizeof(AVPicture); ret = av_interleaved_write_frame(oc, &pkt); } else { /* encode the image */ AVPacket pkt; int got_output; av_init_packet(&pkt); pkt.data = NULL; // packet data will be allocated by the encoder pkt.size = 0; ret = avcodec_encode_video2(c, &pkt, frame, &got_output); if (ret < 0) { fprintf(stderr, "Error encoding video frame\n"); exit(1); } /* If size is zero, it means the image was buffered. */ if (got_output) { if (c->coded_frame->key_frame) pkt.flags |= AV_PKT_FLAG_KEY; pkt.stream_index = st->index; /* Write the compressed frame to the media file. */ ret = av_interleaved_write_frame(oc, &pkt); } else { ret = 0; } } if (ret != 0) { fprintf(stderr, "Error while writing video frame\n"); exit(1); } frame_count++; } static void close_video(AVFormatContext *oc, AVStream *st) { avcodec_close(st->codec); av_free(src_picture.data[0]); av_free(dst_picture.data[0]); av_free(frame); } /**************************************************************/ /* media file output */ int main(int argc, char **argv) { char filename[99]=""; AVOutputFormat *fmt; AVFormatContext *oc; AVStream *audio_st, *video_st; AVCodec *audio_codec, *video_codec; double audio_pts, video_pts; int i; /* Initialize libavcodec, and register all codecs and formats. */ av_register_all(); if (argc != 2) { printf("usage: %s output_file\n" "API example program to output a media file with libavformat.\n" "This program generates a synthetic audio and video stream, encodes and\n" "muxes them into a file named output_file.\n" "The output format is automatically guessed according to the file extension.\n" "Raw images can also be output by using '%%d' in the filename.\n" "\n", argv[0]); return 1; } strcpy(filename,"a.h264"); /* allocate the output media context */ avformat_alloc_output_context2(&oc, NULL, NULL, filename); if (!oc) { printf("Could not deduce output format from file extension: using MPEG.\n"); avformat_alloc_output_context2(&oc, NULL, "mpeg", filename); } if (!oc) { return 1; } fmt = oc->oformat; /* Add the audio and video streams using the default format codecs * and initialize the codecs. */ video_st = NULL; audio_st = NULL; if (fmt->video_codec != AV_CODEC_ID_NONE) { video_st = add_stream(oc, &video_codec, fmt->video_codec); } if (fmt->audio_codec != AV_CODEC_ID_NONE) { audio_st = add_stream(oc, &audio_codec, fmt->audio_codec); } /* Now that all the parameters are set, we can open the audio and * video codecs and allocate the necessary encode buffers. */ if (video_st) open_video(oc, video_codec, video_st); if (audio_st) open_audio(oc, audio_codec, audio_st); av_dump_format(oc, 0, filename, 1); /* open the output file, if needed */ if (!(fmt->flags & AVFMT_NOFILE)) { if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) { fprintf(stderr, "Could not open '%s'\n", filename); return 1; } } /* Write the stream header, if any. */ if (avformat_write_header(oc, NULL) < 0) { fprintf(stderr, "Error occurred when opening output file\n"); return 1; } if (frame) frame->pts = 0; for (;;) { /* Compute current audio and video time. */ if (audio_st) audio_pts = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den; else audio_pts = 0.0; if (video_st) video_pts = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den; else video_pts = 0.0; if ((!audio_st || audio_pts >= STREAM_DURATION) && (!video_st || video_pts >= STREAM_DURATION)) break; /* write interleaved audio and video frames */ if (!video_st || (video_st && audio_st && audio_pts < video_pts)) { write_audio_frame(oc, audio_st); } else { write_video_frame(oc, video_st); frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base); } Sleep(40); } /* Write the trailer, if any. The trailer must be written before you * close the CodecContexts open when you wrote the header; otherwise * av_write_trailer() may try to use memory that was freed on * av_codec_close(). */ av_write_trailer(oc); /* Close each codec. */ if (video_st) close_video(oc, video_st); if (audio_st) close_audio(oc, audio_st); /* Free the streams. */ for (i = 0; i < oc->nb_streams; i++) { av_freep(&oc->streams[i]->codec); av_freep(&oc->streams[i]); } if (!(fmt->flags & AVFMT_NOFILE)) /* Close the output file. */ avio_close(oc->pb); /* free the stream */ av_free(oc); return 0; } ******************************************************************************* After first run, if we change #define ENCODER_WIDTH 640 #define ENCODER_HEIGHT 480 to #define ENCODER_WIDTH 160 #define ENCODER_HEIGHT 120 and run again, file size is almost the same. Question now is why? shouldn't smaller sized video be taking up much lesser space than the original sized video? Same thing happens if instead of saving to hard-disk I transmit over udp; it is taking up similar bandwidth consumption. Can anyone provide guidance for above? Thanks for your time! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mtaha.ansari at gmail.com Wed Dec 19 08:58:50 2012 From: mtaha.ansari at gmail.com (Taha Ansari) Date: Wed, 19 Dec 2012 12:58:50 +0500 Subject: [Libav-user] Changing decoder resolution does not change file output size for h264 format Message-ID: Hi all! I have made a test application that captures from webcam (using dshow filter), and saves it as a file on hard disk. My camera supports natively 640x480 resolution, so I had to forcefully open it in smaller resolution to conduct this test: pFormatCtx = avformat_alloc_context(); AVDictionary *dict = NULL; av_dict_set( &dict, "video_size", "160x120" ,0); if(avformat_open_input(&this->pFormatCtx, this->finalInputName.c_str(), pInputFormat, &dict)!=0) return -1; // Couldn't open file finalInputName is the correctly formatted video:audio string ffmpeg recognizes for dshow. Problem now is, no matter what the decoder's resolution is (160x120, 320x240, 640x480 etc.), output file size for approximately one minute duration is always the same - around 3 MB. I tried encoding to other formats like 'mpg', 'ogg', their video sizes seems to be appropriately scaled, then what am I doing wrong with h264 format, fail to understand? Can anyone kindly provide some guidance? Thanks for your time! Best regards... -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexcohn at netvision.net.il Wed Dec 19 09:02:35 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Wed, 19 Dec 2012 10:02:35 +0200 Subject: [Libav-user] Scaled down h264 video has almost same size as normal sized video; why? In-Reply-To: References: Message-ID: On Tue, Dec 18, 2012 at 1:07 PM, Taha Ansari wrote: > After first run, if we change > > #define ENCODER_WIDTH 640 > #define ENCODER_HEIGHT 480 > > to > > #define ENCODER_WIDTH 160 > #define ENCODER_HEIGHT 120 > > and run again, file size is almost the same. Question now is why? shouldn't > smaller sized video be taking up much lesser space than the original sized > video? Note that you have the encoder bit rate hard coded: > c->bit_rate = 400000; ... so, one would expect a well-tempered encoder to produce same encoded frame sizes. You could try to compare the resulting video quality in two cases. E.g., decode the two streams and display them at 160x120. You are expected to see very similar images. If you increase the requested bit rate, the VGA stream will still be improving, but the 160x120 stream is probably saturated. You can consult the "video bitrate calculator" at http://www.dr-lex.be/info-stuff/videocalc.html to find the optimal bit rate - it would be more than 1Mbps for VGA at 25 FPS. BR, Alex From mtaha.ansari at gmail.com Wed Dec 19 10:29:15 2012 From: mtaha.ansari at gmail.com (Taha Ansari) Date: Wed, 19 Dec 2012 14:29:15 +0500 Subject: [Libav-user] Scaled down h264 video has almost same size as normal sized video; why? In-Reply-To: References: Message-ID: Note that you have the encoder bit rate hard coded: > > > c->bit_rate = 400000; > > ... so, one would expect a well-tempered encoder to produce same > encoded frame sizes. You could try to compare the resulting video > quality in two cases. E.g., decode the two streams and display them at > 160x120. You are expected to see very similar images. If you increase > the requested bit rate, the VGA stream will still be improving, but > the 160x120 stream is probably saturated. You can consult the "video > bitrate calculator" at http://www.dr-lex.be/info-stuff/videocalc.html > to find the optimal bit rate - it would be more than 1Mbps for VGA at > 25 FPS. > > BR, > Alex > Hi Alex! Thanks for the link - you simply nailed down the problem for me; it was bit_rate factor after all! Thanks again for your guidance! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at mikeversteeg.com Wed Dec 19 11:31:05 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Wed, 19 Dec 2012 11:31:05 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: >> On Mon, Dec 17, 2012 at 10:59 AM, Dolevo Jay wrote: >>> I capture the video frame by frame from the desktop screen and send them >>> over network after encoding. This happens on the PC processor and I have no >>> problem with this. It works perfect for now. However, I capture the audio >>> separately with the help of an HID device which has its own processor. I can >>> send the audio even without encoding but still the problem is the video and >>> audio get out of sync and drift occurs although I sync the processors at the >>> very beginning. Could anyone shed any light on this issue? >> >> You can set the video PTS in sync with the current audio "clock". Most >> likely, your audio packets arrive at fixed nominal frequency which is >> not precise (from the point of view of your PC clock). In this case >> you should calculate PTS by multiplying the expected audio packet >> duration by number of actual audio packets received. > > > Even if a nominal fixed frequency were precise enough with respect to the video frequency it seems you're probably looking at transport delays that are neither constant nor identical (enough) for the two streams. It's not clear if you send video and audio over the same network stream if you maybe even capture the audio on a separate host (possibly the remote)? How big is the drift, I suppose we're not talking about a 1 or 2 frames jitter? I have a minor jitter, there is no network involved. I aforementioned example all PTS's are calculated automatically. Where do I insert my own video PTS? I assume it is in the write_video_frame function, but is it before the call to avcodec_encode_video() or after? Do I set the codec PTS or the packet, or both? Here's (I think) the relevant piece of code: // encode the image int out_size = avcodec_encode_video(c, pVideoOut, iVideoOutSize, stPicture); // if zero size, it means the image was buffered if (out_size > 0) { 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); } Thanks, Mike From cehoyos at ag.or.at Wed Dec 19 11:59:23 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Wed, 19 Dec 2012 10:59:23 +0000 (UTC) Subject: [Libav-user] Decoding HD videos on iPad devices References: Message-ID: Gohar Hovhannisyan writes: > We wonder whether it is possible to perform decoding on > iPad GPU to speed up decoding process (by compiling > it with special flags, or with some patches) Only if you implement it. > or run it parallel on dual core (iPad2) / quad-core (new iPad) > or are there any other methods to speed up decoding process? You can set the number of threads that decoding should use. Carl Eugen From mike at mikeversteeg.com Wed Dec 19 13:46:12 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Wed, 19 Dec 2012 13:46:12 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: PS: This (http://lists.libav.org/pipermail/libav-api/2012-April/000473.html) thread is about the exact same question and again no one seems to know the answer. From mike at mikeversteeg.com Wed Dec 19 14:07:01 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Wed, 19 Dec 2012 14:07:01 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: Found another thread with similar question: http://libav-users.943685.n4.nabble.com/Libav-user-PTS-values-and-writing-encoded-audio-and-video-frames-td4551001.html Again, not answered. I do not think no one has ever considered video and audio clocks can slightly drift away from each other, so the lack of feedback is likely because the questions are wrong. I am therefore trying to rephrase my, and all these similar questions, as follows.. Using the sample code referred to, there is a direct connection between a video frame (lasting 1/fps) and an audio frame (fixed length lasting length/samplerate). This works fine as long as the audio and video clock are in perfect sync. However when has only the smallest difference from the other, after a while (could be hours) an error accumulates resulting in a slight AV sync problem. Obviously this problem can be fixed by monitoring this difference and resampling the audio data, but it uses resources. Changing the audio packet size dynamically seems a solution, but it does not seem possible. Is there another way, like "modulating" some time stamp and if so, how? Mike From rjvbertin at gmail.com Wed Dec 19 15:26:25 2012 From: rjvbertin at gmail.com (RJV Bertin) Date: Wed, 19 Dec 2012 15:26:25 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: Message-ID: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> On 19 Dec 2012, at 14:07, Mike Versteeg wrote: > Found another thread with similar question: > http://libav-users.943685.n4.nabble.com/Libav-user-PTS-values-and-writing-encoded-audio-and-video-frames-td4551001.html > > Again, not answered. > > I do not think no one has ever considered video and audio clocks can > slightly drift away from each other, so the lack of feedback is likely > because the questions are wrong. I am therefore trying to rephrase my, > and all these similar questions, as follows.. > > Using the sample code referred to, there is a direct connection > between a video frame (lasting 1/fps) and an audio frame (fixed length > lasting length/samplerate). This works fine as long as the audio and > video clock are in perfect sync. However when has only the smallest > difference from the other, after a while (could be hours) an error > accumulates resulting in a slight AV sync problem. Obviously this > problem can be fixed by monitoring this difference and resampling the > audio data, but it uses resources. Changing the audio packet size > dynamically seems a solution, but it does not seem possible. Is there > another way, like "modulating" some time stamp and if so, how? > > Mike > _______________________________________________ > Maybe you should ask which clock is the most precise, and use that one as your master clock? If that's not possible you won't have many other options if everything has to be done on realtime; adapting frame display times as soon as you detect the need will be much easier than modifying sound chunks, I think. From mike at mikeversteeg.com Wed Dec 19 15:34:51 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Wed, 19 Dec 2012 15:34:51 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: > Maybe you should ask which clock is the most precise, and use that one as your master clock? If that's not possible you won't have many other options if everything has to be done on realtime; adapting frame display times as soon as you detect the need will be much easier than modifying sound chunks, I think. Either one can be used as master clock for the recorder. But I cannot sync both clocks with each other if that's what you mean. So are you saying this cannot be handled by libav, i.e. it always requires a fixed ratio between frames and audio samples? Earlier comments let to believe "something" can be done with timestamps, but I fail to see what. From alexcohn at netvision.net.il Wed Dec 19 16:20:43 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Wed, 19 Dec 2012 17:20:43 +0200 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: On Wed, Dec 19, 2012 at 4:34 PM, Mike Versteeg wrote: >> Maybe you should ask which clock is the most precise, and use that one as your master clock? If that's not possible you won't have many other options if everything has to be done on realtime; adapting frame display times as soon as you detect the need will be much easier than modifying sound chunks, I think. It's not a question of clock precision; video should follow audio because it's FPS is much lower, and it is more resilient to slight adjustments. > Either one can be used as master clock for the recorder. But I cannot sync both clocks with each other if that's what you mean. Yes you can! You should set the PTS for the video stream according to the audio clock, that's it. I believe that you can know the audio clock by counting the audio packets. BR, Alex From mike at mikeversteeg.com Wed Dec 19 16:27:15 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Wed, 19 Dec 2012 16:27:15 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: >> Either one can be used as master clock for the recorder. But I cannot sync both clocks with each other if that's what you mean. > > Yes you can! You should set the PTS for the video stream according to > the audio clock, that's it. I believe that you can know the audio > clock by counting the audio packets. I can't as this would introduce double/missing frames, which is unacceptable for my app. I guess what I want is not possible, so I have to resort to audio resampling. Thanks everyone. Mike From alexcohn at netvision.net.il Wed Dec 19 16:38:01 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Wed, 19 Dec 2012 17:38:01 +0200 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: On Wed, Dec 19, 2012 at 5:27 PM, Mike Versteeg wrote: > I can't as this would introduce double/missing frames, which is > unacceptable for my app. Why? The nominal frame rate of a video stream is only a guideline; the actual PTS can handle reasonable jitter. Alex From mike at mikeversteeg.com Wed Dec 19 16:46:15 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Wed, 19 Dec 2012 16:46:15 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: >> I can't as this would introduce double/missing frames, which is >> unacceptable for my app. > > Why? The nominal frame rate of a video stream is only a guideline; the > actual PTS can handle reasonable jitter. My initial thought was just that: adjust the PTS to effectively slightly change the frame rate in the file, matching my video clock to the audio clock. But I have since learned (offline) that this is not possible as indeed the video PTS, at least for MPEG-2, increments as integer (0, 1, 2, ...). There's no fiddling with it. So short of doubling/dropping the occasional video frame, I can't see any other way to "sync" my video to audio. Mike From alexcohn at netvision.net.il Wed Dec 19 17:01:39 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Wed, 19 Dec 2012 18:01:39 +0200 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: On Wed, Dec 19, 2012 at 5:46 PM, Mike Versteeg wrote: > video PTS, at least for MPEG-2, increments as integer (0, 1, 2, ...) Oops, my bad... I lost your original requirement to be MPEG-2 compliant. But maybe it would be enough to set REPEAT_FIRST_FIELD once in a while. Alex From mike at mikeversteeg.com Wed Dec 19 17:14:31 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Wed, 19 Dec 2012 17:14:31 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: >> video PTS, at least for MPEG-2, increments as integer (0, 1, 2, ...) > > Oops, my bad... I lost your original requirement to be MPEG-2 > compliant. But maybe it would be enough to set REPEAT_FIRST_FIELD once > in a while. Thanks. I am not familiar with that. Won't that introduce a double frame? And if that's a trick that works I assume it can only be used to delay my video, what if I need to speed it up? So other formats do support "true" time stamping? I have chosen MPEG-2 as my master for video recording as it is light on the CPU, compresses well and is accepted by most editing software. If there is a similar format that would solve my problem, I can look into using that. I was not even aware MPEG-2 was stricter than other codecs. Mike From alexcohn at netvision.net.il Wed Dec 19 17:28:19 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Wed, 19 Dec 2012 18:28:19 +0200 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: On Wed, Dec 19, 2012 at 6:14 PM, Mike Versteeg wrote: >>> video PTS, at least for MPEG-2, increments as integer (0, 1, 2, ...) >> >> Oops, my bad... I lost your original requirement to be MPEG-2 >> compliant. But maybe it would be enough to set REPEAT_FIRST_FIELD once >> in a while. > > Thanks. I am not familiar with that. Won't that introduce a double frame? No, it is sued to fight interlaced video (a.k.a telecine). The effect of this flag is that the frame is slowed down by 50%. It should be good enough to keep a ~30 fps video seamlessly synchronized with the audio stream that is a bit slower. > And if that's a trick that works I assume it can only be used to delay my video, what if I need to speed it up? That's where you can have problems. > So other formats do support "true" time stamping? Absolutely. MPEG-4 h264 stream has full support of flexible PTS per frame, and it will deliver much better quality. But it really needs more CPU, and you may face questions of licenses, patents, and royalties for use of different h264 encoders. Anyway, if you are looking at player support, MPEG-2 is the king. I hope that other people on this list will have more to share on this topic. Alex From rjvbertin at gmail.com Wed Dec 19 19:50:49 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Wed, 19 Dec 2012 19:50:49 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: <98CDC337-B28B-485A-8CE6-C08053BEB4F3@gmail.com> On Dec 19, 2012, at 16:46, Mike Versteeg wrote: > the audio clock. But I have since learned (offline) that this is not > possible as indeed the video PTS, at least for MPEG-2, increments as > integer (0, 1, 2, ...). There's no fiddling with it. So short of Can't you set the video's time scale such that an integer increment corresponds to an amount of real time that's relevant to your situation? (This is more or less what I did when I had to sync 12.5Hz video with 1kHz dynamic data; I reconstructed new QuickTime movies with a time scale of 12500) Of course I know next to nothing about libav O:^) R From gohar_h at instigatemobile.com Thu Dec 20 06:47:37 2012 From: gohar_h at instigatemobile.com (Gohar Hovhannisyan) Date: Thu, 20 Dec 2012 09:47:37 +0400 Subject: [Libav-user] Decoding HD videos on iPad devices In-Reply-To: References: Message-ID: <50D2A679.4090206@instigatemobile.com> Hi Carl, thank you for your answer. I've set the number of threads to 10, but every time my app crashes on avcodec_decode_video2. Could you please assist me what I'm doing wrong? Thanks, Gohar On 12/19/12 2:59 PM, Carl Eugen Hoyos wrote: > Gohar Hovhannisyan writes: > >> We wonder whether it is possible to perform decoding on >> iPad GPU to speed up decoding process (by compiling >> it with special flags, or with some patches) > Only if you implement it. > >> or run it parallel on dual core (iPad2) / quad-core (new iPad) >> or are there any other methods to speed up decoding process? > You can set the number of threads that decoding should use. > > Carl Eugen > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user From mike at mikeversteeg.com Thu Dec 20 11:12:50 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 20 Dec 2012 11:12:50 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: >>>> video PTS, at least for MPEG-2, increments as integer (0, 1, 2, ...) >>> >>> Oops, my bad... I lost your original requirement to be MPEG-2 >>> compliant. But maybe it would be enough to set REPEAT_FIRST_FIELD once >>> in a while. >> >> Thanks. I am not familiar with that. Won't that introduce a double frame? > > No, it is sued to fight interlaced video (a.k.a telecine). The effect > of this flag is that the frame is slowed down by 50%. It should be > good enough to keep a ~30 fps video seamlessly synchronized with the > audio stream that is a bit slower. If this does not introduce any other problems, like in editing software, then yes it should work. Unfortunately I'd still need a trick to speed up. >> So other formats do support "true" time stamping? > > Absolutely. MPEG-4 h264 stream has full support of flexible PTS per > frame, and it will deliver much better quality. But it really needs > more CPU, and you may face questions of licenses, patents, and > royalties for use of different h264 encoders. So far I've not been able to buy a licence for x264, but also it is too heavy on CPU. > Anyway, if you are looking at player support, MPEG-2 is the king. I > hope that other people on this list will have more to share on this > topic. Thanks Alex, you've been very helpful! Mike From mike at mikeversteeg.com Thu Dec 20 11:18:56 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Thu, 20 Dec 2012 11:18:56 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: <98CDC337-B28B-485A-8CE6-C08053BEB4F3@gmail.com> References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> <98CDC337-B28B-485A-8CE6-C08053BEB4F3@gmail.com> Message-ID: >> the audio clock. But I have since learned (offline) that this is not >> possible as indeed the video PTS, at least for MPEG-2, increments as >> integer (0, 1, 2, ...). There's no fiddling with it. So short of > > Can't you set the video's time scale such that an integer increment corresponds to an amount of real time that's relevant to your situation? No. The MPEG-2 encoder seems very picky (possibly part of the protocol) when it comes to that. In fact a time base other than 1/25 or 1/30 and it either returns an error or smacks me with an AV. Won't even do 29.97 fps or 50 or 60 fps. > Of course I know next to nothing about libav O:^) I've been using it for about a year and still feel I know nothing about it. It requires a lot of dedication, surfing and reading to get comfortable with it. Great code though, and (mostly) free. Mike From cehoyos at ag.or.at Thu Dec 20 12:13:56 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 20 Dec 2012 11:13:56 +0000 (UTC) Subject: [Libav-user] Decoding HD videos on iPad devices References: Message-ID: Carl Eugen Hoyos writes: > > We wonder whether it is possible to perform decoding on > > iPad GPU to speed up decoding process (by compiling > > it with special flags, or with some patches) > > Only if you implement it. Reconsidering this, it is possible that -vcodec h264_vda is what you are searching for (I don't know for sure). Carl Eugen From cehoyos at ag.or.at Thu Dec 20 12:12:39 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 20 Dec 2012 11:12:39 +0000 (UTC) Subject: [Libav-user] Decoding HD videos on iPad devices References: <50D2A679.4090206@instigatemobile.com> Message-ID: Gohar Hovhannisyan writes: > I've set the number of threads to 10, but every time my app > crashes on avcodec_decode_video2. (Backtrace etc. missing, see https://ffmpeg.org/bugreports.html ) Is the crash reproducible with ffmpeg (the application)? Please do not top-post here, Carl Eugen From rjvbertin at gmail.com Thu Dec 20 18:36:36 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Thu, 20 Dec 2012 18:36:36 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> Message-ID: <1205BAD9-76B2-4925-839A-6BB83E2674C6@gmail.com> On Dec 20, 2012, at 11:12, Mike Versteeg wrote: > If this does not introduce any other problems, like in editing > software, then yes it should work. Unfortunately I'd still need a > trick to speed up. Speeding up (probably) means reducing the duration of the preceding frame - which seems easy enough to accomplish with a simple caching scheme. > No. The MPEG-2 encoder seems very picky (possibly part of the > protocol) when it comes to that. In fact a time base other than 1/25 > or 1/30 and it either returns an error or smacks me with an AV. Won't > even do 29.97 fps or 50 or 60 fps. I'm not talking about frame rate or time base. I'm talking about the unit in which presentation durations are encoded, a factor that makes it possible to encode a continuous variable (time) on an arbitrary fixed point scale that's most suited to the required frame rate. A 1/25 time base (25Hz, 0.04s) would be amount to a frame duration of 24 'ticks' with the standard (QuickTime) timescale of 600/s, or 100 with a timescale of 2500/s . You don't see any difference between the two when watching a video, but with the latter timescale one has more precise control over individual frame timing. I doubt things work differently in libav. R. From mike at mikeversteeg.com Fri Dec 21 09:00:59 2012 From: mike at mikeversteeg.com (Mike Versteeg) Date: Fri, 21 Dec 2012 09:00:59 +0100 Subject: [Libav-user] How to perform drift compensation in MPEG-2 recorder In-Reply-To: <1205BAD9-76B2-4925-839A-6BB83E2674C6@gmail.com> References: <496155AF-A561-4036-BDCA-B9E1047871D3@gmail.com> <1205BAD9-76B2-4925-839A-6BB83E2674C6@gmail.com> Message-ID: >> No. The MPEG-2 encoder seems very picky (possibly part of the >> protocol) when it comes to that. In fact a time base other than 1/25 >> or 1/30 and it either returns an error or smacks me with an AV. Won't >> even do 29.97 fps or 50 or 60 fps. > > I'm not talking about frame rate or time base. I'm talking about the unit in which presentation durations are encoded, a factor that makes it possible to encode a continuous variable (time) on an arbitrary fixed point scale that's most suited to the required frame rate. A 1/25 time base (25Hz, 0.04s) would be amount to a frame duration of 24 'ticks' with the standard (QuickTime) timescale of 600/s, or 100 with a timescale of 2500/s . You don't see any difference between the two when watching a video, but with the latter timescale one has more precise control over individual frame timing. I doubt things work differently in libav. That's my original thought, unfortunately in ffmpeg the PTS is expressed in units of time_base, and (at least in MPEG-2) that equals the frame rate. Try anything other than 1/25 or 1/30 and the encoder refuses to do its job. Mike From trn200190 at gmail.com Fri Dec 21 10:55:22 2012 From: trn200190 at gmail.com (i m what i m ~~~~) Date: Fri, 21 Dec 2012 15:25:22 +0530 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data Message-ID: Hello All i am new to ffmpeg i have worked with VC++ before in VS2010. want to make an application in which i will stream h264 encrypted and encoded video using live media libraries and then decrypt and decode it and display it using direct show the video. For now i am able to encrypt and encode the video and decrypt the video but i need some free source decoder to which i can give NAL units and then give the decoded data to direct show libraries to show the video..... Please help me...... Will ffmpeg libraries be able to decode h 264 data and then will be able to give data to direct show and play it....... Please give me the source link for ffmpeg source code which can be built in VS2010 and steps to built it. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From mybrokenbeat at gmail.com Fri Dec 21 11:18:00 2012 From: mybrokenbeat at gmail.com (Oleg) Date: Fri, 21 Dec 2012 12:18:00 +0200 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: References: Message-ID: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> FFmpeg CAN'T be built in VS2010 by default as VS doesn't support C89 standard. You can build ffmpeg with MINGW compiler and use output libraries in VS. Btw, Windows Vista and above have built-in support of decoding h264 in Media Foundation framework as well as GPU acceleration support. 21.12.2012, ? 11:55, i m what i m ~~~~ ???????(?): > Hello All > > i am new to ffmpeg i have worked with VC++ before in VS2010. > want to make an application in which i will stream h264 encrypted and encoded video using live media libraries and then decrypt and decode it and display it using direct show the video. > For now i am able to encrypt and encode the video and decrypt the video but i need some free source decoder to which i can give NAL units and then give the decoded data to direct show libraries to show the video..... > Please help me...... > > Will ffmpeg libraries be able to decode h 264 data and then will be able to give data to direct show and play it....... > Please give me the source link for ffmpeg source code which can be built in VS2010 and steps to built it. > > Thanks > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user From trn200190 at gmail.com Fri Dec 21 11:21:22 2012 From: trn200190 at gmail.com (i m what i m ~~~~) Date: Fri, 21 Dec 2012 15:51:22 +0530 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> Message-ID: Sir Is Media Foundation framework free i mean open source ? How can we use Media Foundation framework to decode the h264 video? On Fri, Dec 21, 2012 at 3:48 PM, Oleg wrote: > Media Foundation framework -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryltsov at gmail.com Fri Dec 21 11:42:24 2012 From: ryltsov at gmail.com (Roman Ryltsov) Date: Fri, 21 Dec 2012 12:42:24 +0200 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> Message-ID: Media Foundation is core Windows API. To correct Oleg on his previous post, its H.264 decoder is available starting Windows 7 and is a part of baseline Windows (no additional installations necessary). The decoder is available through both video processing APIs, DirectShow and Media Foundation, which you can leverage in your application. There is a multitude of community samples available for DirectShow and there are Media Foundation samples in Windows SDK. You can also use FFmpeg's H.264 video decoder, the quick start for which is pre-built FFmpeg for Windows available from http://ffmpeg.zeranoe.com/builds/ where you can grab redistributable DLLs and LIBs to link your Visual Studio project against. Hope this helps, Roman On Fri, Dec 21, 2012 at 12:21 PM, i m what i m ~~~~ wrote: > Sir > > Is Media Foundation framework free i mean open source ? > How can we use Media Foundation framework to decode the h264 video? > > On Fri, Dec 21, 2012 at 3:48 PM, Oleg wrote: > >> Media Foundation framework > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trn200190 at gmail.com Fri Dec 21 11:48:50 2012 From: trn200190 at gmail.com (i m what i m ~~~~) Date: Fri, 21 Dec 2012 16:18:50 +0530 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> Message-ID: Thanks for the useful info Roman sir i downloaded the "FFmpeg git-8b6aeb1 64-bit Static " build form the link you have given but i am not able to decode the h264 video how to decode the video i have what i have to type in cmd prompt On Fri, Dec 21, 2012 at 4:12 PM, Roman Ryltsov wrote: > Media Foundation is core Windows API. To correct Oleg on his previous > post, its H.264 decoder is available starting Windows 7 and is a part of > baseline Windows (no additional installations necessary). > > The decoder is available through both video processing APIs, DirectShow > and Media Foundation, which you can leverage in your application. There is > a multitude of community samples available for DirectShow and there are > Media Foundation samples in Windows SDK. > > You can also use FFmpeg's H.264 video decoder, the quick start for which > is pre-built FFmpeg for Windows available from > http://ffmpeg.zeranoe.com/builds/ where you can grab redistributable DLLs > and LIBs to link your Visual Studio project against. > > Hope this helps, > Roman > > > > > On Fri, Dec 21, 2012 at 12:21 PM, i m what i m ~~~~ wrote: > >> Sir >> >> Is Media Foundation framework free i mean open source ? >> How can we use Media Foundation framework to decode the h264 video? >> >> On Fri, Dec 21, 2012 at 3:48 PM, Oleg wrote: >> >>> Media Foundation framework >> >> >> > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryltsov at gmail.com Fri Dec 21 11:52:32 2012 From: ryltsov at gmail.com (Roman Ryltsov) Date: Fri, 21 Dec 2012 12:52:32 +0200 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> Message-ID: You don't need "static" unless you are going to use command line pre-built executable. Have a look here: http://stackoverflow.com/questions/11701635/use-ffmpeg-in-visual-studio/11701737#11701737if you are going to link to FFmpeg (libav*) as "to API/library". There is a link to minimal app there as well which you can quick start from. Roman On Fri, Dec 21, 2012 at 12:48 PM, i m what i m ~~~~ wrote: > Thanks for the useful info Roman sir i downloaded the "FFmpeg git-8b6aeb1 > 64-bit Static " > build form the link you have given but i am not able to decode the h264 > video how to decode the video i have what i have to type in cmd prompt > > On Fri, Dec 21, 2012 at 4:12 PM, Roman Ryltsov wrote: > >> Media Foundation is core Windows API. To correct Oleg on his previous >> post, its H.264 decoder is available starting Windows 7 and is a part of >> baseline Windows (no additional installations necessary). >> >> The decoder is available through both video processing APIs, DirectShow >> and Media Foundation, which you can leverage in your application. There is >> a multitude of community samples available for DirectShow and there are >> Media Foundation samples in Windows SDK. >> >> You can also use FFmpeg's H.264 video decoder, the quick start for which >> is pre-built FFmpeg for Windows available from >> http://ffmpeg.zeranoe.com/builds/ where you can grab redistributable >> DLLs and LIBs to link your Visual Studio project against. >> >> Hope this helps, >> Roman >> >> >> >> >> On Fri, Dec 21, 2012 at 12:21 PM, i m what i m ~~~~ wrote: >> >>> Sir >>> >>> Is Media Foundation framework free i mean open source ? >>> How can we use Media Foundation framework to decode the h264 video? >>> >>> On Fri, Dec 21, 2012 at 3:48 PM, Oleg wrote: >>> >>>> Media Foundation framework >>> >>> >>> >> >> _______________________________________________ >> Libav-user mailing list >> Libav-user at ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/libav-user >> >> > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trn200190 at gmail.com Fri Dec 21 12:21:27 2012 From: trn200190 at gmail.com (i m what i m ~~~~) Date: Fri, 21 Dec 2012 16:51:27 +0530 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> Message-ID: Sir i have directly downloaded the exe for ffmpeg now how do i pass the file name and command line parameter to decode h264 file? On Fri, Dec 21, 2012 at 4:22 PM, Roman Ryltsov wrote: > You don't need "static" unless you are going to use command line pre-built > executable. > > Have a look here: > http://stackoverflow.com/questions/11701635/use-ffmpeg-in-visual-studio/11701737#11701737if you are going to link to FFmpeg (libav*) as "to API/library". There is a > link to minimal app there as well which you can quick start from. > > Roman > > > > On Fri, Dec 21, 2012 at 12:48 PM, i m what i m ~~~~ wrote: > >> Thanks for the useful info Roman sir i downloaded the "FFmpeg >> git-8b6aeb1 64-bit Static " >> build form the link you have given but i am not able to decode the h264 >> video how to decode the video i have what i have to type in cmd prompt >> >> On Fri, Dec 21, 2012 at 4:12 PM, Roman Ryltsov wrote: >> >>> Media Foundation is core Windows API. To correct Oleg on his previous >>> post, its H.264 decoder is available starting Windows 7 and is a part of >>> baseline Windows (no additional installations necessary). >>> >>> The decoder is available through both video processing APIs, DirectShow >>> and Media Foundation, which you can leverage in your application. There is >>> a multitude of community samples available for DirectShow and there are >>> Media Foundation samples in Windows SDK. >>> >>> You can also use FFmpeg's H.264 video decoder, the quick start for which >>> is pre-built FFmpeg for Windows available from >>> http://ffmpeg.zeranoe.com/builds/ where you can grab redistributable >>> DLLs and LIBs to link your Visual Studio project against. >>> >>> Hope this helps, >>> Roman >>> >>> >>> >>> >>> On Fri, Dec 21, 2012 at 12:21 PM, i m what i m ~~~~ >> > wrote: >>> >>>> Sir >>>> >>>> Is Media Foundation framework free i mean open source ? >>>> How can we use Media Foundation framework to decode the h264 video? >>>> >>>> On Fri, Dec 21, 2012 at 3:48 PM, Oleg wrote: >>>> >>>>> Media Foundation framework >>>> >>>> >>>> >>> >>> _______________________________________________ >>> Libav-user mailing list >>> Libav-user at ffmpeg.org >>> http://ffmpeg.org/mailman/listinfo/libav-user >>> >>> >> >> _______________________________________________ >> Libav-user mailing list >> Libav-user at ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/libav-user >> >> > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mybrokenbeat at gmail.com Fri Dec 21 12:22:08 2012 From: mybrokenbeat at gmail.com (Oleg) Date: Fri, 21 Dec 2012 13:22:08 +0200 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> Message-ID: <14287177-D4A9-4E9F-A3A9-14E151BC01D0@gmail.com> It's closed source, but it's a part of Windows OS. So you can use it free in your commercial application and even doesn't have h264 patenting problems as Microsoft has already payed for that. This framework has documentation where you can find all answers on your questions: http://msdn.microsoft.com/ru-ru/library/windows/desktop/dd797815(v=vs.85).aspx Btw, not it's available not from Vista(as I mentioned before), but from Windows 7. 21.12.2012, ? 12:21, i m what i m ~~~~ ???????(?): > Sir > > Is Media Foundation framework free i mean open source ? > How can we use Media Foundation framework to decode the h264 video? > > On Fri, Dec 21, 2012 at 3:48 PM, Oleg wrote: > Media Foundation framework > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From rjvbertin at gmail.com Fri Dec 21 12:30:02 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Fri, 21 Dec 2012 12:30:02 +0100 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: <14287177-D4A9-4E9F-A3A9-14E151BC01D0@gmail.com> References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> <14287177-D4A9-4E9F-A3A9-14E151BC01D0@gmail.com> Message-ID: <957E0E08-F3B2-45FD-848B-CA6DA9F2F90F@gmail.com> On Dec 21, 2012, at 12:22, Oleg wrote: > It's closed source, but it's a part of Windows OS. So you can use it free in your commercial application and even doesn't have h264 patenting problems as Microsoft has already payed for that. Very interesting, though I have some hopes to use this to improve QuickTime's handling of mpeg4 content on MS Windows O:-) > This framework has documentation where you can find all answers on your questions: > http://msdn.microsoft.com/ru-ru/library/windows/desktop/dd797815(v=vs.85).aspx http://msdn.microsoft.com/library/windows/desktop/dd797815(v=vs.85).aspx will probably work for more readers ;) R From trn200190 at gmail.com Fri Dec 21 12:37:29 2012 From: trn200190 at gmail.com (i m what i m ~~~~) Date: Fri, 21 Dec 2012 17:07:29 +0530 Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data In-Reply-To: <957E0E08-F3B2-45FD-848B-CA6DA9F2F90F@gmail.com> References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> <14287177-D4A9-4E9F-A3A9-14E151BC01D0@gmail.com> <957E0E08-F3B2-45FD-848B-CA6DA9F2F90F@gmail.com> Message-ID: TO Oleg Sir the link you gave,i didn't find the download link and how to use,even i didn't get the source fie as the whole text on site is not in english plz do a favor tell how to use it On Fri, Dec 21, 2012 at 5:00 PM, "Ren? J.V. Bertin" wrote: > On Dec 21, 2012, at 12:22, Oleg wrote: > > > It's closed source, but it's a part of Windows OS. So you can use it > free in your commercial application and even doesn't have h264 patenting > problems as Microsoft has already payed for that. > > Very interesting, though I have some hopes to use this to improve > QuickTime's handling of mpeg4 content on MS Windows O:-) > > > This framework has documentation where you can find all answers on your > questions: > > > http://msdn.microsoft.com/ru-ru/library/windows/desktop/dd797815(v=vs.85).aspx > > http://msdn.microsoft.com/library/windows/desktop/dd797815(v=vs.85).aspxwill probably work for more readers ;) > > > R > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From srijith.vasudevan at gmail.com Fri Dec 21 17:05:37 2012 From: srijith.vasudevan at gmail.com (srijith vasudevan) Date: Fri, 21 Dec 2012 21:35:37 +0530 Subject: [Libav-user] facing an issue with avcodec_decode_subtitle2 Message-ID: Hello, I am working on an assignment (using C++) to decode all the subtitle streams present in a m2ts file using libav. I have a m2ts file with one video stream (video stream index = 0), one audio stream (audio stream index = 1) and 5 subtitle streams ( stream indices = 2, 3, 4, 5). I first noticed the problem when I compared the position (x, y, w, h) I got from the decoded subtitle against the actual subtitle position from its control file. *The details of the actual events* SUBTITLE_STREAM_INDEX_2 Event1 (X="607" Y="780" START_FRAME="764") SUBTITLE_STREAM_INDEX_3 Event1 (X="575" Y="780" START_FRAME="764") SUBTITLE_STREAM_INDEX_4 Event1 (X="701" Y="780" START_FRAME="764") SUBTITLE_STREAM_INDEX_5 Event1 (X="483" Y="777" START_FRAME="765") * Quote: Please note Event1 of SUBTITLE_STREAM_INDEX_2, SUBTITLE_STREAM_INDEX_3, SUBTITLE_STREAM_INDEX_4 start at frame no 764. * When I ran the application, it first decoded Event1 of SUBTITLE_STREAM_INDEX_4 and I got the position values from the decoded subtitle as (701, 780, 507, 133). Next it decoded Event1 of SUBTITLE_STREAM_INDEX_2 and the position values decoded were as follows (701, 780, 507, 133). Please note the mismatch in values. The values were same for decoded subtitle of SUBTITLE_STREAM_INDEX_3. AS the next step I am decoding the subtitle and generating a png file. This is when I noticed the issue. For example I am decoding SUBTITLE_STREAM_INDEX_4 at frame no = 764. I generated the image using the subtitle->rects[0]->pict.data. This is correct subtitle. (Assume the dialog to be "hi there"). Now I have another subtitle stream (index = 2) which also starts from the same frame number (frame no = 764). Now when I generate a png using this decoded subtitle it has the same subtitle text as the one decoded from previous index. (the actual dialog is "hola", but the png generated had the dialog as "hi there"). It is basically giving me the position and data of the subtitle decoded from the first SUBTITLE_STREAM encountered for a particular frame number. I am posting the part of code: *Code:* AVPacket packet; //looping till end of file { av_init_packet(&packet); av_read_frame(pFormatContext, &packet); if((packet.stream_index == m_subtitleStreamIndex[0]) || (packet.stream_index == m_subtitleStreamIndex[1]) || (packet.stream_index == m_subtitleStreamIndex[2]) || (packet.stream_index == m_subtitleStreamIndex[3])) { int has_subtitle = 0; AVSubtitle* subtitle = new AVSubtitle; avcodec_decode_subtitle2(pSubtitleCodecContext, subtitle, &has_subtitle, &packet); if (has_subtitle != 0) { if (subtitle->rects) { struct SwsContext *mSwsContext = sws_getContext(subtitle->rects[0]->w, subtitle->rects[0]->h, pSubtitleCodecContext->pix_fmt, subtitle->rects[0]->w, subtitle->rects[0]->h, PIX_FMT_RGBA, SWS_BICUBIC, NULL, NULL, NULL); AVFrame *pPicture = AllocatePicture(PIX_FMT_RGBA, subtitle->rects[0]->w, subtitle->rects[0]->h); /* convert to RGB */ sws_scale(mSwsContext, (const uint8_t **) subtitle->rects[0]->pict.data, subtitle->rects[0]->pict.linesize, 0, subtitle->rects[0]->h, pPicture->data, pPicture->linesize); //code to generate png av_free(pPicture); sws_freeContext(mSwsContext); } } } avsubtitle_free(subtitle); } } Could anyone please advice if I am doing something wrong here or suggest a solution to this problem? I am expecting your priceless guidance and help. Thanks, Srijith -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Fri Dec 21 17:41:35 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 21 Dec 2012 16:41:35 +0000 (UTC) Subject: [Libav-user] Please help me will ffmpeg be able to decode the h264 data References: <51073774-9D3C-46BC-8857-E58E20E53262@gmail.com> Message-ID: Oleg writes: > FFmpeg CAN'T be built in VS2010 FFmpeg can be built by VS2010, it is tested regularly, please see http://ffmpeg.org/platform.html#Microsoft-Visual-C_002b_002b and http://fate.ffmpeg.org/ Carl Eugen From faeem.ali at gmail.com Fri Dec 21 23:50:16 2012 From: faeem.ali at gmail.com (faeem) Date: Sat, 22 Dec 2012 00:50:16 +0200 Subject: [Libav-user] Hardware decoding via libva Message-ID: <50D4E7A8.7060608@gmail.com> Hi All ... I currently use a media player based on ffplay.c, but have a problem where HD video playing on an Intel Atom processor is far too slow, and uses too much CPU time. My understanding is that the problem may be resolved by using direct hardware decoding via VAAPI/libva. I have tested VLC compiled with VAAPI support and there is a huge performance improvement when playing HD video. I'm trying to accomplish something similar with libav. Would someone please direct me to documentation and/or some other explanation of how to perform hardware decoding using VAAPI/libva with ffmpeg's libav libraries. Code examples would be great. I have no interest in hardware encoding, only decoding. Unfortunately, several hours on Google have not yielded any positive results thus far; I'm probably looking in the wrong places. I have compiled ffmpeg/libav with VAAPI support. The ffplay.c code has a line that states: // FIXME use direct rendering I need to know how to fix that FIXME. Additional info: - My media player is based on the 0.11.1 version of ffmpeg's ffplay.c - My media player has been altered to link against the new 1.0 version of ffmpeg/libav. However my code is still derived from the ffplay.c included in ffmpeg 0.11.1. - The main modification I've made is to render the video via OpenGL instead of using an overlay. This is a requirement for the project on which I'm working. The only other major modification is removing the features of ffplay.c I don't require, which is pretty much everything aside from the basic decode and render code. - The code is being developed on Linux. The graphics cards being used are NVIDIA and Intel i9xxx. Thanks in advance. Faeem From cehoyos at ag.or.at Sat Dec 22 01:53:11 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sat, 22 Dec 2012 00:53:11 +0000 (UTC) Subject: [Libav-user] Hardware decoding via libva References: <50D4E7A8.7060608@gmail.com> Message-ID: faeem writes: > Would someone please direct me to documentation > and/or some other explanation of how to perform > hardware decoding using VAAPI/libva with ffmpeg's > libav libraries. Code examples would be great. I know of two examples, the va-api code in vlc and the code in a patch for MPlayer, see for example http://thread.gmane.org/gmane.comp.video.mplayer.devel/61734/focus=61744 [...] > // FIXME use direct rendering > > I need to know how to fix that FIXME. This is not related to va-api at all. > - The main modification I've made is to render the video via OpenGL > instead of using an overlay. I sounds like a very welcome addition to the FFmpeg codebase, please consider sending a patch. Carl Eugen From klaussfreire at gmail.com Sat Dec 22 02:35:05 2012 From: klaussfreire at gmail.com (Claudio Freire) Date: Fri, 21 Dec 2012 22:35:05 -0300 Subject: [Libav-user] Hardware decoding via libva In-Reply-To: References: <50D4E7A8.7060608@gmail.com> Message-ID: On Fri, Dec 21, 2012 at 9:53 PM, Carl Eugen Hoyos wrote: >> - The main modification I've made is to render the video via OpenGL >> instead of using an overlay. > > I sounds like a very welcome addition to the FFmpeg > codebase, please consider sending a patch. Have in mind that overlays tend to perform better than naively implemented OpenGL rendering. It's good to have the option though. From faeem.ali at gmail.com Sat Dec 22 13:00:19 2012 From: faeem.ali at gmail.com (faeem) Date: Sat, 22 Dec 2012 14:00:19 +0200 Subject: [Libav-user] Hardware decoding via libva In-Reply-To: References: <50D4E7A8.7060608@gmail.com> Message-ID: <50D5A0D3.2020108@gmail.com> Hi Claudio ... I'll look into patching ffplay.c with my OpenGL changes and submitting the code once I've gotten the direct rendering problem sorted out. I am aware of the performance loss caused by OpenGL. It was chosen over overlays because it makes adding in special effects much easier, especially time critical stuff. Faeem On 22/12/2012 03:35, Claudio Freire wrote: > On Fri, Dec 21, 2012 at 9:53 PM, Carl Eugen Hoyos wrote: >>> - The main modification I've made is to render the video via OpenGL >>> instead of using an overlay. >> I sounds like a very welcome addition to the FFmpeg >> codebase, please consider sending a patch. > Have in mind that overlays tend to perform better than naively > implemented OpenGL rendering. > It's good to have the option though. > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user From faeem.ali at gmail.com Sat Dec 22 13:15:07 2012 From: faeem.ali at gmail.com (faeem) Date: Sat, 22 Dec 2012 14:15:07 +0200 Subject: [Libav-user] Hardware decoding via libva In-Reply-To: References: <50D4E7A8.7060608@gmail.com> Message-ID: <50D5A44B.5030408@gmail.com> On 22/12/2012 02:53, Carl Eugen Hoyos wrote: > faeem writes: > > I know of two examples, the va-api code in vlc and the code in a patch > for MPlayer, see for example > http://thread.gmane.org/gmane.comp.video.mplayer.devel/61734/focus=61744 > [...] Thanks. I'll be looking into those examples ASAP. >> // FIXME use direct rendering >> >> I need to know how to fix that FIXME. > This is not related to va-api at all. I selected that //FIXME because it specified "direct rendering", which I took to mean "handled by the GPU". It seems I was mistaken there. My conceptual understanding of va-api thus far, within the ffmpeg framework, is that libavcodec will read an encoded video frame, then use va-api and the GPU to perform decoding of that frame instead of performing decoding in software. The end result will probably be a frame in YUV. I'll need to run the YUV to RGB conversion on each frame if I'm running OpenGL and this will still be CPU intensive. I would benefit from the hardware frame decoding though, and that alone should make a significant difference. Is this correct? Faeem From cehoyos at ag.or.at Sat Dec 22 13:22:16 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sat, 22 Dec 2012 12:22:16 +0000 (UTC) Subject: [Libav-user] Hardware decoding via libva References: <50D4E7A8.7060608@gmail.com> <50D5A44B.5030408@gmail.com> Message-ID: faeem writes: > I'll need to run the YUV to RGB conversion on each frame > if I'm running OpenGL and this will still be CPU intensive. (I don't think this is correct but it is not related to va-api at all, consider testing mplayer -vo gl, it is very fast because it does not need CPU conversion of YUV->RGB.) [...] > Is this correct? I am certainly no expert for va-api, but I wonder if you already realized that ffmpeg and ffplay (the applications) do not support va-api in any way, libavcodec contains code that application may use to decode using va-api, see vlc source code and the linked MPlayer patch for examples. Carl Eugen From faeem.ali at gmail.com Sat Dec 22 13:28:54 2012 From: faeem.ali at gmail.com (faeem) Date: Sat, 22 Dec 2012 14:28:54 +0200 Subject: [Libav-user] Hardware decoding via libva In-Reply-To: References: <50D4E7A8.7060608@gmail.com> <50D5A44B.5030408@gmail.com> Message-ID: <50D5A786.5080900@gmail.com> Thanks for the YUV->RGB tip. I'll look into that. I think I read on wikipedia that ffmpeg/libavcodec has no va-api support, but does contain data structures that allow it to be used with va-api. I figured someone here would have some idea on what to do, and I've already got some very useful advice and code examples. So, thanks :) Faeem On 22/12/2012 14:22, Carl Eugen Hoyos wrote: > faeem writes: > >> I'll need to run the YUV to RGB conversion on each frame >> if I'm running OpenGL and this will still be CPU intensive. > (I don't think this is correct but it is not related to > va-api at all, consider testing mplayer -vo gl, it is > very fast because it does not need CPU conversion of > YUV->RGB.) > > [...] > >> Is this correct? > I am certainly no expert for va-api, but I wonder if > you already realized that ffmpeg and ffplay (the > applications) do not support va-api in any way, > libavcodec contains code that application may use > to decode using va-api, see vlc source code and > the linked MPlayer patch for examples. > > Carl Eugen > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user From lixiaohui9219 at 126.com Sat Dec 22 13:59:32 2012 From: lixiaohui9219 at 126.com (=?GBK?B?wOjQobvU?=) Date: Sat, 22 Dec 2012 20:59:32 +0800 (CST) Subject: [Libav-user] question about hls support in ffmpeg 0.8.5 Message-ID: <63b03b2e.2282b.13bc2b2725f.Coremail.lixiaohui9219@126.com> Hi all, Anybody can tell me whether ffmpeg can support HLS play,pause and seek for hsl VOD using Wowza stream server ? Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mybrokenbeat at gmail.com Sat Dec 22 14:22:01 2012 From: mybrokenbeat at gmail.com (Oleg) Date: Sat, 22 Dec 2012 15:22:01 +0200 Subject: [Libav-user] Hardware decoding via libva In-Reply-To: <50D5A44B.5030408@gmail.com> References: <50D4E7A8.7060608@gmail.com> <50D5A44B.5030408@gmail.com> Message-ID: You're misunderstanding some concepts. There are two operations that can be accelerated by GPU: decoding and yuv->rgb converting. First thing can be achieved by vaapi as you mentioned. Second, by using OpenGL shader(I prefer OpenGL as it's cross-platform. Other option is to use DirectX on Win platform) that will convert YUV->RGB and draw converted frame immediately. 22.12.2012, ? 14:15, faeem ???????(?): > On 22/12/2012 02:53, Carl Eugen Hoyos wrote: >> faeem writes: >> >> I know of two examples, the va-api code in vlc and the code in a patch for MPlayer, see for example http://thread.gmane.org/gmane.comp.video.mplayer.devel/61734/focus=61744 [...] > Thanks. I'll be looking into those examples ASAP. > >>> // FIXME use direct rendering >>> >>> I need to know how to fix that FIXME. >> This is not related to va-api at all. > I selected that //FIXME because it specified "direct rendering", which I took to mean "handled by the GPU". It seems I was mistaken there. > > My conceptual understanding of va-api thus far, within the ffmpeg framework, is that libavcodec will read an encoded video frame, then use va-api and the GPU to perform decoding of that frame instead of performing decoding in software. > > The end result will probably be a frame in YUV. I'll need to run the YUV to RGB conversion on each frame if I'm running OpenGL and this will still be CPU intensive. I would benefit from the hardware frame decoding though, and that alone should make a significant difference. > > Is this correct? > > Faeem > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user From haihao.xiang at intel.com Mon Dec 24 03:07:33 2012 From: haihao.xiang at intel.com (Xiang, Haihao) Date: Mon, 24 Dec 2012 10:07:33 +0800 Subject: [Libav-user] Hardware decoding via libva In-Reply-To: References: <50D4E7A8.7060608@gmail.com> <50D5A44B.5030408@gmail.com> Message-ID: <1356314853.2652.22.camel@xhh-ilk32> VA API has vaPutSurface() to directly render the decoded frame on a drawable, you can refer to the code of mplayer vaapi (git://gitorious.org/vaapi/mplayer.git) Regards Haihao > You're misunderstanding some concepts. There are two operations that can be accelerated by GPU: decoding and yuv->rgb converting. First thing can be achieved by vaapi as you mentioned. Second, by using OpenGL shader(I prefer OpenGL as it's cross-platform. Other option is to use DirectX on Win platform) that will convert YUV->RGB and draw converted frame immediately. > > > > 22.12.2012, ? 14:15, faeem ???????(?): > > > On 22/12/2012 02:53, Carl Eugen Hoyos wrote: > >> faeem writes: > >> > >> I know of two examples, the va-api code in vlc and the code in a patch for MPlayer, see for example http://thread.gmane.org/gmane.comp.video.mplayer.devel/61734/focus=61744 [...] > > Thanks. I'll be looking into those examples ASAP. > > > >>> // FIXME use direct rendering > >>> > >>> I need to know how to fix that FIXME. > >> This is not related to va-api at all. > > I selected that //FIXME because it specified "direct rendering", which I took to mean "handled by the GPU". It seems I was mistaken there. > > > > My conceptual understanding of va-api thus far, within the ffmpeg framework, is that libavcodec will read an encoded video frame, then use va-api and the GPU to perform decoding of that frame instead of performing decoding in software. > > > > The end result will probably be a frame in YUV. I'll need to run the YUV to RGB conversion on each frame if I'm running OpenGL and this will still be CPU intensive. I would benefit from the hardware frame decoding though, and that alone should make a significant difference. > > > > Is this correct? > > > > Faeem > > > > _______________________________________________ > > Libav-user mailing list > > Libav-user at ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/libav-user > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user From klaussfreire at gmail.com Mon Dec 24 03:42:28 2012 From: klaussfreire at gmail.com (Claudio Freire) Date: Sun, 23 Dec 2012 23:42:28 -0300 Subject: [Libav-user] Hardware decoding via libva In-Reply-To: References: <50D4E7A8.7060608@gmail.com> <50D5A44B.5030408@gmail.com> Message-ID: On Sat, Dec 22, 2012 at 10:22 AM, Oleg wrote: > You're misunderstanding some concepts. There are two operations that can be accelerated by GPU: decoding and yuv->rgb converting. First thing can be achieved by vaapi as you mentioned. Second, by using OpenGL shader(I prefer OpenGL as it's cross-platform. Other option is to use DirectX on Win platform) that will convert YUV->RGB and draw converted frame immediately. If you don't use a shader, YUV-RGB conversion not only consumes cycles. You can actually ignore the cycles it takes on most modern CPUs. The problem is RGB requires a lot more bandwidth to upload back into the CPU, and that usually becomes a bottleneck on lower-end systems for HD content (which requires quite a lot of bandwidth). Hence my "naively" comment earlier. You don't only need to get the result in YUV to the shader, but also in downsampled YUV (ie: 4:1:1, 4:2:1, 4:2:2 or whatever format the codec is using internally). From nkipe at tatapowersed.com Mon Dec 24 06:26:25 2012 From: nkipe at tatapowersed.com (Navin) Date: Mon, 24 Dec 2012 10:56:25 +0530 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: References: <50CEF1CC.50308@tatapowersed.com> Message-ID: <50D7E781.6080409@tatapowersed.com> Actually I'm giving avipicture_fill a value. I didn't show that bit of the code. /g_pFrameRGB = avcodec_alloc_frame_proc();/ But it's strange that purify is showing an error while reading from data[0][0]. At least the first value should've been read correctly. Am a bit worried about this, since bounds errors would give problems at completely unexpected times. Could anyone help with this? Perhaps you'd get the same error if you try even a simple ffmpeg program with Purify. Navin On 12/18/2012 2:57 PM, Alex Cohn wrote: >> So I reduced the code to just this >> pAreaInMemory[0] = g_pFrameRGB->data[0][0]; >> and I'm still getting the error (which I've shown above). >> The code goes something like this (I've shown many of the initializations in >> GetFrame itself although they're supposed to be outside): >> >> bool GetFrame() >> { >> ...blah... >> AVFrame* g_pFrameRGB = NULL; >> avpicture_fill_proc((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, >> g_metadata->WIDTH, g_metadata->HEIGHT); > avipicture_fill does not expect NULL pointer to AVPicture as first > parameter. The pointer must be initialized (see doc/examples/muxing.c > for the correct usage). > > BR, > Alex > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > I've got a piece of code which extracts every rgb pixel from a video and displays it without any problem. But when I ran it with Purify, I got these errors: * [E] ABR: Array bounds read in GetFrame {197 occurrences} Reading 1 byte from 0x04ae0040 (1 byte at 0x04ae0040 illegal) Address 0x04ae0040 is 16 bytes before the beginning of a 1769472 byte block at 0x04ae0050 Address 0x04ae0040 points to a malloc'd block in heap 0x003a0000 Thread ID: 0x17c4* So I reduced the code to just this *pAreaInMemory[0] = g_pFrameRGB->data[0][0];* and I'm still getting the error (which I've shown above). The code goes something like this (I've shown many of the initializations in GetFrame itself although they're supposed to be outside): bool GetFrame() { ...blah... AVFrame* g_pFrameRGB = NULL; avpicture_fill_proc((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); ...blah... sws_scale_proc(g_sws_ctx, (uint8_t const * const *)g_pFrame->data, g_pFrame->linesize, 0, g_metadata->HEIGHT, g_pFrameRGB->data, g_pFrameRGB->linesize ); ...blah... unsigned char* pAreaInMemory = (unsigned char*) malloc( sizeof(unsigned char) * 1024 * 768 ); ...get the video data here... pAreaInMemory[0] = g_pFrameRGB->data[0][0]; ...blah... free(pAreaInMemory); } Why is there a bounds problem when reading from data[0][0] ? I noticed the way data is initialized in ffmpeg. Is this purify error something I can ignore (there's no memory leak. Just the bounds error) or can it lead to serious problems? -- Navin -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexcohn at netvision.net.il Mon Dec 24 11:35:04 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Mon, 24 Dec 2012 12:35:04 +0200 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: <50D7E781.6080409@tatapowersed.com> References: <50CEF1CC.50308@tatapowersed.com> <50D7E781.6080409@tatapowersed.com> Message-ID: On Mon, Dec 24, 2012 at 7:26 AM, Navin wrote: > Actually I'm giving avipicture_fill a value. I didn't show that bit of the code. > > g_pFrameRGB = avcodec_alloc_frame_proc(); Yes, this should be correct. > But it's strange that purify is showing an error while reading from data[0][0]. Actually, after your call to avpicture_fill_proc(), data[0] is pointing to pbuffer[0]. You didn't disclose how you initialized pbuffer, so it's impossible to tell why Purify is unhappy with this address. By the way, I don't understand the rationale of allocating another chunk of memory, pAreaInMemory. Whatever you do with these bytes, why don't you use pbuffer directly? BR, Alex From mtaha.ansari at gmail.com Mon Dec 24 11:55:17 2012 From: mtaha.ansari at gmail.com (Taha Ansari) Date: Mon, 24 Dec 2012 15:55:17 +0500 Subject: [Libav-user] Choppy dshow audio playback with ffplay Message-ID: Hi! I have a small test application that sends microphone audio over network. But the audio playback is sometimes very choppy/lossy, and also I initially need to 'seek' ffplay back to hear audio with minimum latency. I do this in Windows, using dshow, zeranoe ffmpeg builds, MSVS; and here is custom code of relevance (output file is in extension .mp2, and packets are sent on udp. I tried AAC extension as well, but results are somewhat the same): *********** + Decoding part: + ************* if(this->packet.stream_index == this->audioStream) { unsigned int samples_size= 0; AVCodecContext *c = outputCodecCtxAudio; int finalPTS = 0; samples = (short *) av_fast_realloc(samples, &samples_size, FFMAX(packet.size, AVCODEC_MAX_AUDIO_FRAME_SIZE)); finalPTS = packet.pts; audiobufsize = AVCODEC_MAX_AUDIO_FRAME_SIZE*2; avcodec_decode_audio3(pCodecCtxAudio, samples, &audiobufsize, &packet); if(pCodecCtxAudio->sample_rate != c->sample_rate || pCodecCtxAudio->channels != c->channels ) { if ( rs == NULL) { rs = av_audio_resample_init(c->channels, pCodecCtxAudio->channels, c->sample_rate, pCodecCtxAudio->sample_rate, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16, 0,0,0,0); } } if(pCodecCtxAudio->sample_rate != c->sample_rate || pCodecCtxAudio->channels != c->channels) { int size_out = audio_resample(rs, (short *)buffer_resample, samples, audiobufsize/ (pCodecCtxAudio->channels * 2) ); av_fifo_generic_write(fifo, (uint8_t *)buffer_resample, size_out * c->channels * 2, NULL ); } else { av_fifo_generic_write(fifo, (uint8_t *)samples, audiobufsize, NULL ); } } *********** - Decoding part: - ************* *********** + Encoding part: + *************** if ( decoderData->audiobufsize ) { AVPacket pkt; av_init_packet(&pkt); AVCodecContext* c = encoderData->audio_st->codec; int frame_bytes = c->frame_size * 2 * c->channels; while( av_fifo_size(decoderData->fifo) >= frame_bytes ) { int ret = av_fifo_generic_read( decoderData->fifo, data_buf, frame_bytes, NULL ); /* encode the samples */ pkt.size= avcodec_encode_audio(c, audio_out, frame_bytes /*packet.size*/, (short *)data_buf); pkt.stream_index= encoderData->audio_st->index; pkt.data= audio_out; pkt.flags |= AV_PKT_FLAG_KEY; pkt.pts = pkt.dts = 0; /* write the compressed frame in the media file */ if (av_interleaved_write_frame(encoderData->ocAud, &pkt) != 0) { fprintf(stderr, "Error while writing audio frame\n"); exit(1); } } } *********** - Encoding part: - *************** Other code is similar to the muxing.c example that comes with the builds. I know the functions used above are kind of outdated, but that is the best working source I could find from the internet. Can anyone kindly highlight how I could improve my code, or do I need to tweak ffplay somehow for better results? Thanks for your time, Best regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at hinespot.com Mon Dec 24 20:54:56 2012 From: michael at hinespot.com (Michael R. Hines) Date: Mon, 24 Dec 2012 14:54:56 -0500 Subject: [Libav-user] decoding a duplicated packet in another process Message-ID: <1356378896.2572.19.camel@chopin> Hi, My task is to send AVPackets over the network (to another process) that does not have access to the original video for transcoding purposes. To do this, I need to duplicate the packet data and the AVPacket struct, like this: Pseudocode (in a 2nd C program talking TCP/IP): 1. Allocate AVCodec with avcodec_find_decoder(mpeg2) 2. Allocate AVCodecContext with avcodec_alloc_context3() 3. Open the codec with avcodec_open2() 4. av_malloc() some space to get the duplicate packet data from network No problems so far.... (Note: there's no AVFormatContext or AVStream here because I want to copy the packet rather than read it from the original stream). Then, I proceed to read in a copy of the AVPacket structure from the network, along with the data portion of the packet that was pulled previously from the original video stream. (side_data_elems == 0, so I just ignored that part of the packet). This all works fine -- all the AVPacket values are there, the data is assigned to the AVPacket successfully. But, then I try to decode the packet, with avcodec_decode_video2(duplicated packet), and I get: [mpeg2video @ 0xa9f3420] mpeg_decode_postinit() failure I even ran GDB and found out that the failure comes from here: file libavcodec/mpeg12.c:1277 function static int mpeg_decode_postinit(AVCodecContext *avctx) line 1277: if ((s->width == 0) || (s->height == 0)) return -2; Ok, that makes sense - so the decoder is missing some information.... Which means I'm probably not performing steps #1, 2, 3 properly. Are there are additional parameters (like width and height) in the AVCodecContext or AVCodec structures that I'm supposed to change before opening the codec for decoding before the MPEG2 code can start doing its work properly? What am I missing? Thanks! - Michael R. Hines From michael at hinespot.com Mon Dec 24 21:12:12 2012 From: michael at hinespot.com (Michael R. Hines) Date: Mon, 24 Dec 2012 15:12:12 -0500 Subject: [Libav-user] decoding a duplicated packet in another process Message-ID: <1356379932.28898.1.camel@chopin> Hi, Looks like I answered my own question: I was duplicating the packets out of order as they came out of the AVStream on the other side of the network. So the decoder was not decoding the same sequence of packets that it expected. Thanks, - Michael R. Hines From michael at hinespot.com Mon Dec 24 21:20:42 2012 From: michael at hinespot.com (Michael R. Hines) Date: Mon, 24 Dec 2012 15:20:42 -0500 Subject: [Libav-user] segfault decoding a copied packet Message-ID: <1356380442.28898.8.camel@chopin> Hi all, So, this is related to a previous post: I've written a program that duplicates an AVPacket over the network. But, when it gets to the decoder on the other side (in another C program talking TCP/IP), I get this from my debugger: Program received signal SIGSEGV, Segmentation fault. avui_decode_frame (avctx=0x0, data=0x15f90, data_size=0x0, avpkt=0x180) at libavcodec/avuidec.c:114 114 a[2 * k ] = 0xFF - (transparent ? *srca++ : 0); (gdb) bt #0 avui_decode_frame (avctx=0x0, data=0x15f90, data_size=0x0, avpkt=0x180) at libavcodec/avuidec.c:114 #1 0x00015f90 in ?? () (gdb) The code up to this point was done with the following sequence of a events: 1. avcodec_find_decoder(mpeg2) 2. avcodec_alloc_context3() 3. avcodec_open2() 4. copy the AVPacket to duplicate AVPacket 5. av_malloc() some space to store the duplicate packet data from network 6. assigned the newly allocated memory to the duplicate AVPacket 7. read the packet data bytes from the network 8. avcodec_decode_video2(duplicated packet) Is av_malloc() not sufficient to duplicate the packet? Do I need to align the memory somehow before ? - Michael R. Hines From michael at hinespot.com Mon Dec 24 21:32:58 2012 From: michael at hinespot.com (Michael R. Hines) Date: Mon, 24 Dec 2012 15:32:58 -0500 Subject: [Libav-user] segfault decoding a copied packet Message-ID: <1356381178.28898.9.camel@chopin> Answered my own question again: av_new_packet() =) - Michael R. Hines From beyond702 at gmail.com Tue Dec 25 10:08:10 2012 From: beyond702 at gmail.com (Brian Chi) Date: Tue, 25 Dec 2012 17:08:10 +0800 Subject: [Libav-user] There is no picture in the output file while encoding with libx264 as codec. Message-ID: Hi~, I want to realize an application that firstly decode a multi-media file(such as test.mp4 file, video codec id is H264), get a video stream and an audio stream, then make some different in the audio stream, at last encode the video stream(use libx264) and audio stream into a result file(result.mp4). To promote the efficiency, i omitted the decode and encode of video stream, i get the video packet via function "av_read_frame", then output it directly into the result file via function "av_write_frame". But there is no picture in the output file, and the size of output file is fairly small. I tracked the ffmpeg code and found that in the function "av_write_frame->mov_write_packet->ff_mov_write_packet", it will call function "ff_avc_parse_nal_units" to obtain the size of nal unit, but the return value is very small(such as 208 bytes). I can't find where the problem is. Does anybody know that? I'm very appreciate it. -- Best Regards, Chi -------------- next part -------------- An HTML attachment was scrubbed... URL: From 34973832 at qq.com Tue Dec 25 13:39:19 2012 From: 34973832 at qq.com (=?ISO-8859-1?B?TXIuIFhpYW8=?=) Date: Tue, 25 Dec 2012 20:39:19 +0800 Subject: [Libav-user] ffserver, snprintf not us corrctly! Message-ID: hi, in ffserver.c, there is a error when usng snprintf. see the followed code: /* prepare http header */ q = c->buffer; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 OK\r\n"); // !!! error mime_type = c->stream->fmt->mime_type; if (!mime_type) mime_type = "application/x-octet-stream"; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Pragma: no-cache\r\n"); // !!! error /* for asf, we need extra headers */ if (!strcmp(c->stream->fmt->name,"asf_stream")) { /* Need to allocate a client id */ c->wmp_client_id = av_lfg_get(&random_state); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id); // !!! error } q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-Type: %s\r\n", mime_type); // !!! error q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); // !!! error !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!should be like this: /* prepare http header */ q = c->buffer; q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "HTTP/1.0 200 OK\r\n"); mime_type = c->stream->fmt->mime_type; if (!mime_type) mime_type = "application/x-octet-stream"; q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "Pragma: no-cache\r\n"); /* for asf, we need extra headers */ if (!strcmp(c->stream->fmt->name,"asf_stream")) { /* Need to allocate a client id */ c->wmp_client_id = av_lfg_get(&random_state); q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id); } q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "Content-Type: %s\r\n", mime_type); q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "\r\n"); -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexcohn at netvision.net.il Tue Dec 25 16:55:19 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Tue, 25 Dec 2012 17:55:19 +0200 Subject: [Libav-user] There is no picture in the output file while encoding with libx264 as codec. In-Reply-To: References: Message-ID: On Tue, Dec 25, 2012 at 11:08 AM, Brian Chi wrote: > I tracked the ffmpeg code and found that in the function > "av_write_frame->mov_write_packet->ff_mov_write_packet", it will call > function "ff_avc_parse_nal_units" to obtain the size of nal unit, but the > return value is very small(such as 208 bytes). It's very natural for the first NAL unit to be small. An h264 stream begins with configuration SPS/PPS untis that don't contain video data, but let the decoder initialization to work. Did you continue reading more video packets after the first one? Alex From cehoyos at ag.or.at Tue Dec 25 17:03:28 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Tue, 25 Dec 2012 16:03:28 +0000 (UTC) Subject: [Libav-user] ffserver, snprintf not us corrctly! References: Message-ID: Mr. Xiao <34973832 at ...> writes: > hi, in ffserver.c, there is a error when usng snprintf. Please send patches made with git format-patch or git send-email to ffmpeg-devel (git diff >patch.diff is also acceptable). Carl Eugen From beyond702 at gmail.com Wed Dec 26 05:35:21 2012 From: beyond702 at gmail.com (Brian Chi) Date: Wed, 26 Dec 2012 12:35:21 +0800 Subject: [Libav-user] There is no picture in the output file while encoding with libx264 as codec. In-Reply-To: References: Message-ID: Yes, I read all frames, most return value of function "ff_avc_parse_nal_units" is 0. i think maybe the problem is about NAL, will the NAL layer of H264 frame be detached in the function "av_read_frame". So in the "ff_avc_parse_nal_units", it can't find start code(0x000001), and discard the frame. Is that right? 2012/12/25 Alex Cohn > On Tue, Dec 25, 2012 at 11:08 AM, Brian Chi wrote: > > I tracked the ffmpeg code and found that in the function > > "av_write_frame->mov_write_packet->ff_mov_write_packet", it will call > > function "ff_avc_parse_nal_units" to obtain the size of nal unit, but the > > return value is very small(such as 208 bytes). > > It's very natural for the first NAL unit to be small. An h264 stream > begins with configuration SPS/PPS untis that don't contain video data, > but let the decoder initialization to work. Did you continue reading > more video packets after the first one? > > Alex > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > -- Best Regards, Chi -------------- next part -------------- An HTML attachment was scrubbed... URL: From nkipe at tatapowersed.com Wed Dec 26 06:52:14 2012 From: nkipe at tatapowersed.com (Navin) Date: Wed, 26 Dec 2012 11:22:14 +0530 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: References: <50CEF1CC.50308@tatapowersed.com> <50D7E781.6080409@tatapowersed.com> Message-ID: <50DA908E.6080504@tatapowersed.com> Okay, so basically this is how the code goes. It's from the ffmpeg tutorials itself. Could the code be wrong because I used sws_getContext? g_metadata is a struct I constructed, for holding some properties of the video. AVFormatContext* g_pFormatCtx = NULL; AVCodecContext* g_g_pCodecCtx = NULL; int g_videoStream; int g_numBytes; AVCodec* g_pCodec = NULL; AVFrame* g_pFrame = NULL; AVFrame* g_pFrameRGB = NULL; AVDictionary* g_optionsDict = NULL; struct SwsContext* g_sws_ctx = NULL; av_register_all(); if (avformat_open_input(&g_pFormatCtx, g_metadata->videoLocation.c_str(), NULL, NULL) != 0) { freeVideoData(); return false; } if (avformat_find_stream_info(g_pFormatCtx, NULL) < 0) { freeVideoData(); return false; } g_videoStream = -1; for(unsigned int i = 0; i < g_pFormatCtx->nb_streams; i++) { if (g_pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { g_videoStream=i; break; //breaks out of for loop } }//for if (g_videoStream == -1) return false; g_memoryBuffer->size = unsigned int(g_metadata->WIDTH * g_metadata->HEIGHT * sizeof(RGBPixel));//encapsulating the calculation of memory size g_pCodec = avcodec_find_decoder(g_g_pCodecCtx->codec_id); if (NULL == g_pCodec) return false; if (avcodec_open2(g_g_pCodecCtx, g_pCodec, &g_optionsDict) < 0) return false; g_pFrame = avcodec_alloc_frame(); if (NULL == g_pFrame) return false; g_pFrameRGB = avcodec_alloc_frame(); if (NULL == g_pFrameRGB) return false; uint8_t* pbuffer = NULL; g_numBytes = avpicture_get_size(PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); pbuffer = (uint8_t *) av_malloc(g_numBytes * sizeof(uint8_t));//TODO: exception handling may be required for allocs g_sws_ctx = sws_getContext(g_metadata->WIDTH, g_metadata->HEIGHT, g_g_pCodecCtx->pix_fmt, \ g_metadata->WIDTH, g_metadata->HEIGHT, PIX_FMT_RGB24, SWS_BILINEAR, NULL, NULL, NULL ); avpicture_fill((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); av_free(pbuffer); Navin On 12/24/2012 4:05 PM, Alex Cohn wrote: > On Mon, Dec 24, 2012 at 7:26 AM, Navin wrote: >> Actually I'm giving avipicture_fill a value. I didn't show that bit of the code. >> >> g_pFrameRGB = avcodec_alloc_frame_proc(); > Yes, this should be correct. > >> But it's strange that purify is showing an error while reading from data[0][0]. > Actually, after your call to avpicture_fill_proc(), data[0] is > pointing to pbuffer[0]. You didn't disclose how you initialized > pbuffer, so it's impossible to tell why Purify is unhappy with this > address. > > By the way, I don't understand the rationale of allocating another > chunk of memory, pAreaInMemory. Whatever you do with these bytes, why > don't you use pbuffer directly? > > BR, > Alex > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > From alexcohn at netvision.net.il Wed Dec 26 08:33:46 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Wed, 26 Dec 2012 09:33:46 +0200 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: <50DA908E.6080504@tatapowersed.com> References: <50CEF1CC.50308@tatapowersed.com> <50D7E781.6080409@tatapowersed.com> <50DA908E.6080504@tatapowersed.com> Message-ID: On Wed, Dec 26, 2012 at 7:52 AM, Navin wrote: > avpicture_fill((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); .. so far so good > av_free(pbuffer); oops, you still expect g_pFrameRGB->data[0] to be a valid array. But you have released this memory! BR, Alex From michael at hinespot.com Wed Dec 26 11:15:36 2012 From: michael at hinespot.com (Michael R. Hines) Date: Wed, 26 Dec 2012 05:15:36 -0500 Subject: [Libav-user] keyframe not a keyframe? In-Reply-To: <50DA908E.6080504@tatapowersed.com> References: <50CEF1CC.50308@tatapowersed.com> <50D7E781.6080409@tatapowersed.com> <50DA908E.6080504@tatapowersed.com> Message-ID: <1356516936.28898.16.camel@chopin> Hi, 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: The following statement: printf("packet flags: %d picture type: %c\n", inPacket.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_PKT_FLAG_KEY. Is this behavior correct? (I'm decoding MPEG2 video). Thanks, - Michael From santhosh.kumar.bachu at gmail.com Wed Dec 26 11:34:26 2012 From: santhosh.kumar.bachu at gmail.com (Santhosh Kumar) Date: Wed, 26 Dec 2012 16:04:26 +0530 Subject: [Libav-user] test mail Message-ID: -- Santhosh -- Symbol of Smile:) -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexcohn at netvision.net.il Wed Dec 26 11:39:51 2012 From: alexcohn at netvision.net.il (Alex Cohn) Date: Wed, 26 Dec 2012 12:39:51 +0200 Subject: [Libav-user] There is no picture in the output file while encoding with libx264 as codec. In-Reply-To: References: Message-ID: On Wed, Dec 26, 2012 at 6:35 AM, Brian Chi wrote: > Yes, I read all frames, most return value of function "ff_avc_parse_nal_units" is 0. > i think maybe the problem is about NAL, will the NAL layer of H264 frame be detached in the function "av_read_frame". > So in the "ff_avc_parse_nal_units", it can't find start code(0x000001), and discard the frame. Packets in mp4 are not stored in annex B format, you will never see 0x000001 start codes there. See http://msdn.microsoft.com/en-us/library/windows/desktop/dd757808(v=vs.85).aspx From nkipe at tatapowersed.com Wed Dec 26 12:39:24 2012 From: nkipe at tatapowersed.com (Navin) Date: Wed, 26 Dec 2012 17:09:24 +0530 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: References: <50CEF1CC.50308@tatapowersed.com> <50D7E781.6080409@tatapowersed.com> <50DA908E.6080504@tatapowersed.com> Message-ID: <50DAE1EC.8000707@tatapowersed.com> Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!sooooo much! That was the problem. Solved now. Navin On 12/26/2012 1:03 PM, Alex Cohn wrote: > On Wed, Dec 26, 2012 at 7:52 AM, Navin wrote: >> avpicture_fill((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); > .. so far so good >> av_free(pbuffer); > oops, you still expect g_pFrameRGB->data[0] to be a valid array. But > you have released this memory! > > BR, > Alex > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > From rjvbertin at gmail.com Wed Dec 26 13:50:44 2012 From: rjvbertin at gmail.com (=?iso-8859-1?Q?=22Ren=E9_J=2EV=2E_Bertin=22?=) Date: Wed, 26 Dec 2012 13:50:44 +0100 Subject: [Libav-user] Array bounds error while reading from ffmpeg data array using Purify In-Reply-To: <50DA908E.6080504@tatapowersed.com> References: <50CEF1CC.50308@tatapowersed.com> <50D7E781.6080409@tatapowersed.com> <50DA908E.6080504@tatapowersed.com> Message-ID: On Dec 26, 2012, at 06:52, Navin wrote: > g_pFrameRGB = avcodec_alloc_frame(); > if (NULL == g_pFrameRGB) return false; > > uint8_t* pbuffer = NULL; > g_numBytes = avpicture_get_size(PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); > pbuffer = (uint8_t *) av_malloc(g_numBytes * sizeof(uint8_t));//TODO: exception handling may be required for allocs > > g_sws_ctx = sws_getContext(g_metadata->WIDTH, g_metadata->HEIGHT, g_g_pCodecCtx->pix_fmt, \ > g_metadata->WIDTH, g_metadata->HEIGHT, PIX_FMT_RGB24, SWS_BILINEAR, NULL, NULL, NULL ); > > avpicture_fill((AVPicture *) g_pFrameRGB, pbuffer, PIX_FMT_RGB24, g_metadata->WIDTH, g_metadata->HEIGHT); > av_free(pbuffer); > > > Navin >> oops, you still expect g_pFrameRGB->data[0] to be a valid array. But >> you have released this memory! > Oh, adorable, the sort of mess-up that's so easy to make and hard to trace. I cannot help but remark that avpicture_fill receives all the information required to allocate the working memory itself, making it more 'logical' to deallocate said memory in a subsequent call to a matching deconstructor function (e.g. avcodec_free_frame). Is there a reason for not having implemented such a default case ... or is it indeed possible to pass NULL as the second argument to avpicture_fill to have it do the allocation? R. From beyond702 at gmail.com Thu Dec 27 04:23:20 2012 From: beyond702 at gmail.com (Brian Chi) Date: Thu, 27 Dec 2012 11:23:20 +0800 Subject: [Libav-user] There is no picture in the output file while encoding with libx264 as codec. In-Reply-To: References: Message-ID: I see, but the function "av_write_frame->mov_write_packet->ff_mov_write_packet->ff_avc_parse_nal_units->ff_avc_find_startcode" find the start code 0x000001, how can i resolve this problem to make it works? The first 4 bytes in the AVPacket is the size of this NALU, should i replace the first 4 bytes with 0x000001 or 0x00000001? Is that ok? Thanks a lot for your help. 2012/12/26 Alex Cohn > On Wed, Dec 26, 2012 at 6:35 AM, Brian Chi wrote: > > Yes, I read all frames, most return value of function > "ff_avc_parse_nal_units" is 0. > > i think maybe the problem is about NAL, will the NAL layer of H264 frame > be detached in the function "av_read_frame". > > So in the "ff_avc_parse_nal_units", it can't find start code(0x000001), > and discard the frame. > > Packets in mp4 are not stored in annex B format, you will never see > 0x000001 start codes there. See > > http://msdn.microsoft.com/en-us/library/windows/desktop/dd757808(v=vs.85).aspx > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user > -- Best Regards, Chi -------------- next part -------------- An HTML attachment was scrubbed... URL: From eng.m.behery at live.com Thu Dec 27 15:55:13 2012 From: eng.m.behery at live.com (mustafa elbehery) Date: Thu, 27 Dec 2012 16:55:13 +0200 Subject: [Libav-user] =?windows-1256?q?Help_to_convert_MP3_to_WMA_=28_16k_?= =?windows-1256?q?bit=2C_22k_Hz_=29=FE?= Message-ID: Dear sir, First of all I have to show my great respect for all the developers of "FFMPEG". I'm sending this e-mail to you specifically to help me solve my problem.I'm developing a JAVA module which converting from MP3 Format to many other formats, and I used (JAVE http://www.sauronsoftware.it/projects/jave/index.php), open src Java lib based on "FFMPEG", and I faced a problem in converting to "WMA (16k bit, 22k Hz) " format. I tried even the latest FFMPEG dist. which contains {wmalossless, wmapro, wmav1, wmav2, wmavoice} codecs, but unfortunately they only of them who can ENCODE to WMA are {wmav1, wmav2}, and they are not accepting my encoding parameters. I'm really confused and do not know what to do, the encoding is working fine from MP3 to WMA with (64k bit, 22k Hz) , but when I change to (16 k bit), it always broken.I'm waiting for your response because I really spent two working days without a result, I hope you can understand my situation, Looking forward to hear from you soon, Reagrds. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Thu Dec 27 23:10:41 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 27 Dec 2012 22:10:41 +0000 (UTC) Subject: [Libav-user] =?utf-8?q?Help_to_convert_MP3_to_WMA_=28_16k_bit=2C_?= =?utf-8?b?MjJrIEh6ICnigI8=?= References: Message-ID: mustafa elbehery writes: > I faced a problem in converting to "WMA (16k bit, 22k Hz)" format. Do you have a 16k wma sample? Carl Eugen From eng.m.behery at live.com Fri Dec 28 10:24:46 2012 From: eng.m.behery at live.com (mustafa elbehery) Date: Fri, 28 Dec 2012 11:24:46 +0200 Subject: [Libav-user] =?windows-1256?q?Help_to_convert_MP3_to_WMA_=28_16k_?= =?windows-1256?q?bit=2C_22k_Hz_=29=FE?= In-Reply-To: References: , Message-ID: yes I do. > To: libav-user at ffmpeg.org > From: cehoyos at ag.or.at > Date: Thu, 27 Dec 2012 22:10:41 +0000 > Subject: Re: [Libav-user] Help to convert MP3 to WMA ( 16k bit, 22k Hz )? > > mustafa elbehery writes: > > > I faced a problem in converting to "WMA (16k bit, 22k Hz)" format. > > Do you have a 16k wma sample? > > Carl Eugen > > _______________________________________________ > Libav-user mailing list > Libav-user at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/libav-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Fri Dec 28 12:00:41 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 28 Dec 2012 11:00:41 +0000 (UTC) Subject: [Libav-user] =?utf-8?q?Help_to_convert_MP3_to_WMA_=28_16k_bit=2C_?= =?utf-8?b?MjJrIEh6ICnigI8=?= References: , Message-ID: mustafa elbehery writes: ?> > > I faced a problem in converting to "WMA (16k bit, 22k Hz)" format. > > > > Do you have a 16k wma sample? > > yes I do.? Then please either post ffmpeg -i yoursample output or provide the file. Please do not top-post here and please fix your mailer to use "text-only", Carl Eugen From michael at hinespot.com Fri Dec 28 19:08:51 2012 From: michael at hinespot.com (Michael R. Hines) Date: Fri, 28 Dec 2012 13:08:51 -0500 Subject: [Libav-user] keyframe not a keyframe? In-Reply-To: <1356516936.28898.16.camel@chopin> References: <50CEF1CC.50308@tatapowersed.com> <50D7E781.6080409@tatapowersed.com> <50DA908E.6080504@tatapowersed.com> <1356516936.28898.16.camel@chopin> Message-ID: <1356718131.22135.0.camel@salieri> I got a response from the ffmpeg bugtracker: https://ffmpeg.org/trac/ffmpeg/ticket/2074 I suspect your are missing the codec delay. The video frame you get out usually isn't based on the packet you just sent in at all. This is especially true with multithreaded decoding, but even without it's not generally possible due to how B-frames work. And, indeed I print out the ->pict_type "picture type" 3 frames later, there is an I-frame that pops up a few frames later with a "delay" of sorts exactly a 3 frames later. In my case, I have a quad-core computer, so perhaps there's a thread being allocated for each core on my computer to do the encoding. - Michael On Wed, 2012-12-26 at 05:15 -0500, Michael R. Hines wrote: > Hi, > > 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: > > The following statement: > > printf("packet flags: %d picture type: %c\n", inPacket.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_PKT_FLAG_KEY. > > Is this behavior correct? (I'm decoding MPEG2 video). > > Thanks, > > - Michael > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Mohamed.Salim at desay-svautomotive.com Fri Dec 28 04:13:30 2012 From: Mohamed.Salim at desay-svautomotive.com (Salim, Mohamed) Date: Fri, 28 Dec 2012 11:13:30 +0800 Subject: [Libav-user] Incorrect frame rate Message-ID: <76C45F99342CDC46B7CE253C2343BDA11BA979@hzhe007a.v01.net> HI, I am using libav - 0.6. I use AVCodecContext to read the framerate and bitrate of the video / audio stream. However, I consistently get wrong results on frame rate for wmv / asf streams. The value is always 1000. Is there a correction available in latest releases of libav? Also in some cases (.mov, .mkv), bit rate is shown to be 0. Is it also corrected in newer releases. Kindest Regards, Salim -------------- next part -------------- An HTML attachment was scrubbed... URL: From savanevery at gmail.com Sat Dec 29 10:16:23 2012 From: savanevery at gmail.com (Shawn Van Every) Date: Sat, 29 Dec 2012 04:16:23 -0500 Subject: [Libav-user] Encoding and writing to a file with libavformat and libavcodec Message-ID: Hi all, Just getting started with the libraries and in need of a bit of help. I have been building up a sample based off of the decoding_encoding example along with some sample code using AVFormat. Right now, I am running into issues which I am having a hard time finding the cause of. Here is the error along with the backtrace: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000090 0x00000001000870b5 in ff_mov_write_packet () (gdb) bt #0 0x00000001000870b5 in ff_mov_write_packet () #1 0x00007fff8e58cb28 in szone_malloc_should_clear () #2 0x00007fff8e57f71a in malloc_zone_memalign () #3 0x00007fff8e57ff4e in posix_memalign () #4 0x000000010000f9b5 in av_strdup () Full source is below. Thanks for any help. Best, shawn -- #include #include #include #include #include #include #include #include #undef exit #define STREAM_DURATION 5.0 /* 5 seconds stream duration */ #define STREAM_FRAME_RATE 25 /* 25 images/s */ #define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE)) #define STREAM_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */ static int sws_flags = SWS_BICUBIC; int main(int argc, char **argv) { // Output file const char *outputfile; // Struct to hold the output format details, audio codec, video codec, extension // http://ffmpeg.org/doxygen/trunk/structAVOutputFormat.html AVOutputFormat *avOutputFormat; // Was *fmt // http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html AVFormatContext *avFormatContext; // was *oc // Individual AVStreams for audio and video // http://ffmpeg.org/doxygen/trunk/structAVStream.html AVStream *video_avstream; // was *video_st and *st // Audio and Video Timestamps (presentation time stamp) double video_pts; int codec_id = AV_CODEC_ID_H264; AVCodec *codec; AVCodecContext *c= NULL; int i, ret, x, y, got_output; int write_ret; //FILE *f; AVFrame *frame; AVPacket pkt; uint8_t endcode[] = { 0, 0, 1, 0xb7 }; printf("Encode video file\n"); /* register all the codecs */ //avcodec_register_all(); // Intialize libavcodec - register all codecs and formats?????????? av_register_all(); // Set inpput filename and output filename outputfile = "outtestmov.mp4"; // auto detect the output format from the name. default is mpeg. avOutputFormat = av_guess_format(NULL, outputfile, NULL); if (!avOutputFormat) { printf("Could not deduce output format from file extension: using MPEG.\n"); avOutputFormat = av_guess_format("mpeg", NULL, NULL); } if (!avOutputFormat) { fprintf(stderr, "Could not find suitable output format\n"); exit(1); } avOutputFormat->video_codec = codec_id; /// allocate the output media context, avFormatContext avFormatContext = avformat_alloc_context(); if (!avFormatContext) { fprintf(stderr, "Memory error\n"); exit(1); } // Set the output format of the newly allocated avFormatContext to our avOutputFormat avFormatContext->oformat = avOutputFormat; // Set the output filename to the outputfile snprintf(avFormatContext->filename, sizeof(avFormatContext->filename), "%s", outputfile); /* find the mpeg1 video encoder */ //codec = avcodec_find_encoder(codec_id); codec = avcodec_find_encoder(avOutputFormat->video_codec); if (!codec) { fprintf(stderr, "Codec not found\n"); exit(1); } // add the video stream using the default format codec and initialize the codecs video_avstream = avformat_new_stream(avFormatContext, codec); if (!video_avstream) { fprintf(stderr, "Could not alloc stream\n"); exit(1); } if (video_avstream->codec == NULL) { fprintf(stderr, "AVStream codec is NULL\n"); exit(1); } //c = avcodec_alloc_context3(codec); c = video_avstream->codec; //c->codec_id = avOutputFormat->video_codec; if (!c) { fprintf(stderr, "Could not allocate video codec context\n"); exit(1); } /* put sample parameters */ c->bit_rate = 400000; /* resolution must be a multiple of two */ c->width = 352; c->height = 288; /* frames per second */ c->time_base= (AVRational){1,25}; c->gop_size = 10; /* emit one intra frame every ten frames */ c->max_b_frames=1; c->pix_fmt = AV_PIX_FMT_YUV420P; if(codec_id == AV_CODEC_ID_H264) av_opt_set(c->priv_data, "preset", "slow", 0); /* open it */ if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open codec\n"); exit(1); } //video_avstream->codec = c; frame = avcodec_alloc_frame(); if (!frame) { fprintf(stderr, "Could not allocate video frame\n"); exit(1); } frame->format = c->pix_fmt; frame->width = c->width; frame->height = c->height; /* the image can be allocated by any means and av_image_alloc() is * just the most convenient way if av_malloc() is to be used */ ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height, c->pix_fmt, 32); if (ret < 0) { fprintf(stderr, "Could not allocate raw picture buffer\n"); exit(1); } // some formats want stream headers to be separate if(avFormatContext->oformat->flags & AVFMT_GLOBALHEADER) c->flags |= CODEC_FLAG_GLOBAL_HEADER; avformat_write_header(avFormatContext, NULL); /* encode 1 second of video */ for(i=0;i<25;i++) { av_init_packet(&pkt); pkt.data = NULL; // packet data will be allocated by the encoder pkt.size = 0; fflush(stdout); /* prepare a dummy image */ /* Y */ for(y=0;yheight;y++) { for(x=0;xwidth;x++) { frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3; } } /* Cb and Cr */ for(y=0;yheight/2;y++) { for(x=0;xwidth/2;x++) { frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2; frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5; } } frame->pts = i; /* encode the image */ ret = avcodec_encode_video2(c, &pkt, frame, &got_output); if (ret < 0) { fprintf(stderr, "Error encoding frame\n"); exit(1); } if (got_output) { /* write the compressed frame in the media file */ write_ret = av_write_frame(avFormatContext, &pkt); if (write_ret < 0) { fprintf(stderr, "Error writing frame\n"); exit(1); } av_free_packet(&pkt); } else { printf("got_output false: %d", i); } } /* write the trailer, if any. the trailer must be written * before you close the CodecContexts open when you wrote the * header; otherwise write_trailer may try to use memory that * was freed on av_codec_close() */ av_write_trailer(avFormatContext); avcodec_close(c); av_free(c); av_freep(&frame->data[0]); avcodec_free_frame(&frame); /* free the streams */ for(i = 0; i < avFormatContext->nb_streams; i++) { av_freep(&avFormatContext->streams[i]->codec); av_freep(&avFormatContext->streams[i]); } if (!(avOutputFormat->flags & AVFMT_NOFILE)) { /* close the output file */ avio_close(avFormatContext->pb); } /* free the stream */ av_free(avFormatContext); printf("\n"); return 0; } -------------- next part -------------- An HTML attachment was scrubbed... URL: From cehoyos at ag.or.at Sat Dec 29 12:17:23 2012 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sat, 29 Dec 2012 11:17:23 +0000 (UTC) Subject: [Libav-user] Encoding and writing to a file with libavformat and libavcodec References: Message-ID: Shawn Van Every writes: > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000090 > 0x00000001000870b5 in ff_mov_write_packet () > (gdb) bt > #0 ?0x00000001000870b5 in ff_mov_write_packet () > #1 ?0x00007fff8e58cb28 in szone_malloc_should_clear () > #2 ?0x00007fff8e57f71a in malloc_zone_memalign () > #3 ?0x00007fff8e57ff4e in posix_memalign () > #4 ?0x000000010000f9b5 in av_strdup () The backtrace does not look very helpful, either use static linking or use --disable-stripping. Carl Eugen From savanevery at gmail.com Sat Dec 29 16:50:38 2012 From: savanevery at gmail.com (Shawn Van Every) Date: Sat, 29 Dec 2012 10:50:38 -0500 Subject: [Libav-user] Encoding and writing to a file with libavformat and libavcodec In-Reply-To: References: Message-ID: On Sat, Dec 29, 2012 at 6:17 AM, Carl Eugen Hoyos wrote: > Shawn Van Every writes: > > > Program received signal EXC_BAD_ACCESS, Could not access memory. > > Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000090 > > 0x00000001000870b5 in ff_mov_write_packet () > > (gdb) bt > > #0 0x00000001000870b5 in ff_mov_write_packet () > > #1 0x00007fff8e58cb28 in szone_malloc_should_clear () > > #2 0x00007fff8e57f71a in malloc_zone_memalign () > > #3 0x00007fff8e57ff4e in posix_memalign () > > #4 0x000000010000f9b5 in av_strdup () > > The backtrace does not look very helpful, > either use static linking or use --disable-stripping. > > Carl Eugen > Thanks Carl, here is an updated backtrace: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000090 0x0000000100090095 in mov_write_header (s=0x7fff5fbff410) at movenc.c:3499 3499 if (!s->pb->seekable && It looks like I either haven't instantiated AVFormatContext (s in movenc.c:3499) or AVIOContext (s->pb in movenc.c 3499) correctly. Unfortunately, I haven't seen AVIOContext used in any of the examples. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From savanevery at gmail.com Sat Dec 29 20:29:44 2012 From: savanevery at gmail.com (Shawn Van Every) Date: Sat, 29 Dec 2012 14:29:44 -0500 Subject: [Libav-user] Encoding and writing to a file with libavformat and libavcodec In-Reply-To: References: Message-ID: On Sat, Dec 29, 2012 at 10:50 AM, Shawn Van Every wrote: > > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000090 > 0x0000000100090095 in mov_write_header (s=0x7fff5fbff410) at movenc.c:3499 > 3499 if (!s->pb->seekable && > > It looks like I either haven't instantiated AVFormatContext (s in > movenc.c:3499) or AVIOContext (s->pb in movenc.c 3499) correctly. > Unfortunately, I haven't seen AVIOContext used in any of the examples. > > Thanks > Ahh.. I missed actually opening the output file. Doing the following fixes that error: /* open the output file, if needed */ if (!(avOutputFormat->flags & AVFMT_NOFILE)) { if (avio_open(&avFormatContext->pb, outputfile, AVIO_FLAG_WRITE) < 0) { fprintf(stderr, "Could not open '%s'\n", outputfile); return 1; } } Now I have this: mine(1228,0x7fff70ca4180) malloc: *** error for object 0x10180f800: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Program received signal SIGABRT, Aborted. 0x00007fff83cab212 in __pthread_kill () (gdb) bt #0 0x00007fff83cab212 in __pthread_kill () #1 0x00007fff8332bb34 in pthread_kill () #2 0x00007fff8336fdfa in abort () #3 0x00007fff83343989 in free () #4 0x000000010000f6dc in av_freep (arg=0x101111628) at mem.c:185 #5 0x00007fff855ba7e1 in start () Here is the updated full code if anyone feels like having a look: #include #include #include #include #include #include #include #include #undef exit #define STREAM_DURATION 5.0 /* 5 seconds stream duration */ #define STREAM_FRAME_RATE 25 /* 25 images/s */ #define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE)) #define STREAM_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */ static int sws_flags = SWS_BICUBIC; int main(int argc, char **argv) { // Output file const char *outputfile; // Struct to hold the output format details, audio codec, video codec, extension // http://ffmpeg.org/doxygen/trunk/structAVOutputFormat.html AVOutputFormat *avOutputFormat; // Was *fmt // http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html AVFormatContext *avFormatContext; // was *oc // Individual AVStreams for audio and video // http://ffmpeg.org/doxygen/trunk/structAVStream.html AVStream *video_avstream; // was *video_st and *st // Audio and Video Timestamps (presentation time stamp) double audio_pts, video_pts; /////////////////// int codec_id = AV_CODEC_ID_H264; AVCodec *codec; AVCodecContext *c= NULL; int i, ret, x, y, got_output; int write_ret; //FILE *f; AVFrame *frame; AVPacket pkt; //uint8_t endcode[] = { 0, 0, 1, 0xb7 }; printf("Encode video file\n"); /* register all the codecs */ //avcodec_register_all(); /////// // Intialize libavcodec - register all codecs and formats?????????? av_register_all(); // Set inpput filename and output filename outputfile = "outtestmov.mp4"; // auto detect the output format from the name. default is mpeg. avOutputFormat = av_guess_format(NULL, outputfile, NULL); if (!avOutputFormat) { printf("Could not deduce output format from file extension: using MPEG.\n"); avOutputFormat = av_guess_format("mpeg", NULL, NULL); } if (!avOutputFormat) { fprintf(stderr, "Could not find suitable output format\n"); exit(1); } fprintf(stdout,"Format Name: %s\n",avOutputFormat->name); fprintf(stdout,"Format Video Codec: %d\n",avOutputFormat->video_codec); avOutputFormat->video_codec = codec_id; fprintf(stdout,"Format Video Codec: %d\n",avOutputFormat->video_codec); /// allocate the output media context, avFormatContext avFormatContext = avformat_alloc_context(); if (!avFormatContext) { fprintf(stderr, "Memory error\n"); exit(1); } // Set the output format of the newly allocated avFormatContext to our avOutputFormat avFormatContext->oformat = avOutputFormat; // Set the output filename to the outputfile snprintf(avFormatContext->filename, sizeof(avFormatContext->filename), "%s", outputfile); /* find the mpeg1 video encoder */ //codec = avcodec_find_encoder(codec_id); codec = avcodec_find_encoder(avOutputFormat->video_codec); if (!codec) { fprintf(stderr, "Codec not found\n"); exit(1); } // add the video stream using the default format codec and initialize the codecs video_avstream = avformat_new_stream(avFormatContext, codec); if (!video_avstream) { fprintf(stderr, "Could not alloc stream\n"); exit(1); } if (video_avstream->codec == NULL) { fprintf(stderr, "AVStream codec is NULL\n"); exit(1); } //c = avcodec_alloc_context3(codec); c = video_avstream->codec; //c->codec_id = avOutputFormat->video_codec; if (!c) { fprintf(stderr, "Could not allocate video codec context\n"); exit(1); } /* put sample parameters */ c->bit_rate = 400000; /* resolution must be a multiple of two */ c->width = 352; c->height = 288; /* frames per second */ c->time_base= (AVRational){1,25}; c->gop_size = 10; /* emit one intra frame every ten frames */ c->max_b_frames=1; c->pix_fmt = AV_PIX_FMT_YUV420P; if(codec_id == AV_CODEC_ID_H264) av_opt_set(c->priv_data, "preset", "slow", 0); /* open it */ if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open codec\n"); exit(1); } /* f = fopen(filename, "wb"); if (!f) { fprintf(stderr, "Could not open %s\n", filename); exit(1); } */ //video_avstream->codec = c; ////////////////////////////////// frame = avcodec_alloc_frame(); if (!frame) { fprintf(stderr, "Could not allocate video frame\n"); exit(1); } frame->format = c->pix_fmt; frame->width = c->width; frame->height = c->height; /* the image can be allocated by any means and av_image_alloc() is * just the most convenient way if av_malloc() is to be used */ ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height, c->pix_fmt, 32); if (ret < 0) { fprintf(stderr, "Could not allocate raw picture buffer\n"); exit(1); } /* open the output file, if needed */ if (!(avOutputFormat->flags & AVFMT_NOFILE)) { if (avio_open(&avFormatContext->pb, outputfile, AVIO_FLAG_WRITE) < 0) { fprintf(stderr, "Could not open '%s'\n", outputfile); return 1; } } // some formats want stream headers to be separate if(avFormatContext->oformat->flags & AVFMT_GLOBALHEADER) c->flags |= CODEC_FLAG_GLOBAL_HEADER; avformat_write_header(avFormatContext, NULL); /* encode 1 second of video */ for(i=0;i<25;i++) { av_init_packet(&pkt); pkt.data = NULL; // packet data will be allocated by the encoder pkt.size = 0; fflush(stdout); /* prepare a dummy image */ /* Y */ for(y=0;yheight;y++) { for(x=0;xwidth;x++) { frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3; } } /* Cb and Cr */ for(y=0;yheight/2;y++) { for(x=0;xwidth/2;x++) { frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2; frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5; } } frame->pts = i; /* encode the image */ ret = avcodec_encode_video2(c, &pkt, frame, &got_output); if (ret < 0) { fprintf(stderr, "Error encoding frame\n"); exit(1); } if (got_output) { /* if (c->coded_frame->pts != AV_NOPTS_VALUE) { pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_avstream->time_base); } else { printf("pkt.pts AV_NOPTS_VALUE"); } pkt.pts = i; printf("pkt.pts:%5d\n",pkt.pts); printf("Write frame %3d (size=%5d)\n", i, pkt.size); */ /* write the compressed frame in the media file */ write_ret = av_write_frame(avFormatContext, &pkt); if (write_ret < 0) { fprintf(stderr, "Error writing frame\n"); exit(1); } // fwrite(pkt.data, 1, pkt.size, f); av_free_packet(&pkt); } else { printf("got_output false: %d", i); } } /* get the delayed frames */ /* for (got_output = 1; got_output; i++) { fflush(stdout); ret = avcodec_encode_video2(c, &pkt, NULL, &got_output); if (ret < 0) { fprintf(stderr, "Error encoding frame\n"); exit(1); } if (got_output) { printf("Write frame %3d (size=%5d)\n", i, pkt.size); // fwrite(pkt.data, 1, pkt.size, f); // write the compressed frame in the media file // ret = av_interleaved_write_frame(avFormatContext, &pkt); av_free_packet(&pkt); } } */ /* add sequence end code to have a real mpeg file */ //fwrite(endcode, 1, sizeof(endcode), f); //fclose(f); /* write the trailer, if any. the trailer must be written * before you close the CodecContexts open when you wrote the * header; otherwise write_trailer may try to use memory that * was freed on av_codec_close() */ //av_write_trailer(avFormatContext); avcodec_close(c); av_free(c); av_freep(&frame->data[0]); avcodec_free_frame(&frame); /* free the streams */ for(i = 0; i < avFormatContext->nb_streams; i++) { av_freep(&avFormatContext->streams[i]->codec); av_freep(&avFormatContext->streams[i]); } if (!(avOutputFormat->flags & AVFMT_NOFILE)) { /* close the output file */ avio_close(avFormatContext->pb); } /* free the stream */ av_free(avFormatContext); printf("\n"); return 0; } -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekar01 at gmail.com Mon Dec 31 08:02:21 2012 From: chandrashekar01 at gmail.com (chandrashekar reddy) Date: Mon, 31 Dec 2012 12:32:21 +0530 Subject: [Libav-user] Regarding integrating Media Parcer of ffmepg: Message-ID: Hi All, I would like to use ffmpeg media parcers like ( AVI, Asf,MP4 etc..) in my application.Can u sujject me what is the procedure I should fallow to integarte ffmpeg media parcers in application. Regards, Chan -------------- next part -------------- An HTML attachment was scrubbed... URL: From funkyfactory at gmx.at Sat Dec 29 12:54:36 2012 From: funkyfactory at gmx.at (Funky Factory Development) Date: Sat, 29 Dec 2012 12:54:36 +0100 Subject: [Libav-user] AAC decoding problems Message-ID: <50DED9FC.8070208@gmx.at> Hi, I'm having some issues with AAC decoding with recent version of ffmpeg: I'm using this code to decode AAC Frames (from a stream). I had some troubles with the decoding - everything runs fine but the after a few seconds playing the decoded buffer (m_avAACFrame->data) only contains zeros. int gotframe=0; if(!m_avAACFrame) m_avAACFrame=avcodec_alloc_frame(); else avcodec_get_frame_defaults(m_avAACFrame); int buff=avcodec_decode_audio4(pAACCodecCtx, m_avAACFrame, &gotframe, &avAACpkt); if (gotframe==0 || buff<0) { *outputsize=0; return; } *outputsize=av_samples_get_buffer_size(NULL, 2, m_avAACFrame->nb_samples, pAACCodecCtx->sample_fmt, 1); memcpy(outbuffer,*(byte**)&m_avAACFrame->data,*outputsize); So i switched to the latest version of ffmpeg (Zeranoe FFmpeg for Windows) and now i have the problem that the output sample format is always AV_SAMPLE_FMT_FLT instead of AV_SAMPLE_FMT_S16 ? pAACCodecCtx->bit_rate = 64000; pAACCodecCtx->sample_rate = 44100; pAACCodecCtx->channels = 2; pAACCodecCtx->channel_layout = 3; pAACCodecCtx->sample_fmt = AV_SAMPLE_FMT_S16; //pAACCodecCtx->bit_rate = 64000; //pAACCodecCtx->sample_rate = fmtp[11]; //pAACCodecCtx->channels = fmtp[7]; //c->sample_fmt = AV_SAMPLE_FMT_DBL; //c->profile = FF_PROFILE_AAC_SSR; /* open it */ if (avcodec_open2(pAACCodecCtx, AACCodec,NULL) < 0) { return false; } Is AAC not properly supported on ffmpeg ? Thanks for your help