Opened 2 years ago

Closed 2 years ago

#9632 closed defect (worksforme)

Metadata not work with segment format

Reported by: Przemek Owned by:
Priority: normal Component: avformat
Version: 4.2.4 Keywords: segment METADATA rotate
Cc: Przemek Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Przemek)

Summary of the bug:
I'm trying to add rotation metadata to the video recorded from RTSP stream. All works fine until I try to run recording with segment format.

How to reproduce:

% ffmpeg -rtsp_transport tcp -stimeout 1000000 -i "<RTSP>" -vcodec copy -map_metadata 0 -metadata:s:v rotate=270 -an -dn -y -segment_time 60 -strftime 1 -reset_timestamps 1 -t 25 -f segment /home/short.mp4

I can see in logs that rotate should be written to the metadata as displaymatrix: rotation of -90.00 degrees

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --disable-stripping --enable-pic --enable-shared --enable-pthreads --cross-prefix=aarch64-poky-linux- --ld='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cc='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cxx='aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --arch=aarch64 --target-os=linux --enable-cross-compile --extra-cflags=' -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0=/usr/src/debug/ffmpeg/4.2.2-r0 -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot= -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot-native= -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --extra-ldflags='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now' --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot --libdir=/usr/lib --shlibdir=/usr/lib --datadir=/usr/share/ffmpeg --disable-mipsdsp --disable-mipsdspr2 --cpu=generic --pkg-config=pkg-config --disable-static --enable-alsa --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-bzlib --disable-libfdk-aac --enable-gpl --disable-libgsm --disable-indev=jack --disable-libvorbis --enable-lzma --disable-libmfx --disable-libmp3lame --disable-openssl --enable-postproc --disable-sdl2 --disable-libspeex --enable-swresample --enable-swscale --enable-libtheora --disable-vaapi --disable-vdpau --disable-libvpx --enable-libx264 --disable-libx265 --enable-libxcb --enable-outdev=xv --enable-zlib
  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
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, rtsp, from 'rtsp://admin:dupa.666@192.168.77.122:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream':
  Metadata:
    title           : RTSP Session
  Duration: N/A, start: 0.200000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 5 fps, 5 tbr, 90k tbn, 180k tbc
Output #0, segment, to '/home/short.mp4':
  Metadata:
    title           : RTSP Session
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, q=2-31, 5 fps, 5 tbr, 90k tbn, 90k tbc
    Side data:
      displaymatrix: rotation of -90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[segment @ 0x5594be0340] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[segment @ 0x5594be0340] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
frame=   67 fps=8.6 q=-1.0 Lsize=N/A time=00:00:13.00 bitrate=N/A speed=1.67x

Unfortunately, there is no metadata in out video

$ ffmpeg -i short.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --disable-stripping --enable-pic --enable-shared --enable-pthreads --cross-prefix=aarch64-poky-linux- --ld='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cc='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cxx='aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --arch=aarch64 --target-os=linux --enable-cross-compile --extra-cflags=' -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0=/usr/src/debug/ffmpeg/4.2.2-r0 -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot= -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot-native= -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --extra-ldflags='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now' --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot --libdir=/usr/lib --shlibdir=/usr/lib --datadir=/usr/share/ffmpeg --disable-mipsdsp --disable-mipsdspr2 --cpu=generic --pkg-config=pkg-config --disable-static --enable-alsa --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-bzlib --disable-libfdk-aac --enable-gpl --disable-libgsm --disable-indev=jack --disable-libvorbis --enable-lzma --disable-libmfx --disable-libmp3lame --disable-openssl --enable-postproc --disable-sdl2 --disable-libspeex --enable-swresample --enable-swscale --enable-libtheora --disable-vaapi --disable-vdpau --disable-libvpx --enable-libx264 --disable-libx265 --enable-libxcb --enable-outdev=xv --enable-zlib
  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
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'short.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : RTSP Session
    encoder         : Lavf58.29.100
  Duration: 00:00:13.00, start: 0.000000, bitrate: 1024 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080, 1023 kb/s, 5.15 fps, 5 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandler
At least one output file must be specified

Looks like segment purges metadata from the out file.

Tested on ffmpeg 4.2.2 and 4.2.4 on Linux Mint

Change History (2)

comment:1 by Przemek, 2 years ago

Description: modified (diff)

comment:2 by mkver, 2 years ago

Component: ffmpegavformat
Priority: importantnormal
Resolution: worksforme
Status: newclosed

Works in master; should have been fixed in a74428921f8bfb33cbe0340bfd810b6945e432d2.

Note: See TracTickets for help on using tickets.