ffmpeg refuses to encode video - ffmpeg

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.

Related

Chroma Subsampling with ffmpeg

I want to create an .mp4 output. But it doesn't work...
I'm using ffmpeg. My input video is a raw video and I want to have an raw video .mp4 at the end.
My code that i use:
ffmpeg.exe -i input.y4m -c:v rawvideo -vf format=yuv420p output.y4m
Can anyone help me out? :)
The correct syntax is: ffmpeg.exe -i input.y4m -pix_fmt yuv420p output.y4m
Test sample:
Build synthetic video y4m file in YUV444 format:
ffmpeg -f lavfi -i testsrc=rate=10:size=160x120 -t 5 -pix_fmt yuv444p input1.y4m
Convert from YUV444 to YUV420:
ffmpeg -i input1.y4m -pix_fmt yuv420p output1.y4m
You can also create AVI raw video:
ffmpeg -i input1.y4m -c:v rawvideo -pix_fmt yuv420p output1.avi
But you can't create raw mp4 video.
Following code: ffmpeg -i input1.y4m -c:v rawvideo -pix_fmt yuv420p output1.mp4 returns error message:
[mp4 # 00000140d77eb9c0] Could not find tag for codec rawvideo in stream #0, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
There is an error because mp4 container doesn't support raw video format.

FFMPEG hwaccel complex filters

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.

ffmpeg: "Impossible to convert between the formats" when using NVIDIA GPU hardware acceleration

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"

Encoding YUV to mP4 With qp to get max quality

I am trying to encode my YUV420 Raw format file into mp4. Here is the ffmpeg command
ffmpeg -f s16le -ar 44100 -ac 1 -i "0.a" -f rawvideo -pix_fmt yuv420p -s 480x480 -r 30 -i "0.v" -vcodec libx264 -profile:v baseline -preset ultrafast -qp 0 -b:v 1024k -g 30 -acodec libfdk_aac -ar 44100 -ac 1 -b:a 64k -f mp4 -movflags faststart "1438947231095.mp4"
If i remove qp = 0; it works however the quality is very low not sure why. If i put qp = 0 it doesn't work, What is wrong?
Getting this error
Error while opening encoder for output stream #0:0 - maybe incorrect parameters
The baseline profile doesn't support lossless H.264. You must use the High 4:4:4 Predictive profile instead:
-profile:v high444

Seek issue of HEVC streams with ffplay

I'm attempting to perform a seek operation in an MPEG-TS stream that contains a HEVC encoded bit stream. The HEVC stream is encoded using the following command;
ffmpeg -s:v 1920x1080 -i kimono.yuv -c:v libx265 -x265-params crf=23:fps=30:keyint=10:min-keyint=10 -c:a copy -f mpegts testhevc.ts
The seek operation is attempted with ffplay as;
ffplay testhevc.ts -ss 5 -vf showinfo
The information shown gives multiple initial errors with missing POCs, such as;
Could not find ref with POC 126
However, everything works fine when the same operation is performed with H.264. The encoding with H.264/AVC is performed as;
ffmpeg -s:v 1920x1080 -i kimono.yuv -c:v libx265 -c:v libx264 -crf 23 -r 30 -keyint_min 10 -g 10 -c:a copy -f mpegts testh264.ts
Is this an issue with the ffmpeg tools for HEVC or am I missing something in these commands?.
Thanks.

Resources