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

Support FFmpeg timecode, fix AMF0 parsing failed. #3803

Closed
winlinvip opened this issue Sep 18, 2023 · 1 comment · Fixed by #3804
Closed

Support FFmpeg timecode, fix AMF0 parsing failed. #3803

winlinvip opened this issue Sep 18, 2023 · 1 comment · Fixed by #3804
Assignees
Labels
EnglishNative This issue is conveyed exclusively in English.

Comments

@winlinvip
Copy link
Member

winlinvip commented Sep 18, 2023

See Error submitting a packet to the muxer: Broken pipe, Error muxing a packet

Test using the file timecode.mp4.zip or below:

timecode.mp4

Use this FFmpeg command:

ffmpeg -re -i timecode.mp4 -map 0 -c copy -f flv rtmp://localhost/live/livestream

SRS will fail with this error:

[2023-09-18 11:25:37.576][ERROR][79462][910ul5n0][4] serve error code=2003(Amf0Decode)(Decode AMF0 message failed) : service cycle : rtmp: stream service : rtmp: receive thread : handle publish message : rtmp: consume message : rtmp: decode message : decode message : decode command name : String invalid marker=0
thread [79462][910ul5n0]: do_cycle() [./src/app/srs_app_rtmp_conn.cpp:263][errno=4]
thread [79462][910ul5n0]: service_cycle() [./src/app/srs_app_rtmp_conn.cpp:457][errno=4]
thread [79462][910ul5n0]: do_publishing() [./src/app/srs_app_rtmp_conn.cpp:1030][errno=35]
thread [79462][910ul5n0]: consume() [./src/app/srs_app_recv_thread.cpp:380][errno=35]
thread [79462][910ul5n0]: handle_publish_message() [./src/app/srs_app_rtmp_conn.cpp:1185][errno=35]
thread [79462][910ul5n0]: process_publish_message() [./src/app/srs_app_rtmp_conn.cpp:1230][errno=35]
thread [79462][910ul5n0]: decode_message() [./src/protocol/srs_protocol_rtmp_stack.cpp:384][errno=35]
thread [79462][910ul5n0]: do_decode_message() [./src/protocol/srs_protocol_rtmp_stack.cpp:607][errno=35]
thread [79462][910ul5n0]: srs_amf0_read_string() [./src/protocol/srs_protocol_amf0.cpp:1513][errno=35](Interrupted system call)

Here's the pcap file:

rtmp-amf0-invalid.pcapng.zip

@winlinvip winlinvip self-assigned this Sep 18, 2023
@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Sep 18, 2023
@winlinvip
Copy link
Member Author

winlinvip commented Sep 18, 2023

Examine the pcap file, where FFmpeg sends AMF0 data, but it doesn't begin with the AMF0 string:

Packet #72:
04 00 00 64 00 00 04 12 01 00 00 00

Packet #74:
00 01 a5 e0

(lldb) p *msg
(SrsCommonMessage) $0 = {
  header = {
    timestamp_delta = 100
    payload_length = 4
    message_type = '\x12' 18 '\x12'
    stream_id = 1
    timestamp = 100
    perfer_cid = 4
  }
  size = 4
  payload = 0x0000602000003570 ""
}
(lldb) x/4xb msg->payload
0x602000003570: 0x00 0x01 0xa5 0xe0

SRS should be able to handle this message by simply ignoring it:

[2023-09-18 11:38:45.099][WARN][91322][148t53jz][35] Ignore FFmpeg timecode, data=[00 01 a5 e0]

image

winlinvip added a commit that referenced this issue Sep 18, 2023
…3804)

Please see #3803 for detail:

1. When using FFmpeg with the `-map 0` option, there may be a 4-byte
timecode in the AMF0 Data.
2. SRS should be able to handle this packet without causing a parsing
error, as it's generally expected to be an AMF0 string, not a 4-byte
timecode.
3. Disregard the timecode since SRS doesn't utilize it.

See [Error submitting a packet to the muxer: Broken pipe, Error muxing a
packet](https://trac.ffmpeg.org/ticket/10565)

---------

Co-authored-by: john <hondaxiao@tencent.com>
winlinvip added a commit that referenced this issue Sep 18, 2023
Please see #3803 for detail:

1. When using FFmpeg with the `-map 0` option, there may be a 4-byte
timecode in the AMF0 Data.
2. SRS should be able to handle this packet without causing a parsing
error, as it's generally expected to be an AMF0 string, not a 4-byte
timecode.
3. Disregard the timecode since SRS doesn't utilize it.

See [Error submitting a packet to the muxer: Broken pipe, Error muxing a
packet](https://trac.ffmpeg.org/ticket/10565)

---------

Co-authored-by: john <hondaxiao@tencent.com>
duiniuluantanqin pushed a commit to duiniuluantanqin/srs that referenced this issue Oct 11, 2023
Please see ossrs#3803 for detail:

1. When using FFmpeg with the `-map 0` option, there may be a 4-byte
timecode in the AMF0 Data.
2. SRS should be able to handle this packet without causing a parsing
error, as it's generally expected to be an AMF0 string, not a 4-byte
timecode.
3. Disregard the timecode since SRS doesn't utilize it.

See [Error submitting a packet to the muxer: Broken pipe, Error muxing a
packet](https://trac.ffmpeg.org/ticket/10565)

---------

Co-authored-by: john <hondaxiao@tencent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EnglishNative This issue is conveyed exclusively in English.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant