A novel dynamic programming based technique for optimal selection of input video format and compression rate for video streaming based on "relevancy' of the content and user context is presented. The technique uses context dependent content analysis to divide the input video into temporal segments. User selected relevance levels assigned to these segments are used in formulating a constrained optimization problem, which is solved using dynamic programming. The technique minimizes a weighted distortion measure and the initial waiting time for continuous playback under maximum acceptable distortion constraints. Spatial resolution and frame rate of input video and the DCT quantization parameters are used as optimization variables. The technique is applied to encoding of soccer videos using an H.264 encoder. The improvements obtained over a standard H.264 implementation are demonstrated by experimental results.