How to download and get video informations at the same time in youtube-dl? - youtube-dl

In youtube-dl cli, How can i get information about the video (in json output) while the video beign downloaded by the app?
When i use this command:
youtube-dl https://www.youtube.com/watch?v=jNQXAC9IVRw
It only shows me output filename, But what a about the duration, resolution, etc... ?
I do this with 2 requests, But is it possible in on go?
It would be great if it dump the video meta data into a json file as well as output filename, Because i also struggling to pragmatically get the path of downloaded file (i have to use regex)

Just add --print-json in your command line.
youtube-dl --print-json https://www.youtube.com/watch?v=jNQXAC9IVRw
This outputs a big JSON, while video is still downloading

Related

Is it possible to not change the file created date when embedding thumbnail using youtube-dl?

I was trying to download videos from YouTube using youtube-dl with the following:
youtube-dl -f "bestvideo+bestaudio" --merge-output-format mp4 --add-metadata --embed-thumbnail {video URL}
I want to have both the thumbnail embedded in the output file and also the upload date of the YouTube video written as the "Date created" of the output file.
I was able to write the upload date of the video on YouTube to the output file as the "Date created" by using --add-metadata {URL}.
But if I was also embedding the thumbnail to the output using --add-metadata --embed-thumbnail {URL}, the "Date created" and "Date modified" of the output file becomes the time the video thumbnail was written to the disk (aka 'now') but not the upload date of the video on YouTube.
Is there any way to get the output I want to get by using youtube-dl?
Save the date created and/or the date modified of the downloaded video.
Add metadata for thumbnail
Set the created and/or modified date using touch. To see the help for touch, type:
$ man touch
This is a youtube-dl bug, here is the relevant issue on GitHub.
Unfortunately, youtube-dl is quite bad at accepting pull requests and bug fixes, and many such bugs remain. yt-dlp (an actively maintained youtube-dl fork) doesn't seem to have this bug, so that's what I switched to now. (yt-dlp is also able to embed thumbnails to mkv files, something youtube-dl couldn't do, as well as other bugfixes and features.)

Best audio and video quality not working in youtube-dl

I tried the following command in order to get the best video and audio quality (I can also avoid to write --format best because from the documentation I read that this is the default setting):
youtube-dl.exe --format best https://www.youtube.com/watch?v=7wfUUZvybPY
and I got a video.mp4 with the following characteristics:
I downloaded the same video by using 4k Video Downloader and I got:
How can I get the same result also by using youtube-dl?
You can parse all formats available with:
youtube-dl.exe -F https://www.youtube.com/watch?v=7wfUUZvybPY
Look at first column, "format code". For this video, best option is:
youtube-dl --format 315 https://www.youtube.com/watch?v=7wfUUZvybPY for 3440x1440 video, and
youtube-dl --format 140 https://www.youtube.com/watch?v=7wfUUZvybPY for 129kbit audio.
Then, with ffmpeg, you can merge that two streams in your preferred container (you can find many answers here in Stackoverflow).
For very high bitrates there isn't a file already merged available on YouTube, ffmpeg is a crucial tool for this type of conversions!

Resume youtube-dl download for MP3s

I am trying to download an entire playlist using youtube-dl, this way :
youtube-dl -citwx --audio-format mp3 --audio-quality 320K <playlist>
I believe it extracts the audio without having to download the actual video.
The problem is that I want to be able to stop and resume this download, which is impossible using only these arguments. However, if I add the -k option, the program will download the original videos (which takes a lot longer), convert them, and keep the original files (which takes a lot more space).
Is there any way for me to resume such a transfer without having to download the actual video files?
Sounds to me like there is no way. If it takes just the audio, seems like it needs to be done in one go. Maybe try writing a script that takes the file path and url as arguments, and pass those into a youtube dl script, then when that's done also deletes the video file. takes more time that way, but the space issue is gone.
I found the answer while browsing the man page :
--download-archive FILE Download only videos not listed in the
archive file. Record the IDs of all
downloaded videos in it.
youtube-dl -citwx --download-archive progress.txt --audio-format mp3 --audio-quality 320K <playlist> is the correct command.
A note, --title is deprecated. The correct command should be youtube-dl -ciwx -o "%(title)s.%(ext)s" --download-archive progress.txt --audio-format mp3 --audio-quality 320K <playlist>

Finding Bitrate of video file

How can we find bitrate of a video file in c++? Can we do this by file handling?
Thanks
Install FFMEPG it will give you all the information related to the video
e.g.
ffmpeg -i filename.flv
If you want to implement such yourself you need to be able to read the video container format (Quicktime, ASF, AVI, Matroska etc) and try to find the bitrate from the metadata.
You can use ffprobe from the ffmpeg project to get the information about your video files and get a nice JSON ouput.
Check this answer for an example.

get metadata from jpg, dng and arw raw files

I was wondering if anyone new how to get access the metadata (the date in particular) from jpg, arw and dng files.
I've recently lost the folder structure after a merge operation gone-bad and would like to rename the recovered files according to the metadata.
I'm planning on creating a little C++ app to dig into each file and get the metadata.
any input is appreciated.
( alternatively, if you know of an app that already does this I'd like to know :)
Have you looked at the libexif project http://libexif.sourceforge.net/?
ok, so I did a google search (probably should have started with that) for "batch rename based on exif data arw dng jpg"
and the first page that popped up was the ExifTool by Phil Harvey
it supports recent arw and dng files, and with some command line magic I should be able to get it to do what pretty much what I want
exiftool -r -d images/%Y-%m-%d/%Y%m%d_%%.4c.%%e "-filename<filemodifydate" pics
-move files to folders (images/YYYY-MM-DD/) and rename files to YYYYMMDD_####.ext that are in pics folder(and subfolders)
hope this helps others
You should also try Adobe XMP SDK, which is great for its supported formats (JPEG, PNG, TIFF and DNG).