Derek Smithies | 1 Aug 2003 01:16
Picon
Favicon

Problems ffmpeg==>Openh323

Hi,
 Several problems were experienced in adding ffmpeg to the openh323 
project.

1)I followed the docs, which said, 
      libavcodec/apiexample is your example.

  apiexample does not use FF_INPUT_BUFFER_PADDING_SIZE

  so, I did not provide FF_INPUT_BUFFER_PADDING_SIZE buffer at 
  the end of the decode_video buffer.
  This caused some weird faults on windows.

2)Initially, we tried to get ffmpeg to work in rtp_mode.
  This generated nicely sized packets, which were then sent to the 
  network. However, ffmpeg did not always respect the rtp_payload_size
  variable, and some fatally large packets were generated.

  So, we worked hard and split those fatally large packets.

  Encoding worked fine - all the packets were being transmitted Ok.
  At the decoder, all the received packets were concatenated into one big 
  block. This block would be identical to the block generated by:
    avcodec_encode_video

  But, there was a problem resulting from transmission on the network.
   You see, the decoder would receive X of N packets in a frame.
  Typically, X is equal to N.
  However, sometimes X is less than N. In this situation, we just 
  sent the smaller block to avcodec_decode_video and hoped.
(Continue reading)

Derek Smithies | 1 Aug 2003 01:16
Picon
Favicon

Code Changes, ffmpeg=>OpenH323

Hi,
 Specific code changes that were made to get ffmpeg working
in openh323 were:

1)The file printing.c was added. This contains a routine 
  which handles all printing generated by ffmpeg.

 Consequently, it was possible to direct all print statements to
  the logfile generator in OpenH323.

2)I added a line to libavcodec/Makefile, which generates a dll.
  The change was::

$(SLIB): $(OBJS)
        $(CC) $(SHFLAGS) -o $ <at>  $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
+ifeq ($(CONFIG_WIN32),yes)
+        dllwrap -mno-cygwin --target=i386-mingw32 --export-all -o libavcodec.dll $(OBJS) -lmsvcrt
-lcrtdll -L/usr/lib/mingw
+endif

When OpenH323 runs in windows, msvc is used. Consequently, to use ffmpeg 
with OpenH323 on windows, I had to link msvc with code generated by 
ffmpeg.

I found it impossible to link  libavcodec.so to code generated by msvc 6. 
Consequently, I used the windows equivalent of dlopen/dlsym in the msvc
generated code to call ffmpeg routines.

3)I added some declerations to common .h, namely
#define fprintf   openh323_fprintf
(Continue reading)

Derek Smithies | 1 Aug 2003 01:16
Picon
Favicon

Finally, ffmpeg works in OpenH323

Hi,
 I want to bring you guys up with the status of using your code in the 
OpenH323 project (www.sf.net/projects/openh323)

It has been a bit of a battle, but we finally have ffmpeg working reliably 
in a windows and linux environment.

Performance wise, it really flies in comparison to the H261&H263 codecs 
from the vic project:
     http://www-nrg.ee.lbl.gov/vic/ and
     http://www-mice.cs.ucl.ac.uk/multimedia/software/vic/download.html

Many many thanks to  Michael Niedermayer for his help on a couple of 
questions.
Also, thanks to BERO and Daniel Serpell who answered questions on windows.

I wanted to share my experience, so that others can learn from my hassles.
The best way to do this is write a series of short letters to this list.
I hope noone takes offence.

 Keep up the good work guys!

Derek.
===========================================================

--

-- 
Derek Smithies Ph.D.
IndraNet Technologies Ltd.
Email: derek <at> indranet.co.nz
ph +64 3 365 6485
(Continue reading)

Derek Smithies | 1 Aug 2003 01:16
Picon
Favicon

windows compiling ffmpeg=>Openh323

Hi,
 I note from the www.sf.net/projects/ffmpeg that it states the OS can be 
windows.

So, read the docs.

From ffmpeg/doc/ffmpeg-doc.texi
  <at> section Windows
 Empty.

From  ffmpeg/doc/faq.texi
 Use mingw-gcc available at http://www.mingw.org/ to compile the code. It
 generates object files fully compatible with other windows compilers.

From  ffmpeg/htdocs/win32.html (which is just 28 hours old)
A complete description of windows compiling of ffmpeg (well, enough for
most people) that I have only just found today. Surely, this could be
linked in the ffmpeg-doc.texi file? 

Derek.
 -- 
Derek Smithies Ph.D.
IndraNet Technologies Ltd.
Email: derek <at> indranet.co.nz
ph +64 3 365 6485
Web: http://www.indranet-technologies.com/

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
(Continue reading)

Dan Dennedy | 1 Aug 2003 02:42
Favicon

Re: Problems ffmpeg==>Openh323

Earlier, Derek wrote:

>  I want to bring you guys up with the status of using your code in the
> OpenH323 project (www.sf.net/projects/openh323)
> 
> It has been a bit of a battle, but we finally have ffmpeg working
> reliably in a windows and linux environment.

