Madison was indeed very nearly captured, which would have precipitated a constitutional crisis. Clearly in such a case the president would be incapacitated in all practical terms. I'd suppose that the Secretary of State (at the time, James Monroe) would make the declaration of inability and DeWitt Clinton would assume the duties of the presidency, at least for the time being.
Now, assuming that there are no butterflies with respect to individual longevities, there will be another crisis toward the end of November 1814: Clinton died OTL on 23 November 1814, which would leave the acting presidency in the hands of the president pro tempore of the Senate--except there wasn't one when Clinton died, which makes things stickier still. Joseph Varnum of Massachusetts left that office on 3 February 1814 and his successor, John Gaillard of South Carolina, wouldn't take office until 25 November 1814 in OTL. That would have left the presidency-nominally, at least-in the hands of Langdon Cheves of South Carolina.
I suspect that in this situation, Monroe would have been the de facto president. He would have probably issued instructions to the peace negotiators in Ghent, likely to seek the most generous terms available. Chances are that the confusion in Washington could have led to the revival of the Hartford Convention and the secession of the New England states also.
What happens then is really up for grabs. A migration of US-loyal New Englanders to New York, New Jersey, Pennsylvania and Delaware doesn't seem unlikely (imagine, if you will, Adams pére et fils finding a new home in, say, Chester County, PA (Delaware County didn't split off until quite some years later) near Philadelphia, or Daniel Webster as a representative, then senator from Delaware). By the same token, the War Hawks would probably be thoroughly discredited, and the opposition--what was left of the Federalists plus dissident Democrats--would hold the US government for some time to come.
I'd suspect Canada gets unified sooner to ensure what would amount to a renascent British grip on North America. B