Speeding up a script.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Speeding up a script.

Evert Vorster
Hi there.
I am using a quite convoluted filter in ffmpeg.
-------------------------------------------------------------
#!/bin/bash
#This will split, defish, blend and re-assemble Samsung Gear 360 video
map_dir="/data/Projects/RemapFilter"
ffmpeg -y -i "$1" \
-i $map_dir/lx.pgm -i $map_dir/ly.pgm -loop 1 \
-i $map_dir/Alpha-Map.png \
-i $map_dir/rx.pgm -i $map_dir/ry.pgm \
-c:v hevc_nvenc -rc constqp -qp 26 -cq 26 \
-filter_complex \
"[0:v]eq=contrast=0.8:brightness=-0.01:gamma=0.7:saturation=0.8[bright]; \
 [bright]split=2[in1][in2]; \
 [in1]crop=in_w/2:in_h:0:in_h[l_crop];\
 [in2]crop=in_w/2:in_h:in_w/2:in_h[r_crop]; \
 [3]alphaextract[alf]; \
 [l_crop]vignette=angle=PI/4.6:mode=backward[l_vignette]; \
 [l_vignette][1][2]remap[l_remap]; \
 [r_crop]vignette=angle=PI/4.8:mode=backward[r_vignette]; \
 [r_vignette][4][5]remap[r_remap]; \
 [l_remap]crop=in_w:1920:0:(in_h-1920)/2[l_rm_crop]; \
 [r_remap]crop=in_w:1920:0:(in_h-1920)/2[r_rm_crop]; \
 [l_rm_crop][alf]alphamerge[l_rm_crop_a]; \
 [l_rm_crop_a]split=2[l_rm_crop1][l_rm_crop2]; \
 [l_rm_crop1]crop=in_w/2:in_h:0:0[l_rm_crop_l]; \
 [l_rm_crop2]crop=in_w/2:in_h:in_w/2:0[l_rm_crop_r]; \
 [0:v][r_rm_crop]overlay=(1920-(2028/2)):0[ov1]; \
 [ov1][l_rm_crop_l]overlay=((1920+2028/2)-(2028-1920)):0[ov2]; \
 [ov2][l_rm_crop_r]overlay=0:0[out]" \
-map [out] -map 0:a "$1_Remapped.mp4"
---------------------------------------------------------

When this runs, only one of my CPU is showing any activity.
Is there a way of telling ffmpeg to process these steps in the filter in
parallel?

Kind regards,
Evert Vorster

Isometrix Acquistion Superchief
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Speeding up a script.

Paul B Mahol
On 8/6/17, Evert Vorster <[hidden email]> wrote:

> Hi there.
> I am using a quite convoluted filter in ffmpeg.
> -------------------------------------------------------------
> #!/bin/bash
> #This will split, defish, blend and re-assemble Samsung Gear 360 video
> map_dir="/data/Projects/RemapFilter"
> ffmpeg -y -i "$1" \
> -i $map_dir/lx.pgm -i $map_dir/ly.pgm -loop 1 \
> -i $map_dir/Alpha-Map.png \
> -i $map_dir/rx.pgm -i $map_dir/ry.pgm \
> -c:v hevc_nvenc -rc constqp -qp 26 -cq 26 \
> -filter_complex \
> "[0:v]eq=contrast=0.8:brightness=-0.01:gamma=0.7:saturation=0.8[bright]; \
>  [bright]split=2[in1][in2]; \
>  [in1]crop=in_w/2:in_h:0:in_h[l_crop];\
>  [in2]crop=in_w/2:in_h:in_w/2:in_h[r_crop]; \
>  [3]alphaextract[alf]; \
>  [l_crop]vignette=angle=PI/4.6:mode=backward[l_vignette]; \
>  [l_vignette][1][2]remap[l_remap]; \
>  [r_crop]vignette=angle=PI/4.8:mode=backward[r_vignette]; \
>  [r_vignette][4][5]remap[r_remap]; \
>  [l_remap]crop=in_w:1920:0:(in_h-1920)/2[l_rm_crop]; \
>  [r_remap]crop=in_w:1920:0:(in_h-1920)/2[r_rm_crop]; \
>  [l_rm_crop][alf]alphamerge[l_rm_crop_a]; \
>  [l_rm_crop_a]split=2[l_rm_crop1][l_rm_crop2]; \
>  [l_rm_crop1]crop=in_w/2:in_h:0:0[l_rm_crop_l]; \
>  [l_rm_crop2]crop=in_w/2:in_h:in_w/2:0[l_rm_crop_r]; \
>  [0:v][r_rm_crop]overlay=(1920-(2028/2)):0[ov1]; \
>  [ov1][l_rm_crop_l]overlay=((1920+2028/2)-(2028-1920)):0[ov2]; \
>  [ov2][l_rm_crop_r]overlay=0:0[out]" \
> -map [out] -map 0:a "$1_Remapped.mp4"
> ---------------------------------------------------------
>
> When this runs, only one of my CPU is showing any activity.
> Is there a way of telling ffmpeg to process these steps in the filter in
> parallel?