Hi, I have been working on video support for Linphone (SIP) using
ffmpeg.  This is my first time implementing something like this, so I am
facing perhaps some similar issues as you.

On Thu, 2003-07-31 at 19:16, Derek Smithies wrote:

> 2)Initially, we tried to get ffmpeg to work in rtp_mode.
>   This generated nicely sized packets, which were then sent to the 
>   network. However, ffmpeg did not always respect the rtp_payload_size
>   variable, and some fatally large packets were generated.

I noticed this too, but I am not totally aware of the impact of packets
larger than MTU - RTP header size. I just figured they would be split at
the link layer based upon MTU. For now, it seems to work ok as long as
there is not too much UDP packet lossage. 

To use the rtp callback, I added a generic data pointer arg to the
callback parameter list. I make it point to a structure I need to use
within my callback to enqueue the packets for RTP transmission. A patch
was submitted here but not yet committed.

>   So, we worked hard and split those fatally large packets.
(Continue reading)

Juan J. Sierralta P. | 1 Aug 2003 02:49
Picon

Re: Problems ffmpeg==>Openh323

On Thu, 2003-07-31 at 19:16, Derek Smithies wrote:

> 2)Initially, we tried to get ffmpeg to work in rtp_mode.
>   This generated nicely sized packets, which were then sent to the 
>   network. However, ffmpeg did not always respect the rtp_payload_size
>   variable, and some fatally large packets were generated.
> 
>   So, we worked hard and split those fatally large packets.

	As I said months ago. H.263 RTP mode does the "best effort" to spit
packets <= MTU. This because H.263 uses GOBs structure and sometimes,
especially on I frames a GOB of the minimal size (a row of MB) is bigger
than the wanted MTU.
	Actually, the best would be to have slice encoding support, in that way
the encoder could make slices of an arbitrary number of MB not
necesarily a complete row.
	AFAIK RTP H.263 specs defines a way to signal that a packet doesn't
contain a complete GOB/slice and its the followup of a previously
transmited packet (which has the GOB start code).

>   Encoding worked fine - all the packets were being transmitted Ok.
>   At the decoder, all the received packets were concatenated into one big 
>   block. This block would be identical to the block generated by:
>     avcodec_encode_video
> 
>   But, there was a problem resulting from transmission on the network.
>    You see, the decoder would receive X of N packets in a frame.
>   Typically, X is equal to N.
>   However, sometimes X is less than N. In this situation, we just 
>   sent the smaller block to avcodec_decode_video and hoped.
(Continue reading)

Juan J. Sierralta P. | 1 Aug 2003 03:03
Picon

Re: Problems ffmpeg==>Openh323

On Thu, 2003-07-31 at 20:42, Dan Dennedy wrote:

> >   Encoding worked fine - all the packets were being transmitted Ok.
> >   At the decoder, all the received packets were concatenated into one big 
> >   block. This block would be identical to the block generated by:
> >     avcodec_encode_video
> 
> I use the same approach. I use the GOB number to keep track of start of
> a new frame.

	Look for the Picture Start Code (PSC) which is 0000 0000 0000 0000 1
00000 (22 bits aligned).
	Note that the GOB Start Code (GBSC) is 0000 0000 0000 0000 1 (17 bits
aligned) it's followed by GOB Number (5 bits) which in case of the first
GOB (number 0) correspond to the PSC so the rest of GOB header isn't
transmited. Also note that the RTP Callback always returns a GOB so it
has the first 16 bits on zero which aren't transmited on the RTP payload
but signaled as a packet which contains a GOB start.
	I believe the trick is at the decoder, you should keep track of Seqs to
detect if a packet was lost in order to discard the frame; since you
don't know a priori the numbers of GOBs a frames is divided into you
must have a buffer and decode the full frame after you receive the next
PSC.

--

-- 
Juanjo sin .sig :(

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
(Continue reading)

Andrej Javorsek | 1 Aug 2003 12:00
Picon

ffmpeg and DV

Hello!
This is my first mail on this list, so hello everybody!

The question from me is:
-Is it possible to encode video in PAL DV format (audio and video)?

 I tryed to transcode avi file (created with mencoder) into dv.
Parameters of input file were: resolution 720x576, 25fps, codec DV (from libavcodec), audio 16bit (uncompressed) pcm.

Transcoding parameters were (aproximately): ffmpeg -i infile.avi -vcodec copy -acodec copy -f dv outfile.dv

It seems that ffmpeg recognised that file and processit with no errors. But! When I tryed to upload that file back to my Sony DCR-TRV25E, DV handycam with dvconnect (from libdv) I got garbage!
When I identify that file (with mplayer -identify), I noticed that I have NTSC internal structure of file (but actual compression is stil PAL -> "garbage" ).    ;)

I tried transcoding switches like "-r pal -s pal" and "-r 25 -s 720x576" but output dv file is still NTSC.

