0

im running ubuntu VPS (no GUI) and just trying to convert a bunch(approx 100-200) of short clips that are spread into folders A/B/C/ETC - folders SET1/SET2/SET3/ETC and then Scene1.mkv etc. Ive tried with FFMPEG and it converts to mp4 but still HEVC command

for f in *.mkv; do ffmpeg -i "$f" -c:v copy -bsf:v h264_mp4toannexb -vcodec libx264 -c:a aac -preset veryfast "${f%%mkv}mp4"; done

even tried the codec hevc_mp4toannexb but receive the error:

Codec 'h264' (27) is not supported by the bitstream filter 'hevc_mp4toannexb'. Supported codecs are: hevc (173)Error initializing bitstream filter: hevc_mp4toannexb Error initializing output stream 0:0 -- (theyre definitely H265, cant even play on windows media player because of the HEVC error, only VLC player)

decided to give HandBrakeCli a go.

HandBrakeCLI -i scene1.mkv -o scene1.mp4 -e x264 -q 20 -B 160

works perfectly, but now going through stackoverflow to find a bulk code that works. Ive found many but none seem to work. ive tried:

for %F in *.mkv do HandBrakeCLI -e x264 -q 20 -B 160 -i "%F" -o "%~nF.mp4"

blanks out.

and

for %%F in *.mkv;
 do HandBrakeCLI -i -Z "Fast 1080p30" -o %%~nF.mp4 -e x264 -q 20 -B 160;
done

with the error:

bash: `%%F': not a valid identifier

and even tried some solutions like > HandBrakeCLI bash script convert all videos in a folder but with no luck.

any help would be greatly appreciated. i just cant

Michaelp
  • 31
  • 3
  • `for %%F ...` is not valid bash syntax. You should probably write `for F in *.mkv`. I'm not sure exactly what you are trying to do later when you wrote `%%~nF.mp4` but there's probably an issue as well – Aserre Nov 30 '21 at 16:11
  • Ah, I think I understood. If you want to rename your file from mkv to mp4, use the syntax you had in your first command : `"${F%%mkv}mp4"` – Aserre Nov 30 '21 at 16:15
  • pretty much. all im trying to do is convert .mkv to .mp4 as H264, thats it. same filename just a different extension and video codec. but yes, even when changing to F and/or changing ending to "${F%%mkv}mp4" then its just 'file not found' error – Michaelp Nov 30 '21 at 16:20
  • you've not specified a `-i` option in your second command line. Try `-i "$F"` – Aserre Nov 30 '21 at 16:32

0 Answers0