video - FFMPEG 元数据不适用于段格式

标签 video ffmpeg metadata video-capture

我正在尝试将旋转元数据添加到从 RTSP 流录制的视频中。在我尝试以分段格式运行录制之前,一切正常。我的命令如下所示:

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

我可以在日志中看到,rotate 应该以 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
不幸的是,视频中没有元数据
$ 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
知道如何使用分段和元数据记录 RTSP 吗?我真的更喜欢使用元数据进行轮换,因为我计划将来在元数据中保存更多信息。

最佳答案

我发现它已经解决了
https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=a74428921f8bfb33cbe0340bfd810b6945e432d2#patch1
它在 ffmpeg 5.0 中运行良好。您也可以将此补丁应用到 4.4。

关于video - FFMPEG 元数据不适用于段格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71020015/

相关文章:

javascript - 自动播放时的 HTTP 状态(已取消),循环在 HTML 视频元素上为真

html - Firefox 不播放 HTML5 视频中的 mp4 文件

PHP + FFMPEG + S3。直接在 S3 存储桶之间转码视频

xslt - 使用 XSLT 的元数据驱动生成

php - Facebook 共享器弹出窗口

javascript - WebRTC偶尔会黑屏

ios - 意外行为播放视频在iOS 9 中使用MPMoviePlayerViewController 播放本地视频时?

javascript - 暂停视频和切换按钮

android - xml文件中元数据的用途是什么?

FFmpeg 从视频中间删除 2 秒并连接部分。单线解决方案