Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1235 closed defect (fixed)

ffio_limit does not work correctly with named pipes on OSX (Snow Leopard)

Reported by: ls Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

$ ffmpeg -f s16le -ac 2 -ar 48000 -i <(ffmpeg -loglevel warning -i camera-raw.mp4 -c:a pcm_s16le -f s16le -ac 2 -ar 48000 -) out.wav

ffmpeg version git-2012-04-19-ab75ad0 Copyright (c) 2000-2012 the FFmpeg developers
  built on Apr 19 2012 19:20:02 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/homes/lschilli/src/ffmpeg-gar-osx/build --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-sram --cpu=core2 --enable-hwaccel=h264_vaapi --enable-hwaccel=mpeg2_vaapi --enable-hwaccel=mpeg4_vaapi --enable-libfaac --disable-ffserver --enable-libfreetype --enable-x11grab
  libavutil      51. 46.100 / 51. 46.100
  libavcodec     54. 14.101 / 54. 14.101
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 70.100 /  2. 70.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 11.100 /  0. 11.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, s16le, from '/dev/fd/63':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
Guessed Channel Layout for  Input Stream #0.0 : stereo
Output #0, wav, to '/tmp/out.wav':
  Metadata:
    encoder         : Lavf54.3.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le -> pcm_s16le)
Press [q] to stop, [?] for help
Truncating packet of size 4096 to 1
[pcm_s16le @ 0x101853e00] invalid PCM packet
Error while decoding stream #0:0
Truncating packet of size 4096 to 1
[pcm_s16le @ 0x101853e00] invalid PCM packet
Error while decoding stream #0:0
Truncating packet of size 4096 to 1
[pcm_s16le @ 0x101853e00] invalid PCM packet
Error while decoding stream #0:0
Truncating packet of size 4096 to 1
[pcm_s16le @ 0x101853e00] invalid PCM packet
[...]

Removing size= ffio_limit(s, size); from av_get_packet in libavformat/utils.c seems to be a workaround for this problem. On linux the same command line results in only one of the error messages above.

Change History (4)

comment:1 by ls, 12 years ago

On OSX in ffio_limit s->seekable is 0 when process substitution is used (ffmpeg reads from /dev/fd/xx) while on Linux s->seekable is 1. Furthermore s->maxsize is always 16384 on OSX. I do not understand if avio_size is supposed to work for non seekable streams. Currently I have applied this:

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1bf5ac5..a066cd7 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -276,7 +276,7 @@ AVInputFormat *av_find_input_format(const char *short_name)
 
 int ffio_limit(AVIOContext *s, int size)
 {
-    if(s->maxsize>=0){
+    if(s->maxsize>=0 && s->seekable){
         int64_t remaining= s->maxsize - avio_tell(s);
         if(remaining < size){
             int64_t newsize= avio_size(s);

comment:3 by Michael Niedermayer, 12 years ago

Resolution: fixed
Status: newclosed

I assume martins patch fixed this. If not please reopen.

comment:4 by ls, 12 years ago

Yes, I can verify it does. Thanks for fixing this.

Note: See TracTickets for help on using tickets.