[Ffmpeg-devel] truncated audio output
Michael Niedermayer
michaelni
Mon Jun 19 10:54:37 CEST 2006
Hi
On Mon, Jun 19, 2006 at 12:11:26AM -0400, Justin Ruggles wrote:
> After re-reading my post, I figured that my idea might be better
> explained by a patch. Here is what it would look like if I modified the
> pcm encoder to use my suggestion instead of frame_size=1, which is what
> is used currently.
i agree that a CODEC_CAP_VAR_FRAME_SIZE needs to be added ...
[...]
> Index: ffmpeg/ffmpeg.c
> ===================================================================
> --- ffmpeg/ffmpeg.c (.../svn://svn.mplayerhq.hu/ffmpeg/trunk) (revision 5497)
> +++ ffmpeg/ffmpeg.c (.../ffmpeg) (working copy)
> @@ -526,7 +526,7 @@
> }
>
> /* now encode as many frames as possible */
> - if (enc->frame_size > 1) {
> +
> /* output resampled raw samples */
> fifo_write(&ost->fifo, buftmp, size_out,
> &ost->fifo.wptr);
> @@ -551,48 +551,6 @@
>
> ost->sync_opts += enc->frame_size;
> }
> - } else {
> - AVPacket pkt;
i think we shouldnt drop support for leaving the packet size equal to
the input where its supported, that said i dont mind changing the default
to a fixed size if theres some advantage
[...]
> @@ -1357,12 +1315,32 @@
> if (ost->encoding_needed) {
> for(;;) {
> AVPacket pkt;
> + int fifo_bytes;
> av_init_packet(&pkt);
> pkt.stream_index= ost->index;
>
> switch(ost->st->codec->codec_type) {
> case CODEC_TYPE_AUDIO:
> - ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
> + fifo_bytes = fifo_size(&ost->fifo, NULL);
> + ret = 0;
> + /* encode any samples remaining in fifo */
> + if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_VAR_FRAME_SIZE) {
> + int fs_tmp = enc->frame_size;
> + enc->frame_size = fifo_bytes / (2 * enc->channels);
> + if(enc->frame_size > fs_tmp) {
> + enc->frame_size = fs_tmp;
> + }
why is that check needed? if we had more data then frame_size shouldnt that
have been encoded already? and what about non 16bit PCM?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
More information about the ffmpeg-devel
mailing list