简体   繁体   English

Ffmpeg更改细分市场元数据

[英]Ffmpeg Change Segment Metadata

I was wondering if it is at all possible to change the metadata of video segments in ffmpeg as the segments are being created. 我想知道是否可以在创建片段时更改ffmpeg中视频片段的元数据。 I know that by using the "-metadata" tag, you can change the metadata of the -i input video, but if that -i input video is being split into different segments by the "-f segment" option, then how do you change the metadata of the resulting segments while the -i input video is being segmented? 我知道通过使用“-metadata”标签,您可以更改-i输入视频的元数据,但如果通过“-f segment”选项将-i输入视频拆分为不同的段,那么您如何在分割-i输入视频时更改结果段的元数据? I know that it's possible to change the metadata after the segmenting has completed, but this isn't that useful since I'm looking to stream the segments live as the input video is being segmented. 我知道在分段完成后可以更改元数据,但这并不是很有用,因为我希望在输入视频被分段时实时流式传输段。 To give a little better description: 为了更好地描述一下:

ffmpeg -f video4linux2 -s wvga -t ${CAPTURE_DURATION} -i "/dev/video0" -r 30 \
-vcodec ${VID_CODEC} -s:v 640x480 -b:v 80k -keyint_min 30 -g 30 \
-sc_threshold 0 -map 0 -flags -global_header -qcomp 0.8 \
-qmin 10 -qmax 51 -qdiff 4 -f segment -segment_time ${SEG_TIME} \
-segment_format ${SEG_FORMAT} -metadata START=0 -y "${LOCATE}${OUTPUT}%01d.${EXTENSION}"

Essentially what I'm doing is taking a video from the standard video input and segmenting it. 基本上我正在做的是从标准视频输入中获取视频并对其进行分割。 Once the video segments are created, I can test videos by throwing them all into a VLC playlist, and when the segment format is "mp4", there is a notable delay between each video segment where VLC won't start the video segment until it has played back the time again where the segment was in the original video. 创建视频片段后,我可以通过将视频片段全部放入VLC播放列表来测试视频,当片段格式为“mp4”时,每个视频片段之间存在明显的延迟,其中VLC将不会启动视频片段直到它已播放该片段在原始视频中的时间。 So for example, if I have a 30 second video, and split it into 5 second segments, VLC will play the 1st segment immediately, but it will wait 5 seconds before playing the 2nd segment after the 1st segment has finished playing. 因此,例如,如果我有30秒的视频,并将其分成5秒的片段,VLC将立即播放第1段,但在第1段完成播放后播放第2段之前将等待5秒。 It does this because the 2nd segment has a start time metadata of 5 seconds, so VLC thinks that it has to wait 5 seconds before playing the 2nd segment. 这样做是因为第2段的开始时间元数据为5秒,因此VLC认为它必须等待5秒才能播放第2段。 What I'm wondering is if there's a way to tell ffmpeg to set the segment start time metadata to 0 seconds as the segments are being created. 我想知道的是,如果有一种方法可以告诉ffmpeg在创建段时将段开始时间元数据设置为0秒。 Any help would be greatly appreciated. 任何帮助将不胜感激。

According to the source code, there is a flag that should do what you want: 根据源代码,有一个标志应该做你想要的:

{ "reset_timestamps", "reset timestamps at the begin of each segment",
OFFSET(reset_timestamps), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E }

instead of -metadata START=0 use -reset_timestamps 1 and all your segments will start playing immediately. 而不是-metadata START=0使用-reset_timestamps 1并且所有段将立即开始播放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM