From the Prophet ﷺ. Hisham bin Ammar narrated to us, Sufyan narrated to us, from Zuhri, from Salim, from his father, from Amir bin Rabia, who heard him relate from the Prophet ﷺ that he said, "When you see a funeral procession, stand up for it until it passes you or is set down."
حدثنا محمد بن رمح أنبأنا الليث بن سعد عن نافع عن ابن عمر
عن النبي ﷺ ح و حدثنا هشام بن عمار حدثنا سفيان عن الزهري عن سالم عن أبيه عن عامر بن ربيعة سمعه يحدث عن النبي ﷺ قال إذا رأيتم الجنازة فقوموا لها حتى تخلفكم أو توضع
Bukhari transmitted it in the Book of Funerals, Chapter on Standing for the Funeral, no. 1307, 1308, and Muslim in the Book of Funerals, Chapter on Standing for the Funeral, no. 958, from the hadith of Layth and Sufyan through it.