I have developed a Linux script program which I use to download a few news live streams for later viewing (I am on a completely different time zone).
The downloading is done using an ffmpeg command which reformats the stream on the fly into the mp4 format I need for further editing.
It runs unattended on an Ubuntu 20.04 server (no GUI).
This is the main command that does the download:
The variables hold these items:Code:ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -r 30 -vf scale=w=-4:h=${VIDEORES} -c:v libx264 -preset fast -crf 26 -x264-params keyint=30:scenecut=0:open-gop=0 -c:a aac -t ${CAPTURETIME} ${TARGETFILE}
MODE="-referer \"${VIDEOURL}\"" and VIDEOURL is the source page where the video stream appears
M3U8URL=the stream URL within the webpage
VIDEORES="480"
CAPTURETIME=the recording time in seconds from the source
TARGETFILE= the outut file in mp4 format
Now I would like to be able to optionally also speed up the video such that it can be viewed in a shorter time.
I have researched the command to recode the video with a higher speed while keeping the pitch and sync of the audio part.
This is placed in another script file that can do the conversion from an input file to an output file:
Here the variables are:Code:ffmpeg -hide_banner -i ${SOURCEFILE} -filter_complex \"[0:v]setpts=1/${SPEEDUP}*PTS[v];[0:a]atempo=${SPEEDUP}[a]\" -map \"[v]\" -map \"[a]\" ${TARGETFILE}
SOURCEFILE=input mp4 file created by the previous command
SPEEDUP=a decimal number for the output video playback speed between 0.5 and 2.0
TARGETFILE= the outut file in mp4 format
This works fine but runs at about 6-7 times the playback speed so it takes 10 min to convert a 1 hour video.
My question is how I can plug the speed conversion into the download command so that the conversion is done during streaming.
I need to send the output of the first command into a new "filter" instead of directly to file.
I have seen ffmpeg doing stuff in series but I have not understood how it works...
+ Reply to Thread
Results 1 to 4 of 4
-
-
I have tried this in order to insert the speed handling after the other stuff and before sending it to the output file:
Code:SPEED="1.25" #Test value, should be a script call argument. SPEEDCMD=" -filter_complex \"[0:v]setpts=1/${SPEED}*PTS[v];[0:a]atempo=${SPEED}[a]\" -map \"[v]\" -map \"[a]\" " #This will speed up/down the video by the SPEED amount CMD="ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -r 30 -vf scale=w=-4:h=${VIDEORES} -c:v libx264 -preset fast -crf 26 -x264-params keyint=30:scenecut=0:open-gop=0 -c:a aac -t ${CAPTURETIME} ${SPEEDCMD} ${TARGETFILE}" ... eval "$CMD" RES=$? #-----Check ffmpeg exit code
Code:Filtergraph 'scale=w=-4:h=480' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph. -vf/-af/-filter and -filter_complex cannot be used together for the same stream.
And what could I do instead? -
My goal is to be able to view the news shows from USA in my own time zone, so I have created a download system where I use ffmpeg to capture the shows nightly in my Ubuntu server.
Then I want to remove the ads before viewing so I have created a video editor where I can set cut points accurate to 1 second. The video editor creates a call with the cut points to another ffmpeg based program, which performs the extraction and pasting together of the cuts to create the final video for watching.
Originally I had a much simpler download command but that resulted in videos that could not easily be cut at the cut points so there were artifacts of removed sections in the final video.
After discussions here I wound up with the final download command shown above where:
- The video size is re-encoded on the fly, because if done afterwards it takes about 10 min per video hour..
- The frames are set on the fly in the same inline command so I don't have to process anything afterwards except the cutting.
- The cut/paste operations are now not creating artifacts and it works much faster too (a few seconds only)
Current problem:
Now I have thought that I could save viewing time by speeding up the final video by some 10-15%, but this operation also takes some 10-15% of the original video playing time, so I would like to do that too during download so it will be ready immediately as the download completes.
The command used is based on what I have found on-line and it works well enough, except it takes time so I would like it to be done while downloading too.
So what is the proper way to insert the speedup into the download command so it will run concurrently?
Similar Threads
-
How to compile ffmpeg v6.0 with filter overlay_cuda?
By KaGaWu in forum Newbie / General discussionsReplies: 2Last Post: 7th Feb 2024, 07:56 -
Rescaling the Tinterlace filter outupt in FFMPEG
By JackyBorderCollie in forum Video ConversionReplies: 2Last Post: 4th May 2023, 14:40 -
record/stream live camera feed with ffmpeg on Raspberry Pi 2B+
By Andrei2 in forum Newbie / General discussionsReplies: 0Last Post: 27th Mar 2023, 02:12 -
Best possible output FFMPEG?
By TravelRock in forum RestorationReplies: 7Last Post: 13th Apr 2021, 22:24 -
Handbrake\ffmpeg blur-and-warm filter?
By andy_larkin in forum DVD RippingReplies: 0Last Post: 29th Apr 2020, 22:25