The invention discloses a safe data transmission method based on Real-Time Messaging Protocol (RTMP) connections. The method has the advantages that functional extensions of the RTMP are carried out, and through a key negotiation process between a client and a server, an encryption algorithm and a key adopted by each connection are random, so that external cracking analysis of encrypted data is much more difficult; the symmetrical encryption algorithms are adopted for encryption processing, so that the encryption and decryption processing efficiencies are high, real-time performance of data transmission and user experience are not obviously affected, and the effects on the processing load of the server are small; meanwhile, the server can flexibly select an encryption mode, and, according to a user type or a resource type requested by a user, can determine whether encrypted transmission is needed or not or select one specific encryption algorithm and a key length (the keys with a length of 64 bytes or more can be provided, and the number of the encryption algorithms can reach 255).