How are transaction fees calculated in raw-transactions?
Here is a great answer on how to calculate the transaction size before sending. (Make sure to read the final edit.)

As for the fee, you've got it right: whatever amount from the inputs is NOT sent to other addresses, becomes the transaction fee for the miners.