Opened 10 months ago

Closed 8 months ago

#10828 closed defect (fixed)

ffmpeg 6.1 truncating first five bytes of KLV data stream

Reported by: Richard Scott McNew Owned by:
Priority: important Component: avformat
Version: 6.1 Keywords: klv
Cc: Richard Scott McNew, Marton Balint Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

ffmpeg 6.1 truncates the first five bytes of the KLV data stream packet in mpegts videos

How to reproduce:

Download videos with KLV data stream from:
https://samples.ffmpeg.org/MPEG2/mpegts-klv/

With ffmpeg 6.0:

./ffprobe -show_packets -select_streams d 'Day Flight.mpg'

Output:
[PACKET]
codec_type=data
stream_index=1
pts=N/A
pts_time=N/A
dts=N/A
dts_time=N/A
duration=N/A
duration_time=N/A
size=163
pos=55989596
flags=K

With ffmpeg 6.1 development branch git cloned from https://git.ffmpeg.org/ffmpeg.git:

./ffprobe -show_packets -select_streams d 'Day Flight.mpg'

Output:
[PACKET]
codec_type=data
stream_index=1
pts=N/A
pts_time=N/A
dts=N/A
dts_time=N/A
duration=N/A
duration_time=N/A
size=158
pos=55989596
flags=K

Note the "size" field difference. The first five bytes of the first KLV stream key are being omitted from each packet.

The same problem occurs when extracting the KLV data stream from the mpegts file:

With ffmpeg 6.0:

./ffmpeg -i 'Day Flight.mpg' -c copy -map d -f data klv60.bin
./ls -la

-rw-r--r-- 1 rmcnew rmcnew 977 Jan 27 11:39 klv60.bin

With ffmpeg 6.1 development:

./ffmpeg -i 'Day Flight.mpg' -c copy -map d -f data klv61-dev.bin
./ls -la

-rw-r--r-- 1 rmcnew rmcnew 947 Jan 27 11:40 klv61-dev.bin

Again notice the size difference.

This KLV data truncation corrupts the data stream since it leaves out the first five bytes of the KLV 'key' needed for KLV processing, decoding, etc.

FFmpeg 6.0 details:
ffmpeg version n6.0.1-1-g133069b434-20240127 Copyright (c) 2000-2023 the FFmpeg developers

built with gcc 13.2.0 (crosstool-NG 1.25.0.232_c175b21)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu- --arch=x86_64 --target-os=linux --enable-nonfree --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-openssl --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --disable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --disable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags=-pie --extra-libs='-ldl -lgomp' --samples=fate-suite/ --extra-version=20240127
libavutil 58. 2.100 / 58. 2.100
libavcodec 60. 3.100 / 60. 3.100
libavformat 60. 3.100 / 60. 3.100
libavdevice 60. 1.100 / 60. 1.100
libavfilter 9. 3.100 / 9. 3.100
libswscale 7. 1.100 / 7. 1.100
libswresample 4. 10.100 / 4. 10.100
libpostproc 57. 1.100 / 57. 1.100

FFmpeg 6.1-development details:
ffmpeg version N-113433-gbab7f91c36-20240127 Copyright (c) 2000-2024 the FFmpeg developers

built with gcc 13.2.0 (crosstool-NG 1.25.0.232_c175b21)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu- --arch=x86_64 --target-os=linux --enable-nonfree --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-openssl --enable-lzma --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --samples=fate-suite/ --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags=-pie --extra-libs='-ldl -lgomp' --samples=fate-suite/ --extra-version=20240127
libavutil 58. 36.101 / 58. 36.101
libavcodec 60. 38.100 / 60. 38.100
libavformat 60. 20.100 / 60. 20.100
libavdevice 60. 4.100 / 60. 4.100
libavfilter 9. 17.100 / 9. 17.100
libswscale 7. 6.100 / 7. 6.100
libswresample 4. 13.100 / 4. 13.100
libpostproc 57. 4.100 / 57. 4.100

Build framework used: https://github.com/BtbN/FFmpeg-Builds

Build options:
./makeimage.sh linux64 nonfree 6.0
./build.sh linux64 nonfree 6.0
and
./makeimage.sh linux64 nonfree 6.1
./build.sh linux64 nonfree 6.1 *but adapted to point to cloned development branch

Build operating system: Red Hat Enterprise Linux release 9.3 (Plow) running under WSL2

Change History (2)

comment:1 by Marton Balint, 8 months ago

Cc: Marton Balint added
Component: undeterminedavformat
Status: newopen

comment:2 by Marton Balint, 8 months ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.