Hi! I'm using avcodec, avformat libraries for encoding. Sometimes for syncronization reasons the program needs frame duplication, and i could only make this happen, with the same frame re-encoding. The question is, is there any way to duplicate (increase timestamps, ....) without encoding. Thanks in advance! __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
On Tue, Sep 13, 2005 at 12:27:08PM -0700, A. T. wrote:
Hi!
I'm using avcodec, avformat libraries for encoding. Sometimes for syncronization reasons the program needs frame duplication, and i could only make this happen, with the same frame re-encoding. The question is, is there any way to duplicate (increase timestamps, ....) without encoding.
You have to set the timestamp on all frames anyway.. just set it accordingly. BTW frame duplication is not a correct way to maintain sync. It's most likely the audio that's at fault, and unlike video audio rate can be adjusted without perceptual fault. Rich
Hi! --- Rich Felker <dalias at aerifal.cx> wrote:
You have to set the timestamp on all frames anyway.. just set it accordingly.
But i don't know how. Which structure, which member(s) should i change? What value(s) should i use to modify it (them)?
BTW frame duplication is not a correct way to maintain sync. It's most likely the audio that's at fault, and unlike video audio rate can be adjusted without perceptual fault.
Ok, the question is again how? Thanks in advance! __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Hi I did not want this subject to be an argument. Maybe the method is wrong, but right now i would be very happy if i could make this work using duplication. Here's my questions again: -Which structure, which member(s) should i change? -What value(s) should i use to modify it (them)? Thanks! __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
Hi! Maybe for the second time I will be able to get an answer for my question. How can frame duplication be done without encoding (which structure, which member(s) should i change; what value(s) should i use to modify it (them)) ? I'm sorry if I am disturbing somebody with my messages. Thanks in advance! ps: if it helps, i would like to use ffmpeg >= 0.4.8, ______________________________________________________ Yahoo! for Good Donate to the Hurricane Katrina relief effort. http://store.yahoo.com/redcross-donate3/
On Thu, Sep 15, 2005 at 09:04:33AM -0700, A. T. wrote:
Hi!
Maybe for the second time I will be able to get an answer for my question. How can frame duplication be done without encoding (which structure, which member(s) should i change; what value(s) should i use to modify it (them)) ?
Well I'm confused about what you're doing right now. Some code or pseudocode would help. Basically you just need to increase the pts by twice as much when sending the frame to the encoder, to 'duplicate' the previous frame. Rich
Hi --- Rich Felker <dalias at aerifal.cx> wrote:
Some code or pseudocode would help.
Basically you just need to increase the pts by twice as much when sending the
Yes, it would really help me. frame to the
encoder, to 'duplicate' the previous frame.
I did something like this, but that was just a guess and it did not work. And I believe there is more than just a pts value which needs to be changed - frame counter , etc. - and even if i knew what do i have to modify, still a question: with what value? Thanks in advance! __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Rich Felker wrote:
On Thu, Sep 15, 2005 at 09:04:33AM -0700, A. T. wrote:
Hi!
Maybe for the second time I will be able to get an answer for my question. How can frame duplication be done without encoding (which structure, which member(s) should i change; what value(s) should i use to modify it (them)) ?
Well I'm confused about what you're doing right now. Some code or pseudocode would help. Basically you just need to increase the pts by twice as much when sending the frame to the encoder, to 'duplicate' the previous frame.
Rich
Rich, the OP wants to duplicate a frame *without* encoding. IOW duplicate an *already encoded* frame. -- Michel Bardiaux R&D Director T +32 [0] 2 790 29 41 F +32 [0] 2 790 29 02 E mailto:mbardiaux at mediaxim.be Mediaxim NV/SA Vorstlaan 191 Boulevard du Souverain Brussel 1160 Bruxelles http://www.mediaxim.com/
On Mon, Sep 19, 2005 at 03:10:35PM +0200, Michel Bardiaux wrote:
Rich Felker wrote:
On Thu, Sep 15, 2005 at 09:04:33AM -0700, A. T. wrote:
Hi!
Maybe for the second time I will be able to get an answer for my question. How can frame duplication be done without encoding (which structure, which member(s) should i change; what value(s) should i use to modify it (them)) ?
Well I'm confused about what you're doing right now. Some code or pseudocode would help. Basically you just need to increase the pts by twice as much when sending the frame to the encoder, to 'duplicate' the previous frame.
Rich
Rich, the OP wants to duplicate a frame *without* encoding. IOW duplicate an *already encoded* frame.
Then alter the timestamps being sent to the muxer. This will work for formats with proper timestamps and where container timestamps are required to override codec timestamps (i.e. not many formats). The only 'correct' way to do it for the rest is to patch the coded frame headers. Rich
Hi! --- Rich Felker <dalias at aerifal.cx> wrote:
Then alter the timestamps being sent to the muxer. This will work for formats with proper timestamps and where container timestamps are required to override codec timestamps (i.e. not many formats). The only 'correct' way to do it for the rest is to patch the coded frame headers.
Then if its a problem, i can narrow this down. I would like to use AVI output format with MJPEG codec. What structure, which field should i increase (and of course with what value)? (Actually it would be a really big help if someone could gave me a small code which does this.) Thanks in advance! __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Rich Felker wrote:
On Tue, Sep 13, 2005 at 12:27:08PM -0700, A. T. wrote:
Hi!
I'm using avcodec, avformat libraries for encoding. Sometimes for syncronization reasons the program needs frame duplication, and i could only make this happen, with the same frame re-encoding. The question is, is there any way to duplicate (increase timestamps, ....) without encoding.
You have to set the timestamp on all frames anyway.. just set it accordingly. BTW frame duplication is not a correct way to maintain sync. It's most likely the audio that's at fault, and unlike video audio rate can be adjusted without perceptual fault.
There are still some cases where video itself needs to be resynched. Here we do captures 24/7 with *real* timestamps; every minute of video *must* have exactly 25 times 60 frames. But the broadcasters' timebases are often off by a few frames a day (typically 1 to 10, positive or negative). And even though the system clocks are synchronized with a DCF77 (the ancestor of GPS clocks), small fluctuations do occur. Hence it is sometimes necessary to drop or dup video frames. Dropping is easy, duplication works fine in MPEG1 CBR, but in MPEG1 VBR, even with low tolerance, the bitrate goes down by 50 to 75% locally, and that causes terrible problems in many players, esp. when seeking. So, is there a way to 'fuzz' (invisibly of course!) the duplicated frame to preserve bitrate?
Rich
-- Michel Bardiaux R&D Director T +32 [0] 2 790 29 41 F +32 [0] 2 790 29 02 E mailto:mbardiaux at mediaxim.be Mediaxim NV/SA Vorstlaan 191 Boulevard du Souverain Brussel 1160 Bruxelles http://www.mediaxim.com/
On Wed, Sep 14, 2005 at 10:12:38AM +0200, Michel Bardiaux wrote:
Rich Felker wrote:
On Tue, Sep 13, 2005 at 12:27:08PM -0700, A. T. wrote:
Hi!
I'm using avcodec, avformat libraries for encoding. Sometimes for syncronization reasons the program needs frame duplication, and i could only make this happen, with the same frame re-encoding. The question is, is there any way to duplicate (increase timestamps, ....) without encoding.
You have to set the timestamp on all frames anyway.. just set it accordingly. BTW frame duplication is not a correct way to maintain sync. It's most likely the audio that's at fault, and unlike video audio rate can be adjusted without perceptual fault.
There are still some cases where video itself needs to be resynched. Here we do captures 24/7 with *real* timestamps; every minute of video *must* have exactly 25 times 60 frames. But the broadcasters' timebases are often off by a few frames a day (typically 1 to 10, positive or negative). And even though the system clocks are synchronized with a DCF77 (the ancestor of GPS clocks), small fluctuations do occur. Hence it is sometimes necessary to drop or dup video frames.
No, it's not. Just consider the video refresh as the fundamental unit of time and ignore system clock. Due to the way video is sampled (don't even get me started about interlaced video), temporal resampling is impossible. Dropping or duplicating frames WILL look unbearably horrible unless you intelligently select to do this at a time when there is no motion. Rich
Rich Felker wrote:
On Wed, Sep 14, 2005 at 10:12:38AM +0200, Michel Bardiaux wrote:
There are still some cases where video itself needs to be resynched. Here we do captures 24/7 with *real* timestamps; every minute of video *must* have exactly 25 times 60 frames. But the broadcasters' timebases are often off by a few frames a day (typically 1 to 10, positive or negative). And even though the system clocks are synchronized with a DCF77 (the ancestor of GPS clocks), small fluctuations do occur. Hence it is sometimes necessary to drop or dup video frames.
No, it's not. Just consider the video refresh as the fundamental unit of time and ignore system clock. Due to the way video is sampled (don't even get me started about interlaced video), temporal resampling is impossible. Dropping or duplicating frames WILL look unbearably horrible unless you intelligently select to do this at a time when there is no motion.
Rich
From having followed many threads about telecine and interlacing, I know that your own measure is "best video quality". But this is not an option for me. The system here is a 24/7 *auditing* system: the system clock rules, and encoding is on-the-fly. If the broadcast genlock is off, too bad, that will be audited and will appear as some inserted or dropped frames. After time accurracy, the requirements are that access and slicing and copies and archival must be as easy as possible. Quality is not the *prime* criterion, only the 3rd (we actually encode at 600kbits). Definitely not your way of seeing things, I know. So, drop/dup is the only solution for me, but duplication causes drops in bitrate, and I am in need of some image processing trick to keep the bitrate under control when duplicating. HaND, -- Michel Bardiaux R&D Director T +32 [0] 2 790 29 41 F +32 [0] 2 790 29 02 E mailto:mbardiaux at mediaxim.be Mediaxim NV/SA Vorstlaan 191 Boulevard du Souverain Brussel 1160 Bruxelles http://www.mediaxim.com/
On Wed, Sep 14, 2005 at 03:53:33PM +0200, Michel Bardiaux wrote:
Rich Felker wrote:
On Wed, Sep 14, 2005 at 10:12:38AM +0200, Michel Bardiaux wrote:
There are still some cases where video itself needs to be resynched. Here we do captures 24/7 with *real* timestamps; every minute of video *must* have exactly 25 times 60 frames. But the broadcasters' timebases are often off by a few frames a day (typically 1 to 10, positive or negative). And even though the system clocks are synchronized with a DCF77 (the ancestor of GPS clocks), small fluctuations do occur. Hence it is sometimes necessary to drop or dup video frames.
No, it's not. Just consider the video refresh as the fundamental unit of time and ignore system clock. Due to the way video is sampled (don't even get me started about interlaced video), temporal resampling is impossible. Dropping or duplicating frames WILL look unbearably horrible unless you intelligently select to do this at a time when there is no motion.
Rich
From having followed many threads about telecine and interlacing, I know that your own measure is "best video quality". But this is not an option for me. The system here is a 24/7 *auditing* system: the system clock rules, and encoding is on-the-fly. If the broadcast genlock is off, too bad, that will be audited and will appear as some inserted or dropped frames.
And a duplicate or missing frame won't look like someone edited it??!? I find that hard to believe. Duplicate or dropped frames are easily detectable. Whoever's using frame count to check for editing has their priorities backwards.. Rich
Rich Felker wrote:
On Wed, Sep 14, 2005 at 03:53:33PM +0200, Michel Bardiaux wrote:
Rich Felker wrote:
On Wed, Sep 14, 2005 at 10:12:38AM +0200, Michel Bardiaux wrote:
There are still some cases where video itself needs to be resynched. Here we do captures 24/7 with *real* timestamps; every minute of video *must* have exactly 25 times 60 frames. But the broadcasters' timebases are often off by a few frames a day (typically 1 to 10, positive or negative). And even though the system clocks are synchronized with a DCF77 (the ancestor of GPS clocks), small fluctuations do occur. Hence it is sometimes necessary to drop or dup video frames.
No, it's not. Just consider the video refresh as the fundamental unit of time and ignore system clock. Due to the way video is sampled (don't even get me started about interlaced video), temporal resampling is impossible. Dropping or duplicating frames WILL look unbearably horrible unless you intelligently select to do this at a time when there is no motion.
Rich
From having followed many threads about telecine and interlacing, I know that your own measure is "best video quality". But this is not an option for me. The system here is a 24/7 *auditing* system: the system clock rules, and encoding is on-the-fly. If the broadcast genlock is off, too bad, that will be audited and will appear as some inserted or dropped frames.
And a duplicate or missing frame won't look like someone edited it??!? I find that hard to believe. Duplicate or dropped frames are easily detectable. Whoever's using frame count to check for editing has their priorities backwards..
Uh? The purpose of this audit is not to check for editing; it is to produce log files of all programs and advertisings on TV channels (and more). -- Michel Bardiaux R&D Director T +32 [0] 2 790 29 41 F +32 [0] 2 790 29 02 E mailto:mbardiaux at mediaxim.be Mediaxim NV/SA Vorstlaan 191 Boulevard du Souverain Brussel 1160 Bruxelles http://www.mediaxim.com/
Hi! I am using FFmpeg in my program, but i was not able to find out 2 things. The first thing is connected to error messages: is there any function to get these? (basically i want to write out the reason when a avcodec_open call fails) The second thing is about AC3 codec usage. I modified the output_example.c to work with this, but the sound was totally out of sync. If i used MP3, everything was good. My question is what kind of extra setup needed for AC3 (to work with AVI output format)? Thanks in advance! __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com
Hi! I am using FFmpeg for encoding in my program. I wanted to use AC3 codec, so I modified output_example.c, but the output file's sound was totally out of sync. If MP3 was used, everything was good. The question is what extra configuration needed for this (if it counts, i want to use AVI output format) - or what changes have to be done in output_example.c to make this work? Thanks in advance! __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
Hi! I'm using two threads to encode a video and an audio stream. The questions are should i use mutual exclusion for writing out a frame or not, why is there an interleaved writer function and in my case which one do you suggest to use? Thanks in advance! __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
Paul Lake wrote:
I'm using two threads to encode a video and an audio stream. The questions are should i use mutual exclusion for writing out a frame or not
Yes!
why is there an interleaved writer function
Well... so you don't have to do the interleaving yourself. Quoting from the source: /** * Writes a packet to an output media file ensuring correct interleaving. * * The packet must contain one audio or video frame. * If the packets are already correctly interleaved the application should * call av_write_frame() instead as its slightly faster, its also important * to keep in mind that completly non interleaved input will need huge amounts * of memory to interleave with this, so its prefereable to interleave at the * demuxer level * * @param s media file handle * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ... * @return < 0 if error, = 0 if OK, 1 if end of stream wanted. */ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ [...]
and in my case which one do you suggest to use?
Probably av_interleaved_write_frame(). Bear in mind that you should probably make sure the audio and video thred run at approximately the same speed so your buffers don't get too big. 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
Hi! Is there any way to encode unsigned 8 bit PCM input with a non-PCM codec? (or only signed 16 bit supported?) Thanks in advance! __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
participants (4)
-
boehme@inb.uni-luebeck.de -
dalias@aerifal.cx -
knowdet@yahoo.com -
mbardiaux@mediaxim.be