LCF-AT Posted December 10, 2022 Share Posted December 10, 2022 Hi guys, so I'am using ffmpeg & youtube DL tools and still didn't find out how to manage the problem for multible parts. Just get it work to download any single part of a video etc. So in case of YT-DL its telling me this... https://github.com/yt-dlp/yt-dlp --download-sections REGEX Download only chapters whose title matches the given regular expression. Time ranges prefixed by a "*" can also be used in place of chapters to download the specified range. Needs ffmpeg. This option can be used multiple times to download multiple sections, e.g. --download-sections "*10:15-inf" --download-sections "intro" So I tried using the command more than one time like this.. --download-sections "*00:00-00:30" --download-sections "*05:00-05:30" ..to download first 30 seconds from start and next part from minute 5 also 30 seconds. Not working. I found this info... https://unix.stackexchange.com/questions/230481/how-to-download-portion-of-video-with-youtube-dl-command Native Way (YT-DLP) yt-dlp, the spiritual successor to youtube-dl, supports this w/ ffmpeg installed. It will ONLY download the section of video you specify, good for low bandwidth or long videos! Fastest It accepts timestamps or seconds: yt-dlp.exe --download-sections "*6:02-6:22" It will only download the section specified (to the nearest keyframe). Exact Key Frame If you need exact start / stop times (albeit slower): yt-dlp.exe --download-sections "*1:22:22-inf" --force-keyframes-at-cuts inf means to the end of the video. Sections Download a section titled "03. Symphony No. 6, Op. 68 (Pastoral): III. Allegro": yt-dlp.exe --download-sections "03.*" Multiple Sections Download multiple sections: yt-dlp.exe --download-sections "03.*" --download-sections "05.*" -o "%(title)s-%(section_title)s.%(ext)s" A Note About Speed This method downloads and transcodes pretty slow. It may be faster to just download the whole video and chop up w/ ffmpeg. I would definitely use this method for very long videos or very short segments. ...so maybe I do something wrong with the output. I tried using a template command like "-o "%(title)s.%(ext)s"" but if I understand it right then it will try to save both video parts under same title name & extension right. Just wanna ask whether anyone of you know this already how to download more than one video part from one video + combine the parts together using YT-dlp & or ffmpeg? greetz Link to comment Share on other sites More sharing options...
Hadits follower Posted December 11, 2022 Share Posted December 11, 2022 (edited) i have created a little project Edited December 11, 2022 by Hadits follower update 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted December 11, 2022 Author Share Posted December 11, 2022 Hi @Hadits follower, how should your video help to answer my questions? Maybe you did not understand my questions about how to download parts/portions from a single online video (Youtube for example) using YT-dlp / ffmpeg and merge them together. Thats my main goal. So I found already out how to download more than one parts using yt-dlp by using the right output template like this... -o "%(epoch-3600>%H-%M-%S)s.%(title)s.%(ext)s" ...but the problem here is that I just can set Hour/Minute/Second only and no milli seconds. Now in this case I get offten the message that file X was already downloaded because it does hit the same timestamp like the first file got. I still found no other possible output variable I could use to get a unique filename out like an normal counter 1,2,3,4 etc. https://github.com/yt-dlp/yt-dlp/tree/2022.11.11#output-template Also in case when it works and I got all parts out then I need to merge them and delete the single parts. I found this command... --postprocessor-args NAME:ARGS Give these arguments to the postprocessors. Specify the postprocessor/executable name and the arguments separated by a colon ":" to give the argument to the specified postprocessor/executable. Supported PP are: Merger, ModifyChapters, SplitChapters, ExtractAudio, VideoRemuxer, VideoConvertor, Metadata, EmbedSubtitle, EmbedThumbnail, SubtitlesConvertor, ThumbnailsConvertor, FixupStretched, FixupM4a, FixupM3u8, FixupTimestamp and FixupDuration. The supported executables are: AtomicParsley, FFmpeg and FFprobe. You can also specify "PP+EXE:ARGS" to give the arguments to the specified executable only when being used by the specified postprocessor. Additionally, for ffmpeg/ffprobe, "_i"/"_o" can be appended to the prefix optionally followed by a number to pass the argument before the specified input/output file, e.g. --ppa "Merger+ffmpeg_i1:-v quiet". You can use this option multiple times to give different arguments to different postprocessors. (Alias: --ppa) ...somehow it should work using it but I got no success yet. Somehow tricky to find this out when the yt-dlp guys not creating any example commandlines. I think I will ask them later today. greetz Link to comment Share on other sites More sharing options...
Hadits follower Posted December 12, 2022 Share Posted December 12, 2022 (edited) let me explain . i dont know if you understand my english . 1st, i actually spend much time to fix speed code , as we see its so slow to download non ad emulated and finally i have fixed it to download pc version of video , and i have fixed that time only ytdlp can download restricted video with fast speed there is no other project exist at my watch history , but unfortunately i stopped worked on it because it is properly haram to download age restricted adult video and now i think i just can share it by like this what i have created , it is just share the experience of my journey in youtube, 2nd, i have posted here cause because i see u have posted in offtopic section, i know my post is nothing relation about ur post , but for me its something similar type , and i dont so that i will post to share my experience in a new thread it just a experience unless i am not sharing it , 3rd. may be u said that u r trying to download video like this => 1 hours video , download duration 2-10 min , 40-50 , 15-25 and then make it one by sequence was it may be u said or i may be didnt understood u sentence , i think Matroska is similar type of programs [may be] Edited December 12, 2022 by Hadits follower 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted December 12, 2022 Author Share Posted December 12, 2022 Hi @Hadits follower, hmm good ok but this was not my question to download restricted YT videos with full speed you know. So for this I'am using few age bypass scripts on YT to get access on them in browser or using YT-dlp itself etc. If you have a own project / github page then you can post it here too if you want. So in my case I just wanna download video parts / potions of one and the same video and merge them together to a new file and delete the left portion parts and I thought I could do this with one single command like & yt-dlp / ffmpeg itself. So I was triyng go on yesterday and I found a solution to download all parts seperated with an number counter by using the output value "autonumber". My command looks like this now... yt-dlp" -f best "$url" ^ --force-keyframes-at-cuts --download-sections "*00:00-00:30" --download-sections "*02:00-02:30" ^ -o "%(autonumber)s - %(title)s.%(ext)s" ...with or without using --force-keyframes-at-cuts command (with command it takes longer). Now I get all parts downloaded in seperated files and next step would be to merge them together. Somehow it should be doable with another adding YT-dlp command --postprocessor-args" with ffmpeg to make it work but how is the question. The documentation of that command is not so well or just too less. greetz Link to comment Share on other sites More sharing options...
whoknows Posted December 14, 2022 Share Posted December 14, 2022 @LCF-AT I dont read the whole^ if u have the video files on your disk, u can use direct the ffmpeg to merge the videos (create a txt list pass it to ffmpeg). stackoverflow.com/a/41387530 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted December 14, 2022 Author Share Posted December 14, 2022 @whoknows, read from ^-$. So I know that I can make a text file to concat & merge them together but I would like to make it work without any manually tasks as last step you know. greetz Link to comment Share on other sites More sharing options...
whoknows Posted December 14, 2022 Share Posted December 14, 2022 (edited) @LCF-AT I dont read the whole^ but here is the thing @ 1-there is a text file called urls.txt, put there the urls 2-there is a batch file test.bat yt-dlp_x86.exe --youtube-skip-dash-manifest --batch-file urls.txt REM once yt-dlp_x8.exe finishes REM this will add all segm*.ts filenames to mylist.txt for %%i in (segm*.ts) do echo file '%%i'>> mylist.txt REM Merge Files to all.mp4, according to mylist.txt ffmpeg -f concat -safe 0 -i mylist.txt -c copy all.mp4 Edited December 14, 2022 by whoknows add LCF tag! 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted December 14, 2022 Author Share Posted December 14, 2022 Hi again, I told you already that I'am looking for a easier method without creating any URLs & batch file n stuff etc you know. Main goal is to make all working at once with one commandline (not working yet). At the moment I made a small tool to drag all video parts I want into (Listview) where I can sort / move them like I want and to execute a merge process / command via button press what does execute ffmpeg concat similar like I did create in my "FFmpeg Quicky" app in the past. Will see whether I can find any better methods. greetz Link to comment Share on other sites More sharing options...
LCF-AT Posted December 15, 2022 Author Share Posted December 15, 2022 Hi, question: When I'am using ffmpeg to concat files together which I did split before (same file) then I don't get the same frame-rate in output file. Does anyone why and what the reason for this is? In my case I have a YT video with a fps of 30 and after concat of 3 parts I get a frame-rate of 30.63xxxx in my output file. I made a short video using just the copy mode to download 3 single video parts of same video using yt-dlp and then ffmpeg to concat those files also in copy mode (No Re-Encoding). Video_2022-12-15_230634_merged.mp4 greetz Link to comment Share on other sites More sharing options...
JochenX Posted December 16, 2022 Share Posted December 16, 2022 8 hours ago, LCF-AT said: question: When I'am using ffmpeg to concat files together which I did split before (same file) then I don't get the same frame-rate in output file. Does anyone why and what the reason for this is? In my case I have a YT video with a fps of 30 and after concat of 3 parts I get a frame-rate of 30.63xxxx in my output file. I made a short video using just the copy mode to download 3 single video parts of same video using yt-dlp and then ffmpeg to concat those files also in copy mode (No Re-Encoding). Hi, Do you want to download a full youtube video piece by piece and merge again?! 1 Link to comment Share on other sites More sharing options...
whoknows Posted December 16, 2022 Share Posted December 16, 2022 @LCF-AT you never can trust VLC media info. try mediaarea.net/en/MediaInfo or drop the video to a video editor ( premier / videopad / avidemux ) 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted December 16, 2022 Author Share Posted December 16, 2022 Hi guys, ja nee Jochen, just wanted to download few pieces of same YT video and merge them together on fly without to download the entire video. Lets say I wanna just cut out some highlights of any large live video set (24h +/-) which has tons of GB then I don't wanna download the whole video to make any highlight cut. Just wanna keep video on internet server and cut out all marked timestamps I wanna have and merge them at the end. Somehow I don't get it work at once by using YT-dlp itself so the last merge step I have to handle manually by myself using ffmpeg concat function as you can see in my video. Otherwise I could use ffmpeg itself & filter_complex to download video parts of same video and merge them together at once but when I have many parts then the filter_complex is getting really large whats also pretty unwieldy. So VLC is not the problem wk, all other tools are showing same frame-rate in my merged file (3 video parts of same video what has 30 fps). Just look at my image... ...and thats the problem when I do merge files of same video having same fps rate and at the end I get that strange fps rate out instead of 30 fps. In this case I need exact the same fps of original video which is 30 fps and not 30.x or lower etc. In this case I have to re-encode the video to make fps same to 30 or I have to choose re-encode mode when downloading the video parts with yt-dlp by adding the command "--force-keyframes-at-cuts" but I would like to use the simple copy mode without to re-encode. greetz 1 Link to comment Share on other sites More sharing options...
whoknows Posted December 16, 2022 Share Posted December 16, 2022 (edited) /--force-keyframes-at-cuts/ love it... -- look, naturally, FPS = frames per second if the video is 30fps and the merged is 30.936 as you understand how has this diff ? who put the extra frames ? noone, the mention switch answers the problem & most possible the YT-dlp is not merge it for this problem!!! -- conclusion : u r in desert alone & without water [edit] dudkduckit @ / ffmpeg merge videos result wrong framerate / check also with ffprobe - stackoverflow.com/q/61362471 Edited December 16, 2022 by whoknows adding urls 1 Link to comment Share on other sites More sharing options...
JochenX Posted December 16, 2022 Share Posted December 16, 2022 38 minutes ago, LCF-AT said: In this case I need exact the same fps of original video which is 30 fps and not 30.x or lower etc. In this case I have to re-encode the video to make fps same to 30 or I have to choose re-encode mode when downloading the video parts with yt-dlp by adding the command "--force-keyframes-at-cuts" but I would like to use the simple copy mode without to re-encode. Hi, Dear @LCF-AT, I have experience in the field of multimedia and have seen many softwares that can merge videos directly without re-encoding only when the frame rate and frame size are the same. This is a principle, because if this does not happen, you will have problems to play the video! (this is just my opinion) 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted December 16, 2022 Author Share Posted December 16, 2022 Hey again guys and nice to see you here and trying to help, I don't wanna be in 🏝️ without🚱 but with ☕ hhmm. Now look here.... File merges by ffmpeg using command -f concat -safe 0 -i "%s" -c copy -y "%s%s_merged%s 00001 - Legendary Last Minute Goals.mp4 = Frame 901 (0:00:30.033) 00002 - Legendary Last Minute Goals.mp4 = Frame 902 (0:00:30.067) 00003 - Legendary Last Minute Goals.mp4 = Frame 902 (0:00:30.067) = 2705 Frames -------------------------------------------------------------------- Now afer calling ffmpeg concat command I get this out... 00001 - Legendary Last Minute Goals_merged.mp4 = Frame 2780 (0:01:30.741) = 2780 Frames - 2705 Frames = 75 Frames to much / overhead etc = Why? Also if there are more frames at the end, the question is why does it affect the FrameRate itself? ...my details about that example video parts I got downloaded with yt-dlp. So you see there was added 75 frames but where are they comming from? Now I did check all three video parts and the merded video itself in VD2 to check all frames and I see some strange issues. So the last frame of every single video must be an information frame what gets cut out if you merge another video. Now when I do compare all single video parts with the merged then I see that in the merged video are suddenly MORE video informations to see as in the single parts itself!=? In the second video part for example I have 19 frames MORE video & audio at the start as in the original single video part 2. Thats strange. Somehow the index in the video itself was set wrong. Look at this image I made.... .....do you see this? In the original video part 2 I get less frames to see but they are there in the merged video. Strange or. Now its clear why the merged file has much more frames as the original single video parts. Anyway, also in this case when adding more frames by the merge process keeps the question open why it does change the frame-rate itself or just the frame-rate info. Question now is how to make the Frame-Rate INFORMATION itself SAME without to change the fps itself so I just need to change the information in the file itself. Lets say the video has a fps of 10 but now I wanna set the fps information in the file to 30 fps without to change the real frame-rate and this I wanna do without to re-encode the video. How to make it work? Just imagine I have an device what only can play videos with an specific FPS information of exactly 30 (only the info gets read) like a simple check. I must change just the info in the video file without to re-encode of course you know. Any ideas are welcome. greetz Link to comment Share on other sites More sharing options...
whoknows Posted December 16, 2022 Share Posted December 16, 2022 @LCF-AT telling again, dudkduckit @ ffmpeg merge videos result wrong framerate 1 Link to comment Share on other sites More sharing options...
JochenX Posted December 17, 2022 Share Posted December 17, 2022 Dear @LCF-AT, I have a suggestion for you; Merge three parts of your videos with these softwares: https://dl.bandicam.com/bandicut/bandicut-setup.exe http://www.freevideojoiner.com/ http://www.fosshub.com/MP4Joiner.html/MP4Tools-3.8-win32.exe https://github.com/Rambalac/JoinerSplitter/releases/download/v1.5.3/JoinerSplitterSetup_en.msi https://github.com/mifi/lossless-cut/releases/download/v3.48.2/LosslessCut-win-x64.7z https://file2.softsea.com/download/548210ce/102acb4d45d5696d4c9a91391e9e0acd/Video_Splitter_Joiner/freevideojoinersetup.exe https://github.com/rxaa/MediaMux/releases/download/v1.6.0/MediaMux64.rar Then analyze the frames of the output video, I am sure you will find the answer to all your questions and the puzzle will be solved!😉 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted December 17, 2022 Author Share Posted December 17, 2022 (edited) Hi again, so I don't try out any new tools Jochen. I also know that LosslessCut which also use ffmpeg. The only method I did remember from the past was it to de-mux the video & audio out to h264 and aac files and then I have to mux them back together into MP4 container using -r command before input & after input and mux them like this using ffmpeg and then I got a straight result of my framerate X = 30 in my case. But also here is the video now few seconds longer as before and video is one second longer as audio. Look my image below... ...just need to check that out with any other video where people do speak and check if audio does still match on video or whether they got out of sync. I really hate thos detours. I think when you cut a video into 100 tiny parts and merge them together into new single file then you got maybe tons of changes for fps & sync. Anyway. greetz EDIT: Fogot to add the copy mode at point 4 too. All steps done in copy mode without to re-encode. Edited December 17, 2022 by LCF-AT Adding info for point 4 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted June 14 Author Share Posted June 14 Hi guys, just have another tiny question about YT-DL. How to set any dynamic output file parameter to prevent overwriting the created file when I execute the same command line again or loop? So this is really annoying that I don't find any command for that on YT-DL doc. Just wanna output filenames with any random hash in the filename or just a time date. I found this closed issue.... https://github.com/ytdl-org/youtube-dl/issues/10558 ...someone said using this command... youtube-dl -o "$(date +%Y%m%d)-%(title)s-%(id)s.%(ext)s" your_url_here ....but it's not working when you enter it directly in terminal etc. So what can I do in this case to create some random part I can use in filename output? Also found no command what does check whether the used filename is already there and does then create same filename with any value at the end etc some auto check & create you know. Filename.mp4 Filename_(2).mp4 Filename_(3).mp4 Filename_(4).mp4 Is there any command what can handle this? Do you know that maybe? greetz Link to comment Share on other sites More sharing options...
kao Posted June 14 Share Posted June 14 5 minutes ago, LCF-AT said: but it's not working when you enter it directly in terminal etc That answer works just fine if you RTFM and use a compatible shell. Windows cmd.exe isn't it. For windows cmd.exe and/or BAT file scripting, you could probably use %DATE% and appropriate formatting, as explained in https://stackoverflow.com/questions/14810544/get-date-in-yyyymmdd-format-in-windows-batch-file 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted June 15 Author Share Posted June 15 Hey kao, thanks for your answer. Just don't wanna use a batch file / script etc just plain text command to enter in Windows terminal you know. Doable or not? So for the moment I did wrote a own small timestamp routine I use before calling / sending my command to terminal via CreateProcess. Works ok now when using my tool for that instead of using direct CMD terminal. Just wonder why those tools like YT / ffmpeg do not just include such commands to get time date or some random hash you can use for output file name. Not all wanna write scripts for that or something. On YT-DL there are just TONS of commands you can use in a output template but nothing simple like a creation date of the file you wanna output. Somehow strange. greetz 1 Link to comment Share on other sites More sharing options...
kao Posted June 15 Share Posted June 15 (edited) https://github.com/yt-dlp/yt-dlp#output-template Quote epoch (numeric): Unix epoch of when the information extraction was completed autonumber (numeric): Number that will be increased with each download, starting at --autonumber-start video_autonumber (numeric): Number that will be increased with each video Edited June 15 by kao 1 Link to comment Share on other sites More sharing options...
LCF-AT Posted June 15 Author Share Posted June 15 Hi kao, thanks for this info. So the autonumber only works for same YT process so this I tried before when downloading parts. If I exec YT-DL twice it does not work. The video_autonumber seems also not to work and just get always 1 out in filename. The epoch does work to show hour, minute and second like this "18-05-12" but the hour value is not correct for my time. So do you know how to adjust that command if possible? %(epoch-3600>%H-%M-%S)s What about date time year, month and day? Can this be added too? Just don't see how I should do that... https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes greetz Link to comment Share on other sites More sharing options...
kao Posted June 15 Share Posted June 15 #1 - as per Python documentation, epoch uses UTC time. If you're in another timezone, you need to add/subtract the correct number of seconds (remembering that 1 hour = 3600 seconds). #2 - as per the documentation you linked to, %Y, %m and %d should work. 21 hours ago, LCF-AT said: Just wanna output filenames with any random hash You could use epoch as an almost-random number, just format is as an integer or float and you're done. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now