How to set Frame Range automatically to video length

How can I set a End Frame of blender movie clip editor to match the end time of the video (without trying to search the End Frame of video)? Currently when I'm importing the video, the End Frame is set to 250 instead of ~600 which my video is currently having.

• Quick manual solution: Press PageUp after inserting the clip to jump to its end with your playhead, then hover over the timeline and press E to set the end frame – Samoth Jul 5 '16 at 6:52
• nothing happen when i do so...i'm i doing it wrong? – aji Jul 5 '16 at 8:12
• The PageUp / PageDown only works while hovering your mouse over the VSE view. It jumps with the green playhead between each cut (start/end of strips). The hotkey E (while hovering over the timeline view) sets the Scene.frame_end (the "End: 250" box) to your current playhead position (Scene.frame_current). It works fine for me (but only with recent versions of Blender like 2.76/2.77a, this behaviour has been added not too long ago). – Samoth Jul 5 '16 at 8:18

Your problem - from a VSE point of view:

You want your End Frame Range to be set to your newly imported Footages length.

The solution:

While still hovering over the VSE view press PageUp.

Hover your mouse over your timeline and press E to match your End Frame with your Current frame. (Blenders Hotkeys are context sensitive)

Note:
Make sure, the function Use Preview Range is unchecked if you want your Scene Frame Range to be set accordingly for your final Render.

bpy.context.scene.frame_end = [area for area in bpy.data.screens.get(bpy.context.screen.name).areas.values() if area.type == 'CLIP_EDITOR'][0].spaces[0].clip.frame_duration