Why does piped FFMPEG output differ from an explicit file?

0

The following creates files that have very slightly different toplevel definitions. Why?

$ ffmpeg -f lavfi -i "sine=frequency=1000:duration=1" infile.mp3
$ ffmpeg -i infile.mp3 -f wav - > piped.wav
$ ffmpeg -i infile.mp3 -f wav outfile.wav
$ diff <(hexdump outfile.wav) <(hexdump piped.wav)
< 0000000 4952 4646 58ce 0001 4157 4556 6d66 2074
---
> 0000000 4952 4646 ffff ffff 4157 4556 6d66 2074

My ffmpeg build:

ffmpeg version n4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100

Ian Hunter

Posted 2019-11-26T05:38:01.353

Reputation: 196

Answers

4

58ce 0001 in the input WAV is the file size. FFmpeg will initialize this field with -1. If the output is written over a seekable protocol, ffmpeg will update with actual filesize at the end of muxing operation, else leave it as it is.

Gyan

Posted 2019-11-26T05:38:01.353

Reputation: 21 016