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!

Andrew
  • 1,637
  • 2
  • 11
  • 4

7 Answers7

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).

Joan
  • 4,079
  • 2
  • 28
  • 37
mystic11
  • 2,119
  • 1
  • 12
  • 3
  • 1
    Nice. I've been waiting for Youtube to allow this. – PHearst Jan 15 '13 at 22:39
  • Perfect use case: http://youtube.googleapis.com/v/uMjIvhblxFY&start=52.5&end=80.2&version=3&modestBranding=1&rel=0&showinfo=0&autoplay=1 – Ronnie Overby May 11 '13 at 21:06
  • 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 '14 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 '14 at 11:03
  • Is there a way to load up HTML 5 player with the &end parameter – Shan Eapen Koshy May 17 '15 at 11:10
  • 3
    This shit changes all the time. Read the API https://developers.google.com/youtube/documentation/ – PHearst Aug 10 '15 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](http://stackoverflow.com/a/19507833) – danicotra Oct 29 '16 at 11:58
  • 1
    This worked for me: https://www.youtube.com/embed/xSdbFNwWS28?start=118&end=119. Thanks @brasofilo – smc May 17 '17 at 10:15
  • 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 '18 at 16:41
  • Note that not all videos allow you to embed. For example, https://www.youtube.com/embed/016LXFHpFCk?start=60&end=65 will result in "Video unavailable" whereas https://www.youtube.com/watch?v=016LXFHpFCk&t=60 works. – wisbucky Aug 16 '20 at 05:27
  • The `v` doesn't work for me today but `embed` does. Also, `autoplay=1` is ignored. So this worked: `https://www.youtube.com/embed/x4n1bORDkz0?start=207&end=230` – DSlomer64 Dec 26 '20 at 15:52
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.

Community
  • 1
  • 1
ahcox
  • 9,349
  • 5
  • 33
  • 38
  • How to give time in minutes and seconds? – NEO Jun 21 '14 at 06: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 '15 at 18:42
  • 1
    Thanks for the http://www.infinitelooper.com/?v=WA8sLsM3McU&p=n#/15;19 - just what i was looking for – d.popov Jan 19 '17 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 01 '20 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 02 '20 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

T.Todua
  • 53,146
  • 19
  • 236
  • 237
  • 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. – Aaron Thoma Jun 24 '15 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

Komal12
  • 3,340
  • 4
  • 16
  • 25
PHearst
  • 751
  • 6
  • 29
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

tramper
  • 61
  • 4
  • This is identical to the top voted answer above. https://stackoverflow.com/a/11422551/857012 – Rag Nov 29 '18 at 09: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). – Scott Gartner Feb 06 '20 at 00: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

Anthony De Souza
  • 544
  • 5
  • 10
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

Nikhil Nayyar
  • 319
  • 4
  • 4