I know this can be done by simply removing -hwaccel cuvid BUT I was wondering how this hwuplaod / hwdownload complex filtering stuff actually works with ffmpeg.
T:\ffmpeg\bin\20181015-c27c7b4-win64-static\ffmpeg.exe -y -loglevel 48 -hwaccel_device 0 -hwaccel cuvid -c:v h264_cuvid -i "input.mp4" -i "watermark.png" -filter_complex "format=nv12,hwupload,overlay=0:0" -b:v 24000k -c:v h264_nvenc -c:a copy "output.mp4"
Parsed_format_0 # 00000250b79758c0] auto-inserting filter 'auto_scaler_0' between the filter 'graph 0 input from stream 0:0' and the filter 'Parsed_format_0'
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #1:0
This results in the errors above, however removing the -hwaccel_device 0 and -hwaccel cuvid allows ffmpeg to run and export as expected, however GPU (gtx1080ti) usage is only at about 25% and my cpu (i9-7900x sits around 80%). There is obviously a better way to work this.
Related
The command:
ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -resize 1920x1080 -i "Infinity.mkv" -vf "ass=Infinity.ass" -c:v h264_nvenc -preset slowest -crf 18 -c:a flac -af aformat=s32:48000 -compression_level 5 -strict -2 Infinity.mp4
results in:
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scale_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
Conversion failed!
I tried adding hwupload and hwdownload to the vf filters. The result was the same.
I'm working on FFMPEG with Jetson nano and PC.
I want to know the ordering element of FFMPEG can be effect in the result? Is it necessory to observe the ordering of elements?
In the concept of decoding and encoding streams:
ffmpeg -hwaccel cuvid -c:v h264_nvdec -c:v h264_cuvid -i input -c:v
h264_nvenc output
If I replace the -hwaccel cuvid with -c:v h264_nvdec, such as:
ffmpeg -c:v h264_nvdec -c:v h264_cuvid -hwaccel cuvid -i input -c:v
h264_nvenc output
Q1- May be these two above commands corecttly run, but in the backgrand these two commands have same operations and results?
Q2 -Or if I want to put -hwaccel cuvid after -i input, are these two commands have same operations and results?
I'm using ffmpeg from the command line on Windows 10 and I wanted to gave GPU acceleration a try to improve execution times. A simple cut command like this works fine and its execution time is reduced by 60-70%. Awesome.
ffmpeg -hwaccel cuvid -c:v h264_cuvid -ss 00:00:10 -i in.mp4 -c:v h264_nvenc out.mp4
Now I tried to use the -filter_complex flag to overlay, fade and translate a png image over a video. The working non-GPU enhanced command is this one:
ffmpeg -i in.mp4 -loop 1 -t 75 -i overlay.png -filter_complex "[1:v]fade=t=in:st=30:d=0.3:alpha=1,fade=t=out:st=35.7:d=0.3:alpha=1[png1];[0:v][png1]overlay=x='if(gte(t,30), (t-30)*10, NAN)'" -movflags +faststart out.mp4
Then, I added the GPU-related flags to the command like this.
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i in.mp4 -loop 1 -t 75 -i overlay.png -filter_complex "[1:v]fade=t=in:st=30:d=0.3:alpha=1,fade=t=out:st=35.7:d=0.3:alpha=1[png1];[0:v][png1]overlay=x='if(gte(t,30), 60-tanh((t-30)*30/5)*60, NAN)'" -movflags +faststart -c:v h264_nvenc out.mp4
But it won't work. I get this error.
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
I don't even know what it means. Can I actually run ANY ffmpeg command on the GPU with GPU acceleration? I've found some information about the hwupload_cuda flag but I'm not sure if I should use it and how. My attempts have failed so far.
Any advice on how I should modify the command to make it work on the GPU?
Just add
hwdownload,YOUR_FILTER,hwupload
like this:
ffmpeg.exe
-y
-hwaccel_device 2
-hwaccel cuvid
-c:v h264_cuvid
-i input.mp4
-vfhwdownload,format=nv12,drawtext=textfile=file.txt:x=0:y=0:fontfile='c\:\/windows\/fonts\/arial.ttf',hwupload
-c:v h264_nvenc
-f mp4 output.mp4"
I am trying to merge two mp4 files using ffmpeg command. My input files are not in same encoding so they are not merge with normal command. I have use below command but got exception.
Command: -
ffmpeg -i File_1.mp4 -i File_2.mp4 -filter_complex "[0:v]setsar=1[0v];[1:v]scale=720:576:force_original_aspect_ratio=decrease,setsar=1,pad=720:576:(ow-iw)/2:(oh-ih)/2[1v];[0v][0:a][1v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -c:v libx264 -crf 23 ffmpeg1.mp4
Exception I have got: -
[Parsed_concat_4 # 00000000067ea380] Input link in1:v0 parameters (size 720x576, SAR 1:1) do not match the corresponding
output link in0:v0 parameters (320x240, SAR 1:1)
[Parsed_concat_4 # 00000000067ea380] Failed to configure output pad on
Parsed_concat_4
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!
Please tell me what is the solution for that or any command which can help me out with merge any two mp4 file in windows using cmd.
The concat filter requires all its video inputs to have the same resolution and sample aspect ratio. The framerate and pixel format can differ, though the output may not be what you want.
So, in this command, alter the filtering of the first video input to match the second.
ffmpeg -i File_1.mp4 -i File_2.mp4 -filter_complex "[0:v]scale=720:576:force_original_aspect_ratio=decrease,setsar=1,pad=720:576:(ow-iw)/2:(oh-ih)/2[0v];[1:v]scale=720:576:force_original_aspect_ratio=decrease,setsar=1,pad=720:576:(ow-iw)/2:(oh-ih)/2[1v];[0v][0:a][1v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -c:v libx264 -crf 23 ffmpeg1.mp4
I use a p4000 card and ffmpeg with all requirements (driver , toolkit , cuda compile)
I want to put watermark on the video by this command
./bin/ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -i input.png -filter_complex "overlay=10:10" -c:v h264_nvenc output.mp4
but I encounter this error
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #1:0
Thanks for the advice
-hwaccel cuvid
Mean that decoded frame will go to hw encoder directly (not copy in system memory), so at this time it's impossible to add filters to decoded frame. Try remove -hwaccel cuvid, but speed will be slow.
https://trac.ffmpeg.org/wiki/HWAccelIntro#CUDACUVIDNVDEC