Hi All, It is several weeks that I try to encode a live TV feed (from a V4L2 capture device) to an MPEG2 file using the avformat library without success. I always get 'buffer underrun' errors and core dumps from glibc due to a double free or corruption (caused by avformat/avcodec since the code without the compression calls works perfectly). The resulting file, when playable, is always out of sync, stuttering and all weird things that could happen to a video file. Since it is a live source I can't feed more data than what I receive. I know that the video and audio timings may not be exactly to the microsecond, but why avformat is so concerned about this buffer ? Is there a way to disable this damned buffer ? I searched for some tutorials, example or even for a spell to cast in order to get this thing working, but without success. I found thousands of site with the avformat/avcodec source code nicely formatted but without any useful information. It seems that avformat users are more concerned about playing a file rather than creating one (should I assume that avformat is useful for playing only ?). I just updated the ffmpeg library: bad move, now the frame rate fields are missing, how do I set the frame rate ? Geez, these guys must hate documentation !! The library version should be: 0.4.9-0.lvn.0.18.20050801.4 on a FC4 X86_64. Please can someone help me ? Thanks
danycrit wrote:
It is several weeks that I try to encode a live TV feed (from a V4L2 capture device) to an MPEG2 file using the avformat library without success. I always get 'buffer underrun' errors and core dumps from glibc due to a double free or corruption (caused by avformat/avcodec since the code without the compression calls works perfectly). The resulting file, when playable, is always out of sync, stuttering and all weird things that could happen to a video file.
Since it is a live source I can't feed more data than what I receive. I know that the video and audio timings may not be exactly to the microsecond, but why avformat is so concerned about this buffer ? Is there a way to disable this damned buffer ?
I searched for some tutorials, example or even for a spell to cast in order to get this thing working, but without success.
Try basing your source code on the file 'output_example.c' that is included with FFmpeg. Replace the code in output_example.c that produces the dummy frames with code that grabs your V4L2 frames.
I found thousands of site with the avformat/avcodec source code nicely formatted but without any useful information. It seems that avformat users are more concerned about playing a file rather than creating one (should I assume that avformat is useful for playing only ?).
Nope. Otherwise, FFmpeg wouldn't be able to do transcoding...
I just updated the ffmpeg library: bad move, now the frame rate fields are missing, how do I set the frame rate ?
'frame_rate' was replaced with 'time_base'. HTH Martin -- Martin B?hme Inst. f. Neuro- and Bioinformatics Ratzeburger Allee 160, D-23538 Luebeck Phone: +49 451 500 5514 Fax: +49 451 500 5502 boehme at inb.uni-luebeck.de
Martin Boehme <boehme <at> inb.uni-luebeck.de> writes:
I searched for some tutorials, example or even for a spell to cast in order to get this thing working, but without success.
Try basing your source code on the file 'output_example.c' that is included with FFmpeg. Replace the code in output_example.c that produces the dummy frames with code that grabs your V4L2 frames.
The code is already based on output_example.c, still I have buffer underrun errors and unsynced audio/video all the way. Maybe the problem is that output_example.c can feed the frames as fast as possible and as expected by the stream configuration (25 fps, 44100 KHz audio, for example), while a live source delivers frames when it has something to deliver. Maybe the library can be used only for recorded streams ? Is live encoding supported ?
danycrit wrote:
Martin Boehme <boehme <at> inb.uni-luebeck.de> writes:
I searched for some tutorials, example or even for a spell to cast in order to get this thing working, but without success.
Try basing your source code on the file 'output_example.c' that is included with FFmpeg. Replace the code in output_example.c that produces the dummy frames with code that grabs your V4L2 frames.
The code is already based on output_example.c, still I have buffer underrun errors and unsynced audio/video all the way. Maybe the problem is that output_example.c can feed the frames as fast as possible and as expected by the stream configuration (25 fps, 44100 KHz audio, for example), while a live source delivers frames when it has something to deliver. Maybe the library can be used only for recorded streams ? Is live encoding supported ?
No, FFmpeg doesn't care how fast you feed the video data to it... indeed it has no notion of whether you're going faster or slower than "real-time". Of course, if your live source isn't delivering 25 frames per second or if you're missing frames (maybe because the encoding is taking too much time), then you'll get out of synch. Martin -- Martin B?hme Inst. f. Neuro- and Bioinformatics Ratzeburger Allee 160, D-23538 Luebeck Phone: +49 451 500 5514 Fax: +49 451 500 5502 boehme at inb.uni-luebeck.de
Martin Boehme <boehme <at> inb.uni-luebeck.de> writes:
No, FFmpeg doesn't care how fast you feed the video data to it... indeed it has no notion of whether you're going faster or slower than "real-time".
Good to know. However if it has no notion of the "real-time" why does it complains about buffer underruns ? What is causing this error and how do I get rid of it ? I think that it is the multiplexing process, since when encoding two separate audio and video streams I get no errors.
danycrit <danycrit <at> yahoo.it> writes:
Martin Boehme <boehme <at> inb.uni-luebeck.de> writes:
No, FFmpeg doesn't care how fast you feed the video data to it... indeed it has no notion of whether you're going faster or slower than "real-time".
Good to know. However if it has no notion of the "real-time" why does it complains about buffer underruns ? What is causing this error and how do I get rid of it ? I think that it is the multiplexing process, since when encoding two separate audio and video streams I get no errors.
Just a note for anyone that is interested, I switched the output format to mpegts (Transport Stream) and the buffer underflows are gone away and the a/v stream, played back with mplayer, is perfectly synced, so there must be something broken in the other mpeg formats (svcd, dvd, etc.). Now, I don't really need an mpegts file, but if that's all I can get from ffmpeg, I'll make a reason for it.
Hi On Fri, Nov 04, 2005 at 11:12:17AM +0000, danycrit wrote:
danycrit <danycrit <at> yahoo.it> writes:
Martin Boehme <boehme <at> inb.uni-luebeck.de> writes:
No, FFmpeg doesn't care how fast you feed the video data to it... indeed it has no notion of whether you're going faster or slower than "real-time".
Good to know. However if it has no notion of the "real-time" why does it complains about buffer underruns ? What is causing this error and how do I get rid of it ? I think that it is the multiplexing process, since when encoding two separate audio and video streams I get no errors.
Just a note for anyone that is interested, I switched the output format to mpegts (Transport Stream) and the buffer underflows are gone away and the a/v stream, played back with mplayer, is perfectly synced, so there must be something broken in the other mpeg formats (svcd, dvd, etc.).
dont use dvd or svcd if you dont mean it, use plain mpeg-ps
Now, I don't really need an mpegts file, but if that's all I can get from ffmpeg, I'll make a reason for it.
i strongly suggest to avoid mpeg containers for anything realtime if you can, and it seems you dont care about the container, muxing into mpeg cointainers is timeconsuming and complicated, its not a good choice for realtime ... [...] -- Michael
danycrit wrote:
Hi All,
It is several weeks that I try to encode a live TV feed (from a V4L2 capture device) to an MPEG2 file using the avformat library without success. I always get 'buffer underrun' errors and core dumps from glibc due to a double free or corruption (caused by avformat/avcodec since the code without the compression calls works perfectly). The resulting file, when playable, is always out of sync, stuttering and all weird things that could happen to a video file.
try using someother programs for video capture. mencoder is very nice see if they work.
Since it is a live source I can't feed more data than what I receive. I know that the video and audio timings may not be exactly to the microsecond, but why avformat is so concerned about this buffer ? Is there a way to disable this damned buffer ?
I searched for some tutorials, example or even for a spell to cast in order to get this thing working, but without success. I found thousands of site with the avformat/avcodec source code nicely formatted but without any useful information. It seems that avformat users are more concerned about playing a file rather than creating one (should I assume that avformat is useful for playing only ?).
I just updated the ffmpeg library: bad move, now the frame rate fields are missing, how do I set the frame rate ? -r <fps> Geez, these guys must hate documentation !!
no the documentation is not as good as mplayer's but its good enough
The library version should be: 0.4.9-0.lvn.0.18.20050801.4 on a FC4 X86_64. maybe thats your problem, are you usinf pre-made rpms.
Please can someone help me ? Thanks
participants (4)
-
boehme@inb.uni-luebeck.de -
danycrit@yahoo.it -
lordverminard@gmail.com -
michaelni@gmx.at