youtube 4k video not list from youtube api - youtube-api

When I try to use the 4k video from youtube, I always can not get such high resolution stream. The highest resolution is HD.
for example:
https://www.youtube.com/watch?v=tdwbYGe8pv8
I can only get below profile:
----> 22/1280x720/9/0/115
----> 43/640x360/99/0/0
----> 18/640x360/9/0/115
----> 5/426x240/7/0/0
----> 36/426x240/99/1/0
----> 17/256x144/99/1/0
That means the highest resolution is 1280x720 but not 4k video.
Anyone know if it's really a issue or I need to use other API to get 4k video?

One possible solution:
Install youtube-dl tool
brew install youtube-dl
Run below command to query stream information:
youtube-dl -F http://www.youtube.com/watch?v=TMwpbfxY_Gc --verbose
output:
[info] Available formats for iNJdPyoqt8U:
format code extension resolution note
140 m4a audio only DASH audio 129k , m4a_dash container, aac #128k (44100Hz), 4.72MiB
171 webm audio only DASH audio 171k , audio#128k (44100Hz), 5.01MiB
141 m4a audio only DASH audio 256k , m4a_dash container, aac #256k (44100Hz), 9.38MiB
160 mp4 256x144 DASH video 111k , 15fps, video only, 4.01MiB
278 webm 256x144 DASH video 146k , webm container, VP9, 15fps, video only, 3.42MiB
133 mp4 426x240 DASH video 250k , 30fps, video only, 8.99MiB
242 webm 426x240 DASH video 301k , 30fps, video only, 6.73MiB
243 webm 640x360 DASH video 539k , 30fps, video only, 12.45MiB
134 mp4 640x360 DASH video 607k , 30fps, video only, 14.59MiB
244 webm 854x480 DASH video 985k , 30fps, video only, 22.64MiB
135 mp4 854x480 DASH video 1112k , 30fps, video only, 28.84MiB
247 webm 1280x720 DASH video 1933k , 30fps, video only, 45.20MiB
136 mp4 1280x720 DASH video 2219k , 30fps, video only, 56.87MiB
248 webm 1920x1080 DASH video 3244k , 30fps, video only, 76.72MiB
137 mp4 1920x1080 DASH video 4191k , 30fps, video only, 109.25MiB
264 mp4 2560x1440 DASH video 10096k , 30fps, video only, 275.62MiB
271 webm 2560x1440 DASH video 13837k , 30fps, video only, 245.05MiB
266 mp4 3840x2160 DASH video 22550k , h264, 30fps, video only, 771.23MiB
138 mp4 3840x2160 DASH video 24322k , 30fps, video only, 573.82MiB
313 webm 3840x2160 DASH video 26495k , VP9, 30fps, video only, 477.05MiB
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
43 webm 640x360
18 mp4 640x360
22 mp4 1280x720 (best)
Run below command to download the video (138) and audio (141)
youtube-dl -f 138+141 https://www.youtube.com/watch?v=iNJdPyoqt8U
Then you will get the 4k video file.

<...> 1080p support is gone - youtube removed 1080p downloads, only DASH would work - and we need a other way to get 1080p and above.
https://github.com/rg3/youtube-dl/issues/1261#issuecomment-26554531

Related

Capture full-range/lossless rgb frame from capture card that supports NV12 and YUYV output

