Re: [FFmpeg-user] Combining download of ts stream with geometry modification into mp4?
On Tue, 20 Apr 2021 00:52:07 +0200, Bo Berglund wrote: >I think that the " -threads 1 " part does not work to reduce the CPU load, >though... I got off-list advice and a link to a stack-exchange discussion on this matter: https://superuser.com/questions/792525/how-to-change-ffmpeg-threads-settings It turns out that my use is probably totally wrong since it limits the threads for the download function, which is not a heavy worker: "ffmpeg -threads 1 -user_agent \"Mozilla\" -i $VIDEOURL -vf scale=w=-4:h=360 -c:v libx264 -preset fast -crf 26 -c:a copy -t $CAPTURETIME $TARGETFILE" The proper position seems to be *after* the VIDEOURL instead. But I don't know where exactly it should be located. Maybe it does not matter? Like this instead: "ffmpeg -user_agent \"Mozilla\" -i $VIDEOURL -threads 1 -vf scale=w=-4:h=360 -c:v libx264 -preset fast -crf 26 -c:a copy -t $CAPTURETIME $TARGETFILE" These items are arguments to the script or global variables: $VIDEOURL(read from file) $CAPTURETIME (argument 1) $TARGETFILE (argument 2) -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Combining download of ts stream with geometry modification into mp4?
On Mon, 19 Apr 2021 10:01:47 -0700, Carl Zwanzig wrote: >On 4/19/2021 4:46 AM, Bo Berglund wrote: >>> *assuming that the source is producing a ts which is captured as-is >> I think that it is, > >Which would be easily answered by including the command output (which should >have been in the initial email). > > >Have you tried simply replacing > -i >with > -user_agent \"Mozilla\" -i -t >? > >If that does not work, post the complete command and output (and don't use >-hide_banner). And, of course, use a current build of ffmpeg. Well after my last post I checked if just adding the second command arguments after the input had been defined to be the stream it worked just like I want it to! :) Here is the basics of the script I call from the at schedule at preset times (I have removed input argument checking for clarity): #!/bin/bash read VIDEOURL < $URLFILE #URLFILE contains the long URL to the 24 hour stream CAPTURETIME="$1" #Time in second for the capture duration TARGETFILE="$2" #The output file to store the video into, extension is .mp4 eval "ffmpeg -hide_banner -threads 1 -user_agent \"Mozilla\" -i $VIDEOURL -vf scale=w=-4:h=360 -c:v libx264 -preset fast -crf 26 -c:a copy -t $CAPTURETIME $TARGETFILE" I think that the " -threads 1 " part does not work to reduce the CPU load, though... When I check with top I get a load that varies between 35% and 80% for the ffmpeg PID. But when I check the thread count for that PID it gets above 20! Anyway, the whole thing now works OK and I get the final file at the time the scheduled task is supposed to end. All in all I now have a working solution that does not slow me down for geometry/size conversion after each download as it did before. And the mp4 file size is OK too. -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Combining download of ts stream with geometry modification into mp4?
On 4/19/2021 4:46 AM, Bo Berglund wrote: *assuming that the source is producing a ts which is captured as-is I think that it is, Which would be easily answered by including the command output (which should have been in the initial email). Have you tried simply replacing -i with -user_agent \"Mozilla\" -i -t ? If that does not work, post the complete command and output (and don't use -hide_banner). And, of course, use a current build of ffmpeg. z! ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Combining download of ts stream with geometry modification into mp4?
On Sun, 18 Apr 2021 23:41:59 -0700, Carl Zwanzig wrote: >On 4/18/2021 11:20 PM, Bo Berglund wrote: >> Can I combine these two operations into a single ffmpeg command such that >> there >> is no intermediate ts file created and the mp4 is available essentially when >> the >> download completes? > >You can combine them, but* then the "download" will be extended by the time >needed to re-code the file _and_ you'll lose the ability to retry the >conversion if something goes up the wall. If you can afford the storage, I'd >definitely download and convert in separate steps. I did not mean to first let the ts download complete into the ts file and then start a conversion. That can be done inside the script as a second operation following the capture. What I really asked for is a way to let ffmpeg run the conversion with the source not from a file but from the stream that it is downloading at the same time. Then since the conversion is faster than real time viewing the convert will be essentially ready when the stream download is stopped on timeout. Notice that I have a timeout in there to determine for how long the download is supposed to be done: "-t " The download script is started at a set time via the at command in Linux and shall end upon reaching the timout (since the stream continues). >*assuming that the source is producing a ts which is captured as-is I think that it is, this is the command: ffmpeg -hide_banner -user_agent \"Mozilla\" -i URL -t 3600 -c copy output.ts Where URL is supplied on call as well as timeout 3600 (can be 7200 for 2 hours etc) >Also, >"from 1280x720 to 640x320 px." != "-vf scale=w=-4:h=$360" >(what does the dollar sign do or is that a typo? complete output is always a >good idea.) >1280/720=1.7 while 640/320=2.0, so I assume that should be 360. I actually wrote 360 in the command example itself, the text above has the typo... But with an erroneous $ in front. I copied the command from my script, which accepts the height as a parameter and so in the actual command line it is specified as "-vf scale=w=-4:h=${VSIZE}" When I replaced it I missed to also take out the $ char You are right that the parameter is 360, which makes a 1280x720 conversion come out as exactly 640x320. This should help in the internal processing of pixels. >Have you looked at the CPU usage for each step? Yes I have, the download itself is barely noticable whereas the conversion taxes the CPU a lot. That is why the "-threads 1" is there to not completely lock up the server. So how should a command that uses the input *stream* as source to the mp4 conversion look like? -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Combining download of ts stream with geometry modification into mp4?
On 4/18/2021 11:20 PM, Bo Berglund wrote: Can I combine these two operations into a single ffmpeg command such that there is no intermediate ts file created and the mp4 is available essentially when the download completes? You can combine them, but* then the "download" will be extended by the time needed to re-code the file _and_ you'll lose the ability to retry the conversion if something goes up the wall. If you can afford the storage, I'd definitely download and convert in separate steps. *assuming that the source is producing a ts which is captured as-is Also, "from 1280x720 to 640x320 px." != "-vf scale=w=-4:h=$360" (what does the dollar sign do or is that a typo? complete output is always a good idea.) 1280/720=1.7 while 640/320=2.0, so I assume that should be 360. Have you looked at the CPU usage for each step? Later, z! ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".