I have a scripted system on Linux for downloading real time streaming video for later viewing, which uses ffmpeg to retrieve the videos through their m3u8 urls into mp4 files.
Some of these videos are 2 or even 3 hours long and I would like to be able to start viewing them while they are still being downloaded.
But when I point my video player to the mp4 file being written it fails to display anything.
So I am wondering if there is a way to do the downloading such that the file being written at the end can be simultaneously viewed from the beginning including performing timed playback jumps?
My ffmpeg command for the download looks like this:
The reason for the complex filter is that I want the keyframes start on even seconds to enable simpler and faster editing.Code:CMD="ffmpeg -hide_banner -referer \"${VIDEOURL}\" -i \"${M3U8URL}\" -r 30 -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 26 -x264-params keyint=30:scenecut=0:open-gop=0 -c:a aac -t ${CAPTURETIME} ${TARGETFILE}"
+ Reply to Thread
Results 1 to 11 of 11
-
-
I've noticed that you're re-encoding the video file. Why is that? You could also just copy the codecs over with
Code:-c copy
Code:-f mpegts
Bypass HMACs, One-time-tokens and Lic.Wrapping: https://github.com/DevLARLEY/WidevineProxy2 -
Well, I used copy earlier but then it was near impossible to edit the files because there were always artifacts of surrounding scenes at the cut points in the final video. And re-encoding after the video was downloaded took about 10 minutes per hour of video so was not useful either.
With the on-the-go re-encoding I got control of the frame borders and now applying an edit command with 10 cut points in a 1-hour video takes something like 10 s to process.
Before I did this though, I could still not play the video unless it had been completely downloaded.
It looks like something necessary for playback is added to the video at the end of recording and if that is missing the video is unplayable. Some closing data needed for playback is located at the end of the file, maybe?
This always (also in the present solution) happens if there is an interruption of the download just before it would have ended anyway...
I have noted on my PVR box that it is possible on that to start viewing a recording that is still not finished.
But that is on a system recording off-air via an antenna so it is not streaming video... -
-
Last edited by larley; 13th Aug 2024 at 03:16.
Bypass HMACs, One-time-tokens and Lic.Wrapping: https://github.com/DevLARLEY/WidevineProxy2 -
Code:
N_m3u8DL-RE --save-name test "http://xxxx,xxxx,xxxxx.mpd" --append-url-params --mp4-real-time-decryption --use-shaka-packager --key xxxxxxxxxxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxx --live-pipe-mux
Noob Starter Pack. Just download every Widevine mpd! Not kidding!.
https://files.videohelp.com/u/301890/hellyes6.zip -
Not for me...
I tried to modify the ffmpeg command as follows (added -movflags +faststart after -r 30):
Code:CMD="ffmpeg -hide_banner -referer \"${VIDEOURL}\" -i \"${M3U8URL}\" -r 30 -movflags +faststart -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 26 -x264-params keyint=30:scenecut=0:open-gop=0 -c:a aac -t ${CAPTURETIME} ${TARGETFILE}"
When it was all done it played fine so there is something blocking it from being viewed until fully recorded. -
OK thanks!
So this did allow starting viewing of the mp4 file while it was downloading.
But the length of the video inside the video player (VLC) seems to be read at the moment of opening the file and is not updated while the video is downloaded further.
So the player stops at the location the recording was when it started to play the file even though the file is now longer.
I don't know what this setting might mean for the video itself, I will have to check it further to see if I find any problems.
What exactly is this moov thing? -
'moov' is an MPEG-4 atom (kinda like a container), that contains metadata about the video
Bypass HMACs, One-time-tokens and Lic.Wrapping: https://github.com/DevLARLEY/WidevineProxy2
Similar Threads
-
Can't decrypt video downloaded from Mediasetinfinity
By Poli12 in forum Video Streaming DownloadingReplies: 1Last Post: 3rd Aug 2024, 03:55 -
Downloaded video is greyed from N_m3u8DL-RE
By swappyison in forum Newbie / General discussionsReplies: 0Last Post: 28th Jul 2023, 02:19 -
Downloaded video is out of sync
By Mrachan in forum Video Streaming DownloadingReplies: 10Last Post: 12th May 2023, 19:57 -
Help : Downloaded video does not have subtitles
By Rij in forum Video Streaming DownloadingReplies: 11Last Post: 6th Oct 2021, 12:29 -
Downloaded video but can't play it?
By Anonymous84 in forum Video Streaming DownloadingReplies: 3Last Post: 25th Sep 2021, 19:36