In Manusmriti, the punishment for shedding semen by a student, who is a Brahmachari is described below. And there is in general a punishment prescribed for any man who masturbates.
Watching pornography and shedding semen comes under the category of masturbation (shedding semen out of lust). So the punishment prescribed for shedding semen out of lust gets applied here.
A. For Students
The punishment for shedding semen by a student is very harsh. There are two categories here. One is shedding semen in sleep (nightfall) and shedding semen unchastely out of lust (masturbation).
He should always sleep alone and never shed his semen, for by shedding his semen out of lust he breaks his vow. - Manusmriti 2.180
A.1. Punishment for nightfall (Manusmriti Chapter 2)
[181] A twice-born chaste student of the Veda who has spilt his semen in his sleep, not out of lust, should bathe, worship the sun, and chant, three times, the Vedic verse that begins, ‘Let my sensory power return to me again.’
[182] He should fetch a pot of water, flowers, cow dung, clay, and sacrificial grass, as much as are needed, and go begging every day.
[183] A chaste student of the Veda, purified, should beg every day from the houses of people who do not fail to perform Vedic sacrifices and who are approved of for carrying out their own innate activities.
[184] He should not beg from his guru’s family nor from the relatives of his mother or father, but if he cannot get to the houses of others he should avoid each of these more than the one that precedes it.
[185] And if there are none of the people mentioned above, he should beg from the whole village, purified and restrained in his speech, but he should avoid those who have been indicted.
[186] When he has brought fuel from a distance, he should set it down in the open air, not on the ground, and tirelessly make oblations into the fire with it, morning and evening.
[187] If he fails to go begging or to put fuel on the fire for seven nights when he is not ill, he should carry out the vow for one who has shed his semen unchastely.
A.2 Punishment for masturbation (Manusmriti Chapter 11)
[119] But a man who has shed his semen in violation of a vow should sacrifice a one-eyed donkey to Ruin at a crossroads at night, according to the rules for the domestic sacrifice.
[120] He should make an oblation into the fire in accordance with the rules and then offer oblations of melted butter to the Wind, Indra, the Guru, and Fire while reciting the verse that begins, ‘All over me’.
[121] When a twice-born man who has undertaken a vow sheds his semen out of lust, those who understand the law and expound the Veda call that a violation of the vow.
[122] The brilliant energy of the Veda in a man who has undertaken a vow goes if he has shed his semen, into four gods: the Wind, Indra the much-invoked, the Guru, and Fire.
[123] If this error is committed, he should put on the skin of a donkey and go begging from seven houses, proclaiming his own act.
[124] Living on the food that he has begged from them once a day, washing at sunrise, noon, and sunset, after a year he becomes clean.
B. For any man
General Punishment for Masturbation (Manusmriti 11)
[174] If a man has shed his semen in non-human females, in a man, in a menstruating woman, in something other than a vagina, or in water, he should carry out the ‘Painful Heating’ vow.
This means if anyone masturbates he should do a Painful heating vow (Sāntapana penance). It is described as follows
The Sāntapana penance is traditionally said to consist of cow urine, cow dung, milk, yoghurt, melted butter, water infused with sacrificial grass, and a fast of one night. - Manusmriti 11.213