Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

记录的 FLV 的 FPS 从 60 更改为 62.5 - 严重问题 #Bug #201

Closed
abrar71 opened this issue Jul 14, 2022 · 6 comments
Closed

记录的 FLV 的 FPS 从 60 更改为 62.5 - 严重问题 #Bug #201

abrar71 opened this issue Jul 14, 2022 · 6 comments

Comments

@abrar71
Copy link
Contributor

abrar71 commented Jul 14, 2022

流式传输 60 FPS 的示例视频文件会将其录制文件的 FPS 更改为 62.5 FPS
OBS 或 WireCast 流媒体软件也存在同样的问题
我在下面附上了 lal 录音文件的输入和输出. 我认为这是一个严重的问题

ffmpeg -i /home/abr/frame_counter_4k_60fps.flv -c copy -f flv rtmp://127.0.0.1:1935/app/frame_counter_stream

Input file:

$ ffmpeg -i frame_counter_4k_60fps.flv
Input #0, flv, from 'frame_counter_4k_60fps.flv':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.16.100
  Duration: 00:01:00.04, start: 0.019000, bitrate: 658 kb/s
  Stream #0:0: Video: h264, yuv420p(progressive), 3840x2160 [SAR 1:1 DAR 16:9], 640 kb/s, 60 fps, 60 tbr, 1k tbn
  Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp, 2 kb/s

Recorded file:

$ ffmpeg -i lal_record/flv/frame_counter_stream-1657775570.flv
Input #0, flv, from 'frame_counter_stream-1657775570.flv':
  Duration: 00:00:59.98, start: 0.000000, bitrate: 659 kb/s
  Stream #0:0: Data: none
  Stream #0:1: Video: h264, yuv420p(progressive), 3840x2160 [SAR 1:1 DAR 16:9], 62.50 fps, 60 tbr, 1k tbn
  Stream #0:2: Audio: aac, 48000 Hz, stereo, fltp

English:
Streaming a sample video file at 60 FPS changes the FPS of the recorded file to 62.5 FPS.
The same problem is with OBS or WireCast streaming software.
I have attached the input and output from lal recording files below
This is a critical problem

input_frame_counter_4k_60fps.zip
output_lal_recorded_file.zip
another_sample_file.mp4

#Bug

@abrar71 abrar71 changed the title 记录的 FLV 的 FPS 从 60 更改为 62.5 - 严重问题 记录的 FLV 的 FPS 从 60 更改为 62.5 - 严重问题 #Bug Jul 14, 2022
@abrar71
Copy link
Contributor Author

abrar71 commented Jul 16, 2022

Whatever input FPS is provided, the recorded file's FPS is always wrong.
I think the problem might be in packaging RTMP to FLV tags

@q191201771
Copy link
Owner

简单来说,这是由于ffmpeg推流时,会把原始flv中metadata中的duration字段去除,而lalserver录制的flv,metadata完全使用rtmp的metadata导致的。

现阶段,你可以使用lal中app/demo/pushrtmp替代ffmpeg推流,来解决这个问题。

请问为什么这是一个critical problem?
其他流媒体服务器现象如何?你有空测试并反馈给我吗?

我好评估处理的优先级。

@abrar71
Copy link
Contributor Author

abrar71 commented Jul 17, 2022

经过数小时的研究,我认为我们需要在 lal 的 PackHttpflvTag() 函数中使用 https://github.com/gwuhaolin/livego/blob/master/protocol/amf/metadata.go#L31 中的 MetaDataReform() 函数. 像这样:

func PackHttpflvTag(t uint8, timestamp uint32, in []byte) []byte {

	if t == TagTypeMetadata {
		in, _ = amf.MetaDataReform(in, amf.DEL)
	}

	out := make([]byte, TagHeaderSize+len(in)+PrevTagSizeFieldSize)

我已经对此进行了测试,它解决了问题。

@q191201771
Copy link
Owner

Fixed, try again.

@abrar71
Copy link
Contributor Author

abrar71 commented Jul 20, 2022

This resolves the issue, Thank you! I'll test a bit more and then close the issue.

@q191201771
Copy link
Owner

This resolves the issue, Thank you! I'll test a bit more and then close the issue.

Nice to hear that.
I've modified it a little bit just a moment ago, you shall test the freshest code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants