I have been using ffmpeg in order to download content from a streaming source into an mp4 file while converting the format to a smaller size (480P).
Then when the download finishes I can view the content by playing the downloaded file.
I have scripted it on a Linux server (no GUI there) so the downloads can be done unattended on off hours and viewed later (time zone differences).
Now I wonder if there is a way to convert the download to something that can be viewed in real time as it is being recorded?
If I set the target to a ts file instead of mp4, can it then be viewed while the download goes on?
My current command in the script file looks like this:
where:Code:CMD="ffmpeg -hide_banner -loglevel warning -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}"
VIDEOURL is the source webpage which contains an embedded video player
M3U8URL is the stream URL for the video on that player
CAPTURETIME is the final video length in seconds
TARGETFILE is the name of the output mp4 fiile
How should I modify this command in order to make it produce a file that can be viewed at the same time the download runs?
I think that the mp4 format is not suited since such files need to have a "moov" part that can only be written at the end of a download when the file is closed for writing by ffmpeg.
So possibly converting into a ts file or similar would be a way?
Or is there a better way to do it where the output can be viewed as it is being created?
I use a web browser to connect to my Linux server to view the downloaded files, so something tah can be opened in a web browser would be the output I am after.
Any suggestion welcome.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
Try StreamFab Downloader and download streaming video from Youtube, Netflix, Amazon! Download free trial.
+ Reply to Thread
Results 1 to 7 of 7
Thread
-
-
change to .ts
Code:CMD="ffmpeg -hide_banner -loglevel warning -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 -f mpegts ${TARGETFILE}.ts"
Code:python3 -m http.server 8000
-
Thanks, this worked to create the ts file,
But now I have to work on my infrastructure since my utilities assume a video file everywhere with extension mp4....
I could play the created file in VLC so the command seems to work fine, I "just" have to allow my website to serve out ts files from a webpage.
The current breed only serves out mp4 files so I must somehow change it so it will also accept the ts file ending.
The webpage lists all files with extension mp4 in a given directory and when one clicks a file in the list a call is made to a php script which takes the file name (without extension) as argument and finally ends in this php section:
Code:<?PHP echo "<div>\n"; $videofile = $videofile . '.mp4'; //Assumes name-only call and only mp4 files echo "<video id=\"myVid\" controls autoplay>\n"; echo "<source src=\"$videofile\" type=\"video/mp4\" />\n</video>\n"; echo "<script>\n"; echo "var vid = document.getElementById(\"myVid\");\n"; echo "vid.volume = 0.3;\n"; echo "</script>\n"; echo "</div>\n"; ?>
Then it proceeds assuming an mp4 file until the playing fails...
I have to somehow fix this otherwise no playback of ts files is possible on my server..
So two things need to be done:
- List files with mp4 and ts extensions separately
- Add a host player for the ts type files to be used with these
The code above was retrieved many years ago via a discussion in a forum (don't remember now which one), so now I need to get help somehow to fix it to be able to handle both.
The best would be for the server to be able to check what kind of file is used and adjust the player accordingly.
Which of course I am not able to do at the moment.
Maybe ChatGPT can help???? -
So the change to the download URL made it possible to download to a ts file - that's step one checked!
But the play in web browser URL does not work, which is not surprising since the :8000 suggests the webserver is using port 8000 which it is not...
Using the URL without the :8000 makes the Firefox browser try to download the file rather than playing it.
And I don't understand what you mean by:
Code:python3 -m http.server 8000
My webserver is an Apache standard service on Ubuntu serverLast edited by BosseB; 22nd Oct 2024 at 14:19. Reason: Clarifying which web server is used.
-
-
That is just a temporary service on a single file started by a user accessing a terminal on the server....
My web service for mp4 files consists of a lot of folders with various content and there is a navigational page where these folders are listed by a descriptive name (not the filesystem name).
When such a folder is clicked in the web browser the page shown displays a headline describing the type of content in the folder and a list of available files of type mp4. The list is created by the custom directory scanning function called when one opens the folder in a browser.
Now, the list shows the names (without extension) of the files in the folder and the associated hyperlink calls a php script that gets the name of the file as an argument.
This script sends back a new page to the user, which is a full-page video player loaded with the selected mp4 file ready to be played by clicking the play button shown.
What I want is to be able to do this also on type ts files, which I am now able to download thanks tp the advice above.
But by changing the videoplay script to replace the mp4 file with the ts file only triggers Firefox to suggest a file save operation...
No video player visible...
Several family members use this website to view the content. But it is not public.
The reason for the ts file type to be used is that it allows playback before the file is closed, for example by using the VLC video player or similar.
But I want the playback to be integrated on my web server...
Note:
The video directories are also viewed through a KODI media player running on a RaspberryPi device.
This can actually show the ts files successfully also when they are not yet completely downloaded!
But it is a dedicated player of course and not something used via a web browser...
And it also has a problem:
KODI seems to evaluate the duration of the media file on start of playback and then has problems after some time when the playback reaches a time later than the initial length of the file. It seems like KODI does not update the length while serving the video....
At this point it gets erratic especially when trying to jump back and forward.
A stop and renewed start solves it for a while but after reaching the new duration the same reappears.
Similar Threads
-
View / Download Private YouTube Video
By takistexas in forum Video Streaming DownloadingReplies: 5Last Post: 6th Feb 2024, 06:29 -
Streaming video loop FFmpeg
By Daniquito in forum Video Streaming DownloadingReplies: 0Last Post: 20th Sep 2022, 14:10 -
can you download/view a video from a deleted tweet using Wayback Machine?
By mayimakeasuggestion in forum Video Streaming DownloadingReplies: 1Last Post: 4th Jul 2022, 06:14 -
youtube-dl FFmpeg script drag drop paste url download convert
By vaype_naysh in forum Newbie / General discussionsReplies: 0Last Post: 20th Sep 2021, 14:12 -
Is it possible to download dash mpd and convert into mp4 using ffmpeg?
By MonikaChen in forum Video Streaming DownloadingReplies: 4Last Post: 16th Feb 2021, 09:09