0

im playing with my video files, I want to convert them from mp4, mkv, wmv, avi, flv, mov... to webm.

So I have written this:

for file in *
    do   
if [ -f "$file" ]
    then     filename="${file%.*}"
    ../ffmpeg -hwaccel nvdec -hwaccel_device 0 -hwaccel_output_format cuda -i "$file" -c:v vp9 -b:v 0 -crf 31 -c:a libvorbis "$filename".webm
fi
done

As shown, I have compiler my own ffmpeg binary, with those options:

./configure --enable-gpl --enable-libx264 --enable-nonfree --enable-cuda-nvcc --enable-libvpx --enable-vaapi --enable-libvorbis  --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64

It works, but, with CPU I got speed 0,1x and with cuda... almost the same.

My CPU? 11th Gen Intel(R) Core(TM) i7-11800H

My GPU? GeForce RTX™ 3060 mobile

Filesize? 300-3000mb (same speed with any)

Is there anything I could do? (I also tried vp9_vaapi, getting

Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scale_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented

Any clue? Or do I have to give up?

Thanks

talonmies
  • 70,661
  • 34
  • 192
  • 269
uchi
  • 99
  • 9
  • 1
    According to [Wikipedia](https://en.wikipedia.org/wiki/Nvidia_NVENC), NVENC supports H.264 and H.265 codecs but not VP9 codec. `-hwaccel nvdec` applies only the decoder. `-c:v vp9` uses the CPU for encoding. `vp9_vaapi` (or `vp9_qsv`) may use Intel Quick Sync encoder, but you should put it after the `-i`. Try `ffmpeg -i "$file" -c:v vp9_vaapi -b:v 0 -crf 31 -c:a libvorbis "$filename".webm`. It may not work due to Linux drivers issues. – Rotem Feb 01 '23 at 20:38
  • Hi, i got [vost#0:0/vp9_vaapi @ 0x56240f5db9c0] Finishing stream without any data written to it. Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scale_0' [vost#0:0/vp9_vaapi @ 0x56240f5db9c0] Error configuring filter graph Exiting normally, received signal 2. I dont know what it means... – uchi Feb 01 '23 at 20:45
  • What is the video codec of the input? – Rotem Feb 01 '23 at 20:47
  • Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> vp9 (vp9_vaapi)) Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis)) – uchi Feb 01 '23 at 20:48
  • Try `ffmpeg -c:v h264_vaapi -i "$file" -c:v vp9_vaapi -b:v 0 -crf 31 -c:a libvorbis "$filename".webm` – Rotem Feb 01 '23 at 20:48
  • I got Unknown decoder 'h264_vaapi' which flag i need to add to ./configure? – uchi Feb 01 '23 at 20:51
  • I am using Windows (there is no VAAPI). I guess h264_vaapi is an encoder. Last try: `ffmpeg -c:v h264_qsv -i "$file" -c:v vp9_qsv -b:v 0 -crf 31 -c:a libvorbis "$filename".webm` – Rotem Feb 01 '23 at 20:54
  • Unknown decoder 'h264_qsv' Maybe in winfows could I have better performance? – uchi Feb 01 '23 at 20:56
  • I don't know, I would like to think that in Intel Gen 11 using Quick Sync is faster compared to CPU encoding. – Rotem Feb 01 '23 at 21:02
  • welll then, last question... my target is to get a video that could be played while is still downloaded... my first option was webm... but its very slow... mp4 avi and mkv are discarded because they dont let play the file until is complete... any options? aside ts or mpd – uchi Feb 01 '23 at 21:10
  • 1
    I don't know... is it really working with WebM? In case it does, you may try FLV with H.264 codec, or TS (mpeg-ts) with H.264 or H.265. – Rotem Feb 01 '23 at 21:16
  • Yes its working with webm, i will give a try to that options, thanks – uchi Feb 01 '23 at 21:25
  • it worked with h264 and .ts – uchi Feb 01 '23 at 21:34

1 Answers1

1

Well, after some tests, the bests results were obtained using

-c:v libvpx-vp9 -cpu-used 8 -deadline realtime 

speed increased from 0,05x to 1,12x slow, but, good enough.

Quality is good for me.

uchi
  • 99
  • 9