Asked  6 Months ago    Answers:  5   Viewed   37 times

I was using YouTube videos for my test and I was wondering how can I get the information of bit-rate of the played video?

I used 2 methods to know the information about the bit-rate but didn't get any information.

1. Right-click on a video and choose "Stats for nerds".
2. ffmpeg -i input_video -f ffmetadata metadata.txt

I don't know if by doing the right click on the video and then properties, then details would give me the correct way of showing the bit-rate.

Any suggestions?

 Answers

88

Most YouTube video use adaptive bit rate (ABR) format streaming which means that there is not just a single bit rate.

For ABR multiple bit rate versions of the video are created and each one is broken down into equal length (by time) chunks - e.g. 10 second chunks.

The client player is then able to select the next chunk from the most appropriate bit rate stream for the current network conditions - if the network gets busy it can drop down to a lower bit rate for the next chunk and visa versa if the network is good.

So there is not really the concept of a single bit rate for the whole video, but different bit rates for each chunk that is downloaded (although in practice if you have a good connection it should work up to the top bit rate and stay there).

As you say, you can see a visualisation of this on YouTube by right clicking and looking at the 'stats for nerds' option - see example below:

enter image description here

You can also see the available resolutions, and force the player to select a single one by clicking on the 'wheel' in the bottom right hand corner. As a general rule, a higher resolution will need a higher number of bits and hence mean a higher bit rate,

To see a more detailed view of the video buffers and the bitrate, some players provide a demo view with a representation of the change over time - see below an example from the DASH IF reference player (https://reference.dashif.org/dash.js/latest/samples/dash-if-reference-player/index.html):

enter image description here

Tuesday, June 1, 2021
 
osondoar
answered 6 Months ago
54

Here's a example using the YouTube RSS feeds, simplexml_load_file, parse_url, and parse_str.

<?php

$id = NULL;
$username = 'YouTube';

$xml = simplexml_load_file(sprintf('http://gdata.youtube.com/feeds/base/users/%s/uploads?alt=rss&v=2&orderby=published', $username));

if ( ! empty($xml->channel->item[0]->link) )
{
  parse_str(parse_url($xml->channel->item[0]->link, PHP_URL_QUERY), $url_query);

  if ( ! empty($url_query['v']) )
    $id = $url_query['v'];
}

echo $id; // Outputs the video ID.
Wednesday, March 31, 2021
 
Yrtymd
answered 9 Months ago
34

This is a bug in the interplay between youtube-dl and ffmpeg, caused by the lack of extension in the filename. youtube-dl calls ffmpeg. Since the filename does not contain any extension, youtube-dl asks ffmpeg to generate a temporary file mp3. However, ffmpeg detects the output container type automatically by the extension and fails because mp3 has no extension.

As a workaround, simply add %(ext)s in your filename template:

'outtmpl': u'%(id)s.%(ext)s',
Friday, August 6, 2021
 
zIs
answered 4 Months ago
zIs
61

_isFullScreen inside public void onFullscreen(boolean _isFullScreen) is state of full screen, if it's true it means player is gone to full screen mode and if it is false it means the player is switched back from full screen mode and this listener is called both times when you go to full screen mode and come back from full screen mode with true and false value respectively. You should modify code as below

videoPlayer.setOnFullscreenListener(new OnFullscreenListener() {

        @Override
        public void onFullscreen(boolean _isFullScreen) {
            fullScreen = _isFullScreen;
            if(_isFullScreen){
            textView.setVisibility(View.GONE); // hide text as player switched to full screen mode
            } else {
            textView.setVisibility(View.VISIBLE); // show text as player switched back from full screen mode, changing visibility here instead of onBackPressed have advantage that even if user switches back from full screen mode using control button on player instead of press back button the text will still come to visible
            }
        }
    });

while your onBackPressed listener will be just used for switching player back from full screen mode if player was in full screen mode when back button was pressed;

@Override
public void onBackPressed() {
if (fullScreen){
    videoPlayer.setFullscreen(false);

} else{
    super.onBackPressed();
}
}
Saturday, August 21, 2021
 
SJain
answered 4 Months ago
67

Here's the general procedure:

1) Get the "watch History" playlist of a given user's channel (as a channel ID is the key to getting user info). Note that this will ONLY work when a user is authenticated via oAuth2.

https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key={YOUR_API_KEY}

With that response, there should be a "watchHistory" playlist ... take it and call the playlistItems endpoint:

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=HLTFxEo9ofKM2Siifxoy5V_A&key={YOUR_API_KEY}

Unfortunately, many users are reporting there's a bug in the watch history playlist through the API right now:

https://code.google.com/p/gdata-issues/issues/detail?id=4642

So your mileage may vary.

Saturday, September 4, 2021
 
Ultimater
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share