Have you checked which filter takes most of processing times?

>
> Kind regards,
> Evert Vorster
>
> Isometrix Acquistion Superchief
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Speeding up a script.

DopeLabs
In reply to this post by Evert Vorster
you can search the ffmpeg-all man pages or online documentation for 'threads'

-filter_complex_threads nb_threads (global)
Defines how many threads are used to process a filter_complex graph. Similar to filter_threads but used for -filter_complex graphs only. The default is the number of available CPUs.

-filter_threads nb_threads (global)
Defines how many threads are used to process a filter pipeline. Each pipeline will produce a thread pool with this many threads available for parallel processing. The default is the number of available CPUs.

threads integer (decoding/encoding,video)
Set the number of threads to be used, in case the selected codec implementation supports multi-threading.

you can also set -preset ultrafast.

then there are the hevc threading options (man x265).

Threading, performance:
       --threads <integer>
              Number of threads for thread pool (0: detect CPU core count, default)

       -F/--frame-threads <integer>
              Number of concurrently encoded frames. 0: auto-determined by core count

       --[no-]wpp
              Enable Wavefront Parallel Processing. Default enabled

       --[no-]pmode
              Parallel mode analysis. Default disabled

       --[no-]pme
              Parallel motion estimation. Default disabled

       --[no-]asm <bool|int|string>
              Override CPU detection. Default: auto

 

> On Aug 6, 2017, at 6:16 01AM, Evert Vorster <[hidden email]> wrote:
>
> Hi there.
> I am using a quite convoluted filter in ffmpeg.
> -------------------------------------------------------------
> #!/bin/bash
> #This will split, defish, blend and re-assemble Samsung Gear 360 video
> map_dir="/data/Projects/RemapFilter"
> ffmpeg -y -i "$1" \
> -i $map_dir/lx.pgm -i $map_dir/ly.pgm -loop 1 \
> -i $map_dir/Alpha-Map.png \
> -i $map_dir/rx.pgm -i $map_dir/ry.pgm \
> -c:v hevc_nvenc -rc constqp -qp 26 -cq 26 \
> -filter_complex \
> "[0:v]eq=contrast=0.8:brightness=-0.01:gamma=0.7:saturation=0.8[bright]; \
> [bright]split=2[in1][in2]; \
> [in1]crop=in_w/2:in_h:0:in_h[l_crop];\
> [in2]crop=in_w/2:in_h:in_w/2:in_h[r_crop]; \
> [3]alphaextract[alf]; \
> [l_crop]vignette=angle=PI/4.6:mode=backward[l_vignette]; \
> [l_vignette][1][2]remap[l_remap]; \
> [r_crop]vignette=angle=PI/4.8:mode=backward[r_vignette]; \
> [r_vignette][4][5]remap[r_remap]; \
> [l_remap]crop=in_w:1920:0:(in_h-1920)/2[l_rm_crop]; \
> [r_remap]crop=in_w:1920:0:(in_h-1920)/2[r_rm_crop]; \
> [l_rm_crop][alf]alphamerge[l_rm_crop_a]; \
> [l_rm_crop_a]split=2[l_rm_crop1][l_rm_crop2]; \
> [l_rm_crop1]crop=in_w/2:in_h:0:0[l_rm_crop_l]; \
> [l_rm_crop2]crop=in_w/2:in_h:in_w/2:0[l_rm_crop_r]; \
> [0:v][r_rm_crop]overlay=(1920-(2028/2)):0[ov1]; \
> [ov1][l_rm_crop_l]overlay=((1920+2028/2)-(2028-1920)):0[ov2]; \
> [ov2][l_rm_crop_r]overlay=0:0[out]" \
> -map [out] -map 0:a "$1_Remapped.mp4"
> ---------------------------------------------------------
>
> When this runs, only one of my CPU is showing any activity.
> Is there a way of telling ffmpeg to process these steps in the filter in
> parallel?
>
> Kind regards,
> Evert Vorster
>
> Isometrix Acquistion Superchief
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Speeding up a script.

