Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i am wanting to download a live video feed. i have experimented with ffmpeg and it seems to do the job. but it keeps on doing the job. the live feed continues for a very long time. if i just let it keep running for hours and hours, the feed stops and ffmpeg comes to a graceful stop and i get a .mp4 file that works. but if i press ^C, it kills ffmpeg which does not finish the file it was writing.
during the download it is writing into a file that has a name like the URL but ends in .mp4.part which grows and grows. when the feed ends, ffmpeg makes it into a .mp4 file. but, if it is killed, the file never gets finished.
the ffmpeg man page says nothing about signals. i'd like to know how to gracefully stop ffmpeg and have it finish as if the feed has ended. i want to play the video up to that point long before the feed ends.
also, how can i do the finish process for the leftover files after ffmpeg is killed? i have a few of these i'd like to save. mplayer won't play the unfinished ones.
BTW, ffmpeg shutting down gracefully is not necessarily the same as producing a playable file.
but having it cease to continue running seems to not produce a playable file. the man page appears to say nothing about this unless it is using some strange terminology.
in my case i don't know how long i want it to run. i only know i want to stop it when that time comes around. so giving a time in advance is not an option.
Don't encode on the fly. Dump it to a transport stream,(ffmpeg knows what that is), then re-encode it later if you want to.
You want to start/stop on clock times? Such as a TV program?
i want to start recording a live feed without any idea when it needs to stop. at some point i will know that i need to stop. then i would need to tell it so. typing q does not work. that may be because i ran youtube-dl which runs ffmpeg. i am not running ffmpeg myself.
i am running youtube-dl as a command. but i can see that it is running ffmpeg. i don't know how long i want it to run, in advance.
as the run progresses there is a .mp4.part file which cannot be played. if the feed ends normally, then it has a .mp4 file which plays OK, but for hours longer because i could not end the feed.
if there is a way to have ffmpeg "fix" the .mp4.part file and make the .mp4 file, then that can be done after killing youtube-dl/ffmpeg.
What are you trying to record? Some live event on youtube like a ship passing by?
You'd have to guess the time frame I'd think if the video never stops.
it's kinda like that. the video does eventually stop, but only after hours. it typically runs for 48 to 60 hours. this spring it will run longer, like 120 to 168 hours.
i did figure out how to finish those .mp4.part files and get a working .mp4 file:
Code:
ffmpeg -i foo.mp4.part -c copy -f mp4 foo.mp4
the man page didn't literally say how or even mention "part" but i tried mixing and matching stuff and hit what works.
edit:
i will try the transport stream thing next. if that can eliminate skipping segments then it's time to tweak some extractors in youtube-dl to invoke ffmpeg that way.
It's just another case of "why read man pages when I can ask others to do it for me".
Both youtube-dl and ffmpeg have extensive web pages (in addition to plenty online material).
how many frames were captured? i seem to be getting some method called HLS that is resulting in multiple web requests that sometimes reports skipping segments due to expiring from playlists. can you do that test after capturing 5 minutes and being sure you get the whole 5 minutes with no freezing parts. can that file be played while the capture is running?
i don't follow the way you did that command. what is $a?
If you look into that index.m3u8, you'll find the segmented playlist
Code:
curl "$b" -o test.m3u8
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6384 100 6384 0 0 17347 0 --:--:-- --:--:-- --:--:-- 17347
cat test.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:3990038
#EXT-X-DISCONTINUITY-SEQUENCE:716
#EXT-X-PROGRAM-DATE-TIME:2021-01-13T22:18:01.592+00:00
#EXTINF:4.999,
https://r5---sn-vgqs7ney.googlevideo.com/v....
And you should see a pattern to the end of each segment url.
%3D1610465933234115/dur/4.999/file/seg.ts
%3D1610465933234125/dur/5.001/file/seg.ts
%3D1610465933234135/dur/4.999/file/seg.ts
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.