If I transcode file with switch "-f rawvideo" I get good picture but no sound (I expected that from ffmpeg info during transcoding).

Is there any other way to transcode avi video to proper PAL DV or to get video (and audio) back to DV camcoder (under Linux)?

Thank you for answers!
Regards
Andrej

------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01

Andrej Javorsek | 1 Aug 2003 12:56
Picon

Re: ffmpeg and DV

Sory!
I forgot to mention I was transcoding on Slackware linux 9.0 with 
ffmpeg-cvs-2003-07-28!

Regards
Andrej

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Michael Niedermayer | 1 Aug 2003 13:00
Picon

CVS: ffmpeg/libavcodec mpegvideo.c,1.266,1.267 h263.c,1.180,1.181 h263dec.c,1.121,1.122

Update of /cvsroot/ffmpeg/ffmpeg/libavcodec
In directory sc8-pr-cvs1:/tmp/cvs-serv14216

Modified Files:
	mpegvideo.c h263.c h263dec.c 
Log Message:
make the h263 decoder more error tolerant

Index: mpegvideo.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpegvideo.c,v
retrieving revision 1.266
retrieving revision 1.267
diff -u -d -r1.266 -r1.267
--- mpegvideo.c	29 Jul 2003 02:09:12 -0000	1.266
+++ mpegvideo.c	1 Aug 2003 11:00:02 -0000	1.267
 <at>  <at>  -1004,6 +1004,14  <at>  <at> 
     if(s->next_picture_ptr) s->next_picture= *s->next_picture_ptr;
     if(s->new_picture_ptr ) s->new_picture = *s->new_picture_ptr;

+    if(s->pict_type != I_TYPE && s->last_picture_ptr==NULL){
+        fprintf(stderr, "warning: first frame is no keyframe\n");
+        assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
+        goto alloc;
+    }
+
+    assert(s->pict_type == I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
+
     if(s->picture_structure!=PICT_FRAME){
         int i;
         for(i=0; i<4; i++){
 <at>  <at>  -1014,12 +1022,6  <at>  <at> 
             s->last_picture.linesize[i] *=2;
             s->next_picture.linesize[i] *=2;
         }
-    }
-    
-    if(s->pict_type != I_TYPE && s->last_picture_ptr==NULL){
-        fprintf(stderr, "warning: first frame is no keyframe\n");
-        assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
-        goto alloc;
     }
   }

Index: h263.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/h263.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- h263.c	29 Jul 2003 09:58:47 -0000	1.180
+++ h263.c	1 Aug 2003 11:00:03 -0000	1.181
 <at>  <at>  -2500,6 +2500,8  <at>  <at> 
         return -1;
     s->mb_x= 0;
     s->mb_y= s->gob_index* s->gob_number;
+    if(s->mb_y >= s->mb_height) 
+        return -1;
 #ifdef DEBUG
     fprintf(stderr, "\nGN: %u GFID: %u Quant: %u\n", s->gob_number, gfid, s->qscale);
 #endif
 <at>  <at>  -4069,7 +4071,7  <at>  <at> 

     startcode= get_bits(&s->gb, 22-8);

-    for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>0; i--) {
+    for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=8) {
         startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;

         if(startcode == 0x20)
 <at>  <at>  -4116,8 +4118,6  <at>  <at> 
         if (!width)
             return -1;

-        s->width = width;
-        s->height = height;
         s->pict_type = I_TYPE + get_bits1(&s->gb);

         s->unrestricted_mv = get_bits1(&s->gb); 
 <at>  <at>  -4137,6 +4137,9  <at>  <at> 
         }
         s->qscale = get_bits(&s->gb, 5);
         skip_bits1(&s->gb);	/* Continuous Presence Multipoint mode: off */
+
+        s->width = width;
+        s->height = height;
     } else {
         int ufep;

Index: h263dec.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/h263dec.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- h263dec.c	29 Jul 2003 02:09:12 -0000	1.121
+++ h263dec.c	1 Aug 2003 11:00:03 -0000	1.122
 <at>  <at>  -470,6 +470,15  <at>  <at> 
     } else {
         ret = h263_decode_picture_header(s);
     }
+    
+    if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size);
+
+    /* skip if the header was thrashed */
+    if (ret < 0){
+        fprintf(stderr, "header damaged\n");
+        return -1;
+    }
+    
     avctx->has_b_frames= !s->low_delay;

     if(s->workaround_bugs&FF_BUG_AUTODETECT){
 <at>  <at>  -604,13 +613,6  <at>  <at> 

     if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P))
         s->gob_index = ff_h263_get_gob_height(s);
-
-    if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size);
-    /* skip if the header was thrashed */
-    if (ret < 0){
-        fprintf(stderr, "header damaged\n");
-        return -1;
-    }

     // for hurry_up==5
     s->current_picture.pict_type= s->pict_type;

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01

Gmane