Evert Vorster
In reply to this post by Paul B Mahol
Hi there, Paul.

How would I be able to check which filter uses the most processing power?

I am encoding in hardware with my video card, so it's only the decoding and
filters that are eating up CPU.
What I am seeing is that only one CPU shows any load.

I have a suspicion that it is the remap filter that eats the most CPU, but
I am running two remaps in parrallel, so I would expect to see at least two
CPU showing load.

Kind regards,
-Evert Vorster-

On 6 August 2017 at 21:28, Paul B Mahol <[hidden email]> wrote:

> On 8/6/17, Evert Vorster <[hidden email]> wrote:
> > Hi there.
> > I am using a quite convoluted filter in ffmpeg.
> > -------------------------------------------------------------
> > #!/bin/bash
> > #This will split, defish, blend and re-assemble Samsung Gear 360 video
> > map_dir="/data/Projects/RemapFilter"
> > ffmpeg -y -i "$1" \
> > -i $map_dir/lx.pgm -i $map_dir/ly.pgm -loop 1 \
> > -i $map_dir/Alpha-Map.png \
> > -i $map_dir/rx.pgm -i $map_dir/ry.pgm \
> > -c:v hevc_nvenc -rc constqp -qp 26 -cq 26 \
> > -filter_complex \
> > "[0:v]eq=contrast=0.8:brightness=-0.01:gamma=0.7:saturation=0.8[bright];
> \
> >  [bright]split=2[in1][in2]; \
> >  [in1]crop=in_w/2:in_h:0:in_h[l_crop];\
> >  [in2]crop=in_w/2:in_h:in_w/2:in_h[r_crop]; \
> >  [3]alphaextract[alf]; \
> >  [l_crop]vignette=angle=PI/4.6:mode=backward[l_vignette]; \
> >  [l_vignette][1][2]remap[l_remap]; \
> >  [r_crop]vignette=angle=PI/4.8:mode=backward[r_vignette]; \
> >  [r_vignette][4][5]remap[r_remap]; \
> >  [l_remap]crop=in_w:1920:0:(in_h-1920)/2[l_rm_crop]; \
> >  [r_remap]crop=in_w:1920:0:(in_h-1920)/2[r_rm_crop]; \
> >  [l_rm_crop][alf]alphamerge[l_rm_crop_a]; \
> >  [l_rm_crop_a]split=2[l_rm_crop1][l_rm_crop2]; \
> >  [l_rm_crop1]crop=in_w/2:in_h:0:0[l_rm_crop_l]; \
> >  [l_rm_crop2]crop=in_w/2:in_h:in_w/2:0[l_rm_crop_r]; \
> >  [0:v][r_rm_crop]overlay=(1920-(2028/2)):0[ov1]; \
> >  [ov1][l_rm_crop_l]overlay=((1920+2028/2)-(2028-1920)):0[ov2]; \
> >  [ov2][l_rm_crop_r]overlay=0:0[out]" \
> > -map [out] -map 0:a "$1_Remapped.mp4"
> > ---------------------------------------------------------
> >
> > When this runs, only one of my CPU is showing any activity.
> > Is there a way of telling ffmpeg to process these steps in the filter in
> > parallel?
>
> Have you checked which filter takes most of processing times?
>
> >
> > Kind regards,
> > Evert Vorster
> >
> > Isometrix Acquistion Superchief
> > _______________________________________________
> > ffmpeg-user mailing list
> > [hidden email]
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> > [hidden email] with subject "unsubscribe".
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".




--
Evert Vorster
Isometrix Acquistion Superchief
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Loading...