hls stream with ima in videojs codepan code example

Example 1: javascript stream youtube muisic in background

<script src="http://www.youtube.com/player_api"></script>

<div id="player" style="position: absolute; top: -9999px; left: -9999px;"></div>
<div id="info">loading...</div>
<script src="http://www.youtube.com/player_api"></script>
<script>
var info = document.getElementById('info');
function onYouTubePlayerAPIReady() {
  var player = new YT.Player('player', {
      videoId: 'gzeOWnnSNjg', // this is the id of the video at youtube (the stuff after "?v=")
      loop: true,
      events: {
          onReady: function (e) {
              info.innerHTML = 'video is loaded';
              e.target.playVideo();
          },
          onStateChange: function (event) {
              if (event.data === 1) {
                  info.innerHTML = 'video started playing';
              }
          }
      }
  });
  // you can do more stuff with the player variable
}
</script>

Example 2: how to transcode a video in python using ffmpeg

ffmpeg -i input.mkv -c:a copy -s hd720 output.mkv
This modifies the video to 1280x720 in the output, but you can set the width and height manually if you want:

ffmpeg -i input.mkv -c:a copy -s 1280x720 output.mkv
This produces the exact same output as the earlier command. If you want to set custom sizes in FFmpeg, please remember that the width parameter (1280) comes before height (720).

Tags:

Misc Example