162

I'm trying to figure out how I can specify a custom end time for an embedded YouTube video. I know that I can customize the start time by adding &start=30, but I haven't seen anything relating to the end time.

I need to be able to do this for a web app I'm building, so if there is no way provided by YouTube, how might I be able to accomplish this anyway?

I've skimmed over the documentation to no avail. Thanks!

1

7 Answers 7

211

I just found out that the following works:

https://www.youtube.com/embed/[video_id]?start=[start_at_second]&end=[end_at_second]

Note: the time must be an integer number of seconds (e.g. 119, not 1m59s).

11
  • 41
    Yeah it does work. Also, version=3 may not be necessary. Make sure you use the "API" form of the link, like this: https://www.youtube.com/v/7qkmGjWtG0w?start=840&end=1240&autoplay=1, not the usual form, which starts like this: https://www.youtube.com/watch?v=7qkmGjWtG0w.
    – Kai Carver
    Sep 16, 2014 at 10:53
  • 2
    however it seems to return a Flash/SWF stream... Which works fine for me on Chrome/Windows and IE, but not on Firefox.
    – Kai Carver
    Sep 16, 2014 at 11:03
  • 3
    This shit changes all the time. Read the API developers.google.com/youtube/documentation
    – PHearst
    Aug 10, 2015 at 17:55
  • 5
    You can try even using this form: http://www.youtube.com/embed/BmOpD46eZoA?start=36&end=65 as suggested on this Ibrahim Ulukaya answer to a similar question
    – danicotra
    Oct 29, 2016 at 11:58
  • 3
    Is there a way to do this if you are NOT embedding the video? I just want a regular link that I can share with a start and end time. The video that I want to share does not allow embedding.
    – JoeMjr2
    Feb 14, 2018 at 16:41
67

I tried the method of @mystic11 ( https://stackoverflow.com/a/11422551/506073 ) and got redirected around. Here is a working example URL:

http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3

If the version=3 parameter is omitted, the video starts at the correct place but runs all the way to the end. From the documentation for the end parameter I am guessing version=3 asks for the AS3 player to be used. See:

end (supported players: AS3, HTML5)

Additional Experiments

Autoplay

Autoplay of the clipped video portion works:

http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&autoplay=1

Looping

Adding looping as per the documentation unfortunately starts the second and subsequent iterations at the beginning of the video: http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&loop=1&playlist=WA8sLsM3McU

To do this properly, you probably need to set enablejsapi=1 and use the javascript API.

FYI, the above video looped: http://www.infinitelooper.com/?v=WA8sLsM3McU&p=n#/15;19

Remove Branding and Related Videos

To get rid of the Youtube logo and the list of videos to click on to at the end of playing the video you want to watch, add these (&modestBranding=1&rel=0) parameters:

http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&autoplay=1&modestBranding=1&rel=0

Remove the uploader info with showinfo=0:

http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&autoplay=1&modestBranding=1&rel=0&showinfo=0

This eliminates the thin strip with video title, up and down thumbs, and info icon at the top of the video. The final version produced is fairly clean and doesn't have the downside of giving your viewers an exit into unproductive clicking around Youtube at the end of watching the video portion that you wanted them to see.

5
  • How to give time in minutes and seconds?
    – NEO
    Jun 21, 2014 at 6:04
  • 1
    www.youtube.googleapis.com is giving me a ssl error whilst youtube.googleapis.com is working. However, there seems to be a state problem if you already have seen the video before and left it at a certain point the player ignores the specified start value and jumps right to where you left watching
    – worenga
    Sep 20, 2015 at 18:42
  • 1
    Thanks for the infinitelooper.com/?v=WA8sLsM3McU&p=n#/15;19 - just what i was looking for
    – d.popov
    Jan 19, 2017 at 12:29
  • I just tried https://www.youtube.com/embed/[video_id]?start=[start_at_second]&end=[end_at_second] and it didn't work. https://www.youtube.com/embed/[video_id]&start=[start_at_second]&end=[end_at_second] did. Note the &start=.
    – hmj6jmh
    Mar 1, 2020 at 17:19
  • @hmj6jmh That is annoying. It means youtube has changed in a way which has shoved & characters which are conventionally query delimiters into the path part of the URI.
    – ahcox
    Mar 2, 2020 at 18:21
7

Use parameters(seconds) i.e. youtube.com/v/VIDEO_ID?start=4&end=117

Live DEMO:
https://puvox.software/software/youtube_trimmer.php

1
  • This is convenient since you can visually select the times instead of calculating the seconds! While it doesn't seem to work in the example on the bottom, the generated link does work. Jun 24, 2015 at 12:19
4

Youtube doesn't provide any option for an end time, but there alternative sites that provide this, like Tubechop. Otherwise try writing a function that either pauses video/skips to next when your when your video has played its desired duration.

OR: using the Youtube Javascript player API, you could do something like this:

function onPlayerStateChange(evt) {
    if (evt.data == YT.PlayerState.PLAYING && !done) {
        setTimeout(stopVideo, 6000);
        done = true;
    }
}

Youtube API blog

3
  • 2
    mystic11's answer worked perfectly for me just now. I wonder whether it's reliable.
    – Matthew
    Nov 29, 2012 at 18:09
  • 3
    This is wrong Youtube doesn't provide any option for an end time, but . Rest is good.
    – Null Head
    Jul 29, 2015 at 3:25
  • 2
    @NullHead You're looking at something written in 2011. Things change, man.
    – PHearst
    Aug 10, 2015 at 17:55
1

Today I found, that the old ways are not working very well.

So I used: "Customize YouTube Start and End Time - Acetrot.com" from http://www.youtubestartend.com/

They provide a link into https://xxxx.app.goo.gl/yyyyyyyyyy e.g. https://v637g.app.goo.gl/Cs2SV9NEeoweNGGy9 Link contain forward to format like this https://www.youtube.com/embed/xyzabc123?start=17&end=21&version=3&autoplay=1

2
  • This is identical to the top voted answer above. stackoverflow.com/a/11422551/857012
    – Rag
    Nov 29, 2018 at 9:36
  • Thanks! I'm assuming (maybe hoping is a better word) this will be a longer-lasting solution than the top voted answer because they can update it when YouTube changes their URL formats (the top-voted answer doesn't work at the moment because of changes to the format). Feb 6, 2020 at 0:07
1

I was just trying to look up how and found there is a CLIP feature now added by Youtube right under the video that I had never noticed before!  clip video link

0

I use this signature:

youtube.com/embed/[YOUR_VIDEO_ID]?start=[TIME_IN_SEC]&end=[TIME_IN_SEC]&autoplay=1

https://www.youtube.com/embed/2EWejmkKlxs?start=1230&end=1246&autoplay=1

Not the answer you're looking for? Browse other questions tagged or ask your own question.