Opened 5 years ago

Last modified 5 years ago

#7710 new defect

pkt_size on UDP output not fixed lenght

Reported by: Antonio Jose Tomas Martinez Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: udp
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


When you want to output a fixed lenght of UDP packets at say 1316 bytes (7*TS) using the UDP option pkt_size, the output is limited to 1316 bytes but not fixed to that size.
How to reproduce:

% ffmpeg -re -i file.ts -c copy -f mpegts udp://
ffmpeg version N-93057-g860098efad Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 46.100 / 58. 46.100
  libavformat    58. 26.100 / 58. 26.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100}}}

tcpdump will show this:
tcpdump -i lo0 udp port 1234
14:09:49.247075 IP > UDP, length 1316
14:09:49.247156 IP > UDP, length 1316
14:09:49.247314 IP > UDP, length 564
14:09:49.247490 IP > UDP, length 1316
14:09:49.247680 IP > UDP, length 1316
14:09:49.247915 IP > UDP, length 752

I guess this can be fixed stably just changing:
- flush_buffer(s);
+ if (!s->max_packet_size || s->buf_ptr - s->buffer >= s-max_packet_size) flush_buffer(s);

Change History (4)

comment:1 by Carl Eugen Hoyos, 5 years ago

Keywords: udp added; pkt_size fixed length removed

If you have a patch fixing this issue, please send it - attaching the result of git format-patch - to the FFmpeg development mailing list, patches are ignored on the bug tracker.
To make this a valid bug report, please add the command line you tested together with the complete, uncut console output.

comment:2 by Antonio Jose Tomas Martinez, 5 years ago

I forked it and patched on
The commandline I used it, is written above.

ffmpeg -re -i file.ts -c copy -f mpegts udp://

I will try to submit it to dev mail list.

comment:3 by Carl Eugen Hoyos, 5 years ago

The only way to get a patch into FFmpeg mainline is to send it - made with git format-patch - to the development mailing list.
If you - instead of sending a patch - want to make this a valid ticket, please add the command line you tested together with the complete, uncut console output.

comment:4 by Marton Balint, 5 years ago

This is not a bug. If you want fixed packet size, you should use the -flush_packets 0 option.

Note: See TracTickets for help on using tickets.