I am using a script on Ubuntu to download streamed shows nightly.
The script collects input arguments and uses an ffmpeg command to perform the capture:
Here VIDEOURL is the source stream, CAPTURETIME is the number of seconds to download, TARGETFILE is the output file like output.tsCode:COMMAND="ffmpeg -user_agent \"Mozilla\" -i $VIDEOURL -t $CAPTURETIME -c copy $TARGETFILE" eval $COMMAND
This runs as at jobs during the night at certain times.
Since the result is a ts file it needs to be converted into the final mp4 file I will be watching and I use this command for that (also in a script):
This reduces the file size considerably by coverting from 1280x720 format of the ts file to 852x480 in the mp4 file.Code:COMMAND="ffmpeg -hide_banner -i $INFILE -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 16 -c:a copy $OUTFILE"
My problem is that the audio and video are not in sync, they are off by 250 ms, so I have to apply yet another script run to adjust the time sync:
Here I enter DELAY as -0.25 to reach lip sync.Code:COMMAND="ffmpeg -hide_banner -i $SOURCEFILE -itsoffset $DELAY -i $SOURCEFILE -map 1:v -map 0:a -c copy $TARGETFILE" eval $COMMAND
My question here is if it is possible to combine the actions of the two processing scripts such that the audio fix is also done when the conversion is done from ts to mp4?
Note:
The stream download is as bare as it is because when I tried to do the conversion to mp4 there gaps were created in the result due to processing overload of the Ubuntu server...
By separating processing from download that problem was cleared and I can do the processing in another Ubuntu machine since the target dir is shared with NFS.
Support our site by donate $5 directly to us Thanks!!!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
+ Reply to Thread
Results 1 to 9 of 9
-
-
Thanks, I will test this.
But after I posted I realized that the delay might be just a delay and maybe it cannot be negative?
My standalone script command operating on the mp4 file looks like this:
Code:ffmpeg -hide_banner -i $SOURCEFILE -itsoffset $DELAY -i $SOURCEFILE -map 1:v -map 0:a -c copy $TARGETFILE
If you think about the processing then the stream being delayed (by a positive time) can be buffered by that amount before being combined by the other stream, but it is hard to imagine the other way around.
In such case maybe the sign should control for which stream the delay (buffering) should be applied to? And the actual value be always positive.
If this is the case then the script can check where -itsoffset $DELAY should be placed in the call to ffmpeg based on its sign (and the sign removed of course).
Or else ffmpeg is smart enough to buffer the other stream if the delay is the wrong direction?
As you see I am a bit confused about these matters... -
Now tested the following commands:
Code:ffmpeg -hide_banner -i input00.ts -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 16 -c:a copy -t 120 test_000.mp4 ffmpeg -hide_banner -itsoffset -0.8 -i input00.ts -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 16 -c:a copy -t 120 test_-800.mp4 ffmpeg -hide_banner -itsoffset 0.8 -i input00.ts -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 16 -c:a copy -t 120 test_800.mp4
I used 800 ms in order to clearly see the difference but none was apparent... -
You need to specify the input twice, once without a delay once with. Then pick the video from one file, the audio from the other:
Code:ffmpeg -hide_banner -i input00.ts -itsoffset -0.8 -i input00.ts -map 0:v -map 1:a -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 16 -c:a copy -t 120 test_-800.mp4
-
Yes, I know but this example was from a reply provided here and it did not have two inputs...
I am now testing with two inputs as you suggested.
I now see different delays with the 3 tests...
But the conversion speed is really slow like only 4x the video speed, so a 2 hour video takes 30 min to process...
The standalone audio sync script I have takes only about 10 seconds to deal exclusively with the audio. -
Similar Threads
-
Download DASH stream (audio and video mp4)
By axes in forum Video Streaming DownloadingReplies: 1Last Post: 30th May 2020, 07:30 -
video stream link download possible?
By purelutz in forum Video Streaming DownloadingReplies: 2Last Post: 17th Apr 2019, 02:28 -
joined ts video has 3-second delay if jumping to different time
By cpliu in forum Video ConversionReplies: 6Last Post: 21st Jan 2018, 07:15 -
How can I Download this Video Stream?
By 212eta in forum Video Streaming DownloadingReplies: 15Last Post: 9th Dec 2017, 11:13 -
How to Download Protected Stream Video
By rochmad7 in forum Video Streaming DownloadingReplies: 5Last Post: 9th Aug 2017, 05:47