I was playing with curl today and I discover --range function which helps download files to a specific size . so I downloaded video of 88mb into 2 parts vid1.mp4 and vid2.mp4 . vid1.mp4 playing in vlc player but vid2 seems corrupted and not playing in vlc but I know file is there due to its size
This heavily depends on the video encoder and container format.
Some are optimized for streaming and put their data information at the beginning of the file, however, there are other formats that put it at the end. Then you have to download it fully before being able to decode.
Starting in the middle is generally not how video decoders can work (they rely on information from frames before) and this arbitrary range will not work.
However, from experience, VLC was able to play almost anything I gave it. So if it fails, your splitting is not a supported approach.
I’ve been playing around with getting segments of videos and putting videos back together, and re-encoding, etc. I’m not sure this applies in your case, but just in case.
List formats and then download:
yt-dlp -F URL yt-dlp --restrict-filenames --abort-on-error \ -o "$(date '+%Y%m%d%H%M')-%(title)s-%(id)s.%(ext)s" -f22/18 URL
Seek to position 0 and read for a duration of 4:30.
ffmpeg -ss 0:00:00 -t 00:04:30 -i File_From_Above.mp4 -vcodec copy -acodec copy OutputFile1.mp4
The other option is to reencode the entire file with more compression and the trade-off is some quality.
If the two parts are just the one big file snipped in half, could try join them together to play:
cat vid1.mp4 vid2.mp4 > vidboth.mp4
VLC and possibly other players might resort to brute force and heuristics if the information provided is not enough. So in reality loss of metadata does not mean much, if you have a player that tries all possible data formats before telling you things failed.
Yes, but most commonly, they are .ts segmented in which case, one can use concat with ffmpeg, like this:
for i in `\ls *.ts | sort -V`; do echo "file '$i'"; done >> list.txt; ffmpeg -f concat -safe "0" -i list.txt -c copy merged.ts ffmpeg -i merged.ts -map 0 -c copy output.mp4
I suggested cat because
curl --range doesn’t know about the file internal structure.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.