The footage, published on social media by a senator in the Spanish parliament, is reported to have been filmed in Melilla, an enclave of Spain on the north African coast.
Morocco has become a major gateway into Europe for African migrants.
The latest incident, filmed on Sunday, apparently documented the first time there had been an attempt to smuggle people inside a mattress, according to local media.
The driver of the vehicle fled to Morocco before being arrested by authorities.
The two migrants were said to be in good health conditions and did not require medical assistance.