I am trying to make a program which captures an image, then i need to compare captured image and the input data which i displayed, both should matc pixel by pixel
Here are the details of my capture card
$ v4l2-ctl --list-formats-ext -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'NV12' (Y/CbCr 4:2:0)
Size: Discrete 3840x2160
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 2560x1440
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.017s (60.000 fps)
[1]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 2560x1440
Interval: Discrete 0.020s (50.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.017s (60.000 fps)
[2]: '' (30313050-0000-0010-8000-00aa003)
[3]: '' (e436eb7e-524f-11ce-9f53-0020af0)
$ v4l2-ctl --all
Driver Info:
Driver name : uvcvideo
Card type : ITE HDMI 4K+ Bridge: ITE HDMI 4
Bus info : usb-0000:00:14.0-6
Driver version : 5.18.0
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 1920/1080
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 3840
Size Image : 4147200
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: Rec. 709
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 1920, Height 1080
Default : Left 0, Top 0, Width 1920, Height 1080
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 60.000 (60/1)
Read buffers : 0
I have tried using various methods opencv but ffmpeg came the closest
With below command i am able to get good results but not what i want
ffmpeg -y -f v4l2 -pix_fmt NV12 -video_size 1920x1080 -i /dev/video0 -pix_fmt bgra -frames:v 10 webcam%03d.bmp
Reference Image
RGB of Reference image
RGB of captured image
Note :- I am able to capture fine with Aforge on windows, but not with ffmpeg on linux.
Would like to know if anyone has already got solution to this.
Thanks in advance.
We have to mark the input as BT.709 with "TV Range":
ffmpeg -y -f v4l2 -pix_fmt nv12 -video_size 1920x1080 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -i /dev/video0 -pix_fmt bgra -frames:v 10 webcam%03d.bmp
Marking the input color format as BT.709:
By default FFmpeg assumes BT.601 color format, and the input video applies BT.709 color format, so we have to mark the video as BT.709 using -color_primaries bt709 -color_trc bt709 -colorspace bt709 arguments.
When the input color format is BT.709, and FFmpeg convert it as it were BT.601, the result is wrong output colors.
Marking the range as "TV Range":
By default FFmpeg assumes assumes "Limited Range" (TV range), but we may add -color_range tv to be sure.
Note:
"TV Range" applies "Limited range" - the range of Y color channel is [16, 235] (U and V rane is [16, 240]).
(opposed to "Full range" or "PC Range" where YUV range is [0, 255]).
For reproducing the issue, we may use synthetic video (instead of camera).
Create a reference image:
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=1:duration=1 -pix_fmt bgra ref%03d.bmp
Create NV12 raw frame in BT.709, "Limited Range" (TV Range):
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=1:duration=1 -vf scale=out_color_matrix=bt709:out_range=tv -pix_fmt nv12 -f rawvideo in.nv12
Convert the raw frame to BMP without marking the color format and range (getting wrong colors):
ffmpeg -y -f rawvideo -pix_fmt nv12 -video_size 192x108 -i in.nv12 -pix_fmt bgra -frames:v 1 wrong_colors_out%03d.bmp
Convert the raw frame to BMP with marking the color format and range (getting correct colors):
ffmpeg -y -f rawvideo -pix_fmt nv12 -video_size 192x108 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -i in.nv12 -pix_fmt bgra -frames:v 1 out%03d.bmp
Ordered left to right:
Reference image, "wrong colors" and "correct colors":

FFMPEG: How to convert GIF to MP4 that can be played on iOS?

I'm stuck with LOSSLESS encoding GIF to MP4 that can be played on iOS. The resulting MP4 can be played in default players on Android and Windows, but not on iOS. It's still a valid video that can be played in VLC for iOS, but not in the default player in Files. Thanks for any suggestions!
ffmpeg.exe -stream_loop 10 -f gif -i sample.gif -vf scale=256:256:flags=neighbor -crf 0 output.mp4 -y
GIF sample

Convert cropped images to gif with imagemagick : size conflict

I want to create an animated gif, I thus use this command :
convert -delay 50 --loop 0 cropped*.png animated.gif
where the cropped*.png are images that have been previously cropped from 1920x1080 size images with the command :
convert -crop 1105x441+92+168 source-1.png cropped-1.png
The command display -verbose gives this result :
PNG 1105x441 1920x1080+92+168
The problem is that the resulting gif, when played with eog or in any presentation software (libreimppress, etc) have the size 1920x1080 and not 1105x441. And I can't figure out why.

How to detect if video file is pure static?

I have a collection of analog video recordings. About 10% of the files are entirely static. How could I programmatically look at all files and delete the files that contain mostly static?
The following utilities have command line options to analyze video, however none have built in functionality to detect the absence of video content.
ffmpeg
ffprobe
HandBrake
I've tried using ffmpeg to export still images and then use image magick to compare the difference between those images. Unfortunately, the difference between an image of static, and actual video content returns nearly the same difference percentage. (9% vs 7%)
ffmpeg -ss 00:30 -i PICT0050.AVI -vframes 1 -q:v 2 output1.jpg
magick compare -metric PSNR output1.jpg output2.jpg diff.jpg
9.2191
magick compare -metric PSNR output1.jpg output3.jpg diff.jpg
7.70127
Comparing sample 1 with sample 2 results in 9% difference
Comparing sample 1 with sample 3 results in 7% difference
Sample 1
Sample 2
Sample 3
Sample 4
Sample 5
Sample 6
Sample 7
It looks like the static images are black and white without any colour - so I would look at the mean saturation and if it is low/zero, I would assume they are static. So, in bash and assuming your images are named sampleXXX.jpg:
for f in sample*jpg; do
convert "$f" -colorspace HSL -channel S -separate -format '%M avg sat=%[fx:int(mean*100)]\n' info:
done
Sample Output
sample1.jpg avg sat=0
sample2.jpg avg sat=0
sample3.jpg avg sat=21
sample4.jpg avg sat=0
sample5.jpg avg sat=39
sample6.jpg avg sat=31
which suggests that samples 1,2 and 4 are static.
Another way is to look at the amount of edges using Imagemagick to rank the amount of noise. The noise images will have more edges.
for img in *; do
edginess=`convert $img -edge 1 -scale 1x1! -format "%[fx:mean]" info:`
echo "$img $edginess"
done
1bidV.jpg 0.0472165
3FJUJ.jpg 0.275502 <---- noise image
QpQvA.jpg 0.332296 <---- noise image
b4Gxy.jpg 0.0428422
gQcXP.jpg 0.0437578
vF1YZ.jpg 0.322911 <---- noise image

How to make an animated gif loop twice in imagemagick?

I need to make an animated gif that plays all of its frames twice before stopping. It might seem like a simple thing to do, but for some reason when I set the -loop flag to 2, it plays three times, whereas when I set it to 1, it plays only once. so:
#this will play once then stop
convert -size 300x600 -delay 50 frame1.png -delay 50 frame2.png -loop 1 animation.gif;
#this will play three times then stop
convert -size 300x600 -delay 50 frame1.png -delay 50 frame2.png -loop 2 animation.gif;
How to make it play twice?
I would say that this is a bug in ImageMagick. As a workaround, I can only suggest you list your frames twice and set -loop to 1, like this:
convert -size 300x600 -delay 50 frame1.png frame2.png frame1.png frame2.png -loop 1 animation.gif

Resources