How to know if a link is a video? [duplicate] - url

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to determine if a given URL link is a video or image?
I'm building a forum and I want the facebook feature whereby when the user paste a video URL, i can automatically know its a video and display it differently??

You can check it's "mime type".

The way Facebook implemented requires quite a lot of computing power and may not be suitable for small scaled website.
After the user input the video URL, Facebook will proceed to determine if the URL belongs to a known host (such as Youtube, CollegeHumour). If the URL does not belong to a known host, Facebook will proceed to retrieve the page and determine the video parameters from the <meta> tags, according to what Facebook defines them to be.
However to keep things easy for you, maybe your forum can determine that if the URL is from Youtube, you can use Youtube's embed code to display the video.
This does not deal with MIME types, or video files directly. If it is video files, you will still need to proceed to fetch the headers of the video file, and determine what plugin or Flash player should display the video.

Related

For YouTube video, how to automatically display interactive transcript?

YouTube supports interactive-transcripts, using both machine-generated and user-uploaded transcripts. This is very useful for hearings, lectures, speeches, and educational videos where a visitor might want to read along or jump around. For example in this video:
https://www.youtube.com/watch?v=IY3U2GXhz44
The visitor can click on "...More" and then "Transcript" to view the interactive-transcript.
How does a video owner make that hidden feature automatically open for visitors? I cannot find any documented method for doing that through the API for either embed or linked videos. Is there an undocumented method in the API, or a URL parameter like "&action-panel-transcript=true" that works the way I'd expect it to?
As for url parameter, you can try adding &cc_load_policy=1 behind the rel=0 if it's an embedded video or &yt:cc=on at the end of the url if it's a link to the video.
Source: https://www.makeuseof.com/tag/force-subtitles-embedded-youtube-video/

Uploading a video to youtube from my swift app

I've been asked to integrate videos into an existing app which previously only let users upload posts with images.
I don't want to host the videos on my own server for the following reasons:
Server Bandwidth
File Size Limits and Storage Space
Slow-Loading Video or Unexpected Pauses During Playback
Issues with converting to specific formats
Piracy
Based off this article:
https://www.wp101.com/10-reasons-why-you-should-never-host-your-own-videos/
So I tried to research into where I could host the files and then I would simply have to store the URL in my db and use a video player to stream the content.
Vimeo and youtube seemed to be the main options I could find.
I'm wondering how best to implement, would I make use of a youtube API and on successful upload, grab the link and upload to my own server? I'm concerned this may be a long process for the end user.
Another problem is I can't see any swift examples (ZERO obj-c experience) of making the http request but perhaps it is still possible but I'd just have to write the code myself? I'm wondering if anyone has implemented anything like this already as I can't find any examples.
Looking at this question:
How do I upload a video to YouTube from within an iOS application?
None of the links in the comments work and the answer directs to the youtube 2.0 API and I'm concerned that this is now deprecated.
Any advice appreciated!

YouTube live streaming captions - more than one language

I'm currently live streaming a tv channel (beta phase yet) using YouTube.
How do I add captions in more than 1 language for a live stream (with POST caption URL)?
Even using just one language captions, how can I change the language? (The only option to the user - on web or app - is "EN" even if the caption is in other language)
When using POST approach do send captions on live streams how/where to set/define duration of each subtitle?
Please don't refer this url link. I know it already.
AFAIK you can do only one language, if any at all. I have tried using the POST method YouTube describes on the page you link to - without success. Only get
Result 299: "Error donwloading [...] Can't parse HTTP POST body."
Tried searching all kinds of support forums, but it seems no one has any advice and YouTube never replies to questions related to live caption. Including here...
According to the docs on contentDetails.closedCaptionsType, you can embed captions in your video stream using the option closedCaptionsEmbedded and provide EIA-608 and/or CEA-708 formatted captions in your video from your encoder.
Sending multiple caption tracks muxed with your video with different languages specified by the "Language" tag on the caption stream should allow the user to switch between different captions in the web player.

Programatically adding annotations to YouTube videos

I have a project which is using the YouTube API to upload videos to YouTube.
One of the requirements is to be able to add annotations to the video, either at the time of upload, or afterwards. The annotation will contain some text to display, and a link to a URL.
Does anybody know if this is possible using the YouTube API, or some other method.
If it is possible, please provide links with details of how to do this.
Thanks
Gavin
No, this was answered already here:
Manage YouTube annotations through YouTube API
If you want to do it, you'd have to do it via a browser plug-in or other tricky way such as how YouTubeAnnotations.com does it.

Rails 3 different types of embeds under one controller

I have a rails app that I am looking into implementing videos. I know how embed the videos etc but I am confuse on how to do something like this.
I would like a user to have videos. When a users goes to add a video I want to give them the option of embedding a youtube video or a vimeo video(Should I write out if statement?) without having 2 completely different urls.
For example
If user embeded a youtube video url would look like this
mysite.com/videos/1/youtube/1
If a user were to add video it would look like this
mysite.com/videos/1/youtube/new
What I would like to implement is the user would go to video and then have the choice of choosing vimeo or youtube. Ater the user has input the url of the video and click create i would like urls to look like(whether its youtube, vimeo or uploaded from cpu)
mysite.com/videos/1
mysite.com/videos/new
What is the best way to approach this? Would it be nested resources then rewrite the url paths?
There are many solutions to this problem and I ended up using gem called oembed to handle processing of embedded files from youtube, vimeo etc.
figured this out forgot to update question. Check out solution here
Vaildate 1 field with mutiple options
From a RESTful perspective, the resource that you are requesting is the video. The mechanism of how that video is requested (whether that is Vimeo or Youtube) is irrelevant from the perspective of identifying the resource. The format of the video being requested is simply a parameter of the request. In your controller, you can decide how to render the video based on the parameters (or potentially other aspects of the request header). Your video should clearly exist as a resource as
mysite.com/videos/1
Let the parameters or the HTTP request dictate how that is rendered.

Resources