Navigation

    Home
    All Categories
    • KEEN Trail Camera
    • Top #ReolinkCaptures Awards
    • Announcements and News
    • Wishlist
    • #ReolinkTrial
    • Discussion About Products
    • Reolink Captures
    • Reolink Client & APP
    #ReolinkTrial
    Reolink Captures
    Log in to post
    Guest
    • Guest
    • Register
    • Login

    Learn More

    Reolink updates Learn More

    Meet Reolink at IFA 2024! Learn More

    Reolink Q&A Learn More

    Reolink RTSP-->ffmpeg, RTP: PT=xx: bad cseq if stopped/restarted quickly

    Reolink Client & APP
    5
    14
    4610
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Steven Kan_61128021664
      Steven Kan last edited by

      My BeeCam is a Raspberry Pi3/Raspbian Stretch w/freshly compiled ffmpeg version N-89882-g4dbae00bac running this as a service:

      #!/bin/bash
      cd /usr/local/bin/
      while true
      do
      ./ffmpeg -re -thread_queue_size 512 -rtsp_transport tcp -i
      "rtsp://anonymous:password@192.168.1.11:554" -i WilliamTellOverture.mp3
      -vcodec copy -acodec copy -t 00:11:51 -f flv
      "rtmp://a.rtmp.youtube.com/live2/my-youtube-streaming-key"
      sleep 10s
      done



      where 192.168.1.11 is my spiffy new Reolink RLC-423S, and -t 00:11:51 is the length of my royalty-free MP3. This normally works quite well:

      https://www.youtube.com/user/IAmTheWaterbug/live

      and it loops continuously. The YT stream will glitch when it restarts, but the stream resumes with only about 15 seconds of video lost. It ran continuously overnight for at least 8 hours (e.g. many loops) before I started fiddling with it.

      I changed the sleep to 5s, and that doesn't seem to bother it.

      But on occasion I've done a sudo systemctl stop StreamToYouTube followed by sudo systemctl start StreamToYouTube, within 1-2 seconds (e.g. as fast as I can type Up Up Up and Enter), and sometimes when I do that, the stream fails, and ffmpeg starts dumping:

      [rtsp @ 0x302c2f0] RTP: PT=60: bad cseq e680 expected=0b49
      [rtsp @ 0x302c2f0] RTP: PT=60: bad cseq 93ab expected=0b49
      [rtsp @ 0x302c2f0] RTP: PT=60: bad cseq 93ac expected=0b49
      [rtsp @ 0x302c2f0] RTP: PT=60: bad cseq e682 expected=0b49



      endlessly.

      Rebooting the Pi doesn't fix this (e.g. the YT stream still fails, and sudo systemctl status StreamToYouTube returns the same stream of "bad cseq" errors), but rebooting the RLC-423S does fix it. I'm wondering what exactly that error means.

      During the "failed" state, the camera appears to be working properly from other clients, e.g. I can launch the Reolink.app on my Mac or view the camera's web page from any browser, and the video looks fine.

      But for some reason the RTSP stream goes funky in a way that ffmpeg can't resolve.

      It's quite repeatable if I stop/start the service quickly, but restarting with a 5 second pause in my script doesn't seem to bother it.

      Thanks!
      BadCseq.png

      Reply Quote
      Share
      • Share this Post
      • Facebook
      • Twitter
      • copy the link
        Copied!
      0
        View 0 replies
      • alex_137391448420499
        alex last edited by

        I am having the same issue with my RLC-410 and RLC-420.
        The stream works great if I let them rest for ~30 seconds between running my application (which is using ffmpeg).
        Something is not getting cleaned up properly on the camera-side when the stream is closed.
        2019-04-23_14-29-17.png

        Reply Quote
        Share
        • Share this Post
        • Facebook
        • Twitter
        • copy the link
          Copied!
        0
          View 0 replies
        • Steven Kan_61128021664
          Steven Kan last edited by

          So that 30 second pause fixes things? I'll try putting a 30 second pause in my watchdog timer.

          Thanks!

          Reply Quote
          Share
          • Share this Post
          • Facebook
          • Twitter
          • copy the link
            Copied!
          0
            View 0 replies
          • bigger_lawxx_188801901305986
            bigger_lawxx last edited by

            Have the same problem here. 30 second pause doesnt fix the problem.

            Reply Quote
            Share
            • Share this Post
            • Facebook
            • Twitter
            • copy the link
              Copied!
            0
              View 0 replies
            • Cynthia_124785627824270
              Cynthia last edited by

              Could you please send an email to support@reolink.com? Our support team will check it for you soon. Thanks.

              Reply Quote
              Share
              • Share this Post
              • Facebook
              • Twitter
              • copy the link
                Copied!
              0
                View 0 replies
              • Venryx_183193454948501
                Venryx last edited by

                I had the same issue as the posters above, and found a solution here: https://superuser.com/a/1562786/231129

                Regarding the 30 second pause: It seems it differs by model. Some cameras (my C2 and alex's RLC 410 and 420) appear to have an "auto cleanup" of streams after a wait of about 30 seconds (after stream termination from the computer end), whereas for others (the cameras Steven Kan and bigger_law have), it appears there isn't such a function (thus requiring a camera reboot).

                Anyway, check and see if the solution I linked to works for you. (I'm guessing it will solve at least some of other people's cases)

                Reply Quote
                Share
                • Share this Post
                • Facebook
                • Twitter
                • copy the link
                  Copied!
                0
                  • Steven Kan_61128021664
                    Steven Kan @Venryx last edited by

                    It seems it differs by model. Some cameras (my C2 and alex's RLC 410 and 420) appear to have an ”auto cleanup” of streams after a wait of about 30 seconds (after stream termination from the computer end), whereas for others (the cameras Steven Kan and bigger_law have), it appears there isn't such a function (thus requiring a camera reboot).



                    Ah, things are making more and more sense right now! I have a RLC-410S with Hardware No. IPC_3816M, and it barfs whenever the ffmpeg service stops or restarts.

                    I have an RLC-410 with Hardware No. IPC_51316M it doesn't seem to mind when my ffmpeg service stops/restarts.

                    I couldn't figure out why two such similar cameras behaved so differently.

                    My RLC-423 and my RLC-411 are both Hardware No. IPC_3816M, and both behave like my RLC-410S, e.g. they barf on ffmpeg stop/restart.

                    Reply Quote
                    Share
                    • Share this Post
                    • Facebook
                    • Twitter
                    • copy the link
                      Copied!
                    0
                    View 0 replies
                  • Steven Kan_61128021664
                    Steven Kan last edited by

                    Thanks! I'm incredibly impressed that you were able to duplicate and fix such as obscure problem!

                    I'm copying and pasting your solution from GitHub:

                    FFMpeg.prototype.stop = function() {

                    // replace this...
                    //this.child.kill();

                    // with this...
                    this.child.stdin.write("q\r\n");

                    delete this.child;
                    this.emit('stop');
                    };


                    Does this mean I have to make this change in the ffmpeg source and recompile it?

                    Thanks!

                    Reply Quote
                    Share
                    • Share this Post
                    • Facebook
                    • Twitter
                    • copy the link
                      Copied!
                    0
                      View 0 replies
                    • Venryx_183193454948501
                      Venryx last edited by

                      No, the fix I made was in the NodeJS library that was launching (and non-graciously killing) the ffmpeg process.


                      This is the file I changed: https://[censored]/agsh/rtsp-ffmpeg/blob/master/lib/rtsp-ffmpeg.js


                      So for your case, I would look to the source code of whatever program is "killing" the ffmpeg process. If nothing (in your program) is explicitly killing the subprocess, then I guess you'll need to add a "cleanup" function that graciously ends the subprocess prior to your program overall being terminated.

                      Reply Quote
                      Share
                      • Share this Post
                      • Facebook
                      • Twitter
                      • copy the link
                        Copied!
                      0
                        View 0 replies
                      • Steven Kan_61128021664
                        Steven Kan last edited by

                        Ah, I see. Right now I'm calling ffmpeg through a bash script:

                        #!/bin/bash
                        cd /usr/local/bin/
                        while true
                        do
                        ./ffmpeg -re -thread_queue_size 512 -rtsp_transport tcp -i \
                        "rtsp://anonymous:password@192.168.1.11:554" -i WilliamTellOverture.mp3 \
                        -vcodec copy -acodec copy -t 00:11:51 -f flv \
                        "rtmp://a.rtmp.youtube.com/live2/my-youtube-streaming-key"
                        sleep 10s
                        done



                        that I'm running as a service:

                        [Unit]
                        Description=Streamer
                        After=network-online.target
                        Requires=network-online.target

                        [Service]
                        ExecStart=/usr/local/bin/StreamToYouTube1.sh
                        Restart=always
                        KillSignal=TERM

                        [Install]
                        WantedBy=multi-user.target



                        Can you advise on how I can specify the correct termination method when I send a:

                        'sudo systemctl stop StreamToYouTube'?

                        Thanks!

                        Reply Quote
                        Share
                        • Share this Post
                        • Facebook
                        • Twitter
                        • copy the link
                          Copied!
                        0
                          View 0 replies
                        • Venryx_183193454948501
                          Venryx last edited by

                          Unfortunately I don't know much (basically anything) about Linux/Mac services, so I won't be much help for the specifics.

                          One thing I can say is that it probably involves this:
                          KillSignal=TERM

                          In the NodeJS library I referenced, that is the same kill-signal it had been sending to the ffmpeg process to end it (which was causing the issue).

                          So, you'd need to find some way to have the "stop service" command send the "gracious exit" input I mentioned ("q\r\n"), rather than the "TERM" (ie. "SIGTERM") kill-signal.

                          It's possible the "sudo systemctl stop StreamToYouTube" approach you're using doesn't support this, meaning you'd need to find an alternative way of sending the "gracious quit" message. (though maybe it does support it, I don't know ^_^)

                          Reply Quote
                          Share
                          • Share this Post
                          • Facebook
                          • Twitter
                          • copy the link
                            Copied!
                          0
                            View 0 replies
                          • Steven Kan_61128021664
                            Steven Kan last edited by

                            Ah, ok. Thanks! I'll ask over on arstechnica, where they know Unix. You still get a cookie for finding the solution!

                            Reply Quote
                            Share
                            • Share this Post
                            • Facebook
                            • Twitter
                            • copy the link
                              Copied!
                            0
                              View 0 replies
                            • Venryx_183193454948501
                              Venryx last edited by

                              Haha thanks! I like your stream by the way. 🙂

                              Reply Quote
                              Share
                              • Share this Post
                              • Facebook
                              • Twitter
                              • copy the link
                                Copied!
                              0
                                • Steven Kan_61128021664
                                  Steven Kan @Venryx last edited by

                                  Haha thanks! I like your stream by the way. 🙂



                                  Thanks! It'll be a lot more reliable once I figure out how to stop/restart the service cleanly.

                                  Reply Quote
                                  Share
                                  • Share this Post
                                  • Facebook
                                  • Twitter
                                  • copy the link
                                    Copied!
                                  0
                                  View 0 replies
                                • First post
                                  Last post
                                All Categories
                                Announcements and News Reolink Client & APP Discussion About Products #ReolinkTrial Reolink Captures Wishlist KEEN Trail Camera
                                Never miss Reolink hot deals, news, and updates tailored for you.

                                Thanks for your subscription!

                                Please enter a valid email address.

                                Oops… Something went wrong. Please try again later.

                                You are already subscribed to this email list. :)

                                Submission failed. Please try again later.

                                Reolink Store|Support|About Us|Privacy Policy|Terms and Conditions

                                Copyright 2025 © Reolink All Rights Reserved.

                                Welcome Back!

                                Hi there! Join the Commnunity to get all the latest news, tips and more!

                                Join Now