treblereel / quake2-j2cl-port

Automatically exported from code.google.com/p/quake2-gwt-port
GNU General Public License v2.0
22 stars 3 forks source link

technology refresh #28

Closed jnorthrup closed 1 year ago

jnorthrup commented 1 year ago

pt 1 - ffmpeg on path replaces two installed encoder tools

changes - we don't search the path for tool, we just assume it's on the path. we could try --version or something harmless to test the resultcode but it wasn't precedent.

we write wav file to tmpfile just to be kind to the processbuilder logic and to give ffmpeg an input format to guess is '.wav'

ffmpeg encodes both output formats at once. i did not research opus audio and webp image conversion points in the code, but they would be excellent.

pt 2 - war plugin update.

tested - quarkus on 0.0.0.0 still launches and has audio.

tested - extra credit static github pages demo not working https://jnorthrup.github.io/quake2-j2cl-port/index.html in my gh-pages branch reports a 404 for ./resources/models as below. I am in over my head

image

treblereel commented 1 year ago

@jnorthrup very cool ! Thanks a million !

treblereel commented 1 year ago

@jnorthrup I have to rollback FFmpeg commit because I forgot to clear war folder to check if mp3 files created

jnorthrup commented 1 year ago

@jnorthrup I have to rollback FFmpeg commit because I forgot to clear war folder to check if mp3 files created

did i remove said clear? I'm not sure what you mean here.

jnorthrup commented 1 year ago

i did not see any operations which can be attributed to 'clear' in the old code.

however ffmpeg is not using the -y switch before the mp3 / opus

ProcessBuilder pb = new ProcessBuilder("ffmpeg", "-i", tmpPath, "-filter_complex", "[0:a]asplit[a1][a2]", "-map", "[a1]", "-qscale:a", "2","-y", outPath + ".mp3", "-map", "[a2]", "-qscale:a", "2","-y", outPath + ".ogg");

will overwrite

jnorthrup commented 1 year ago

iinm when ffmpeg fails to open an output file we can assume that the file is probably correct in this situation, so failfast only incurs the cost of reading the media headers of the source tempfil and the tempfile creation. to my knowledge this doesn't abort the loop and only borrows space in the /tmp dir until the process exits.

Files.exist is also a cheaper way to look for presumably correct media of the target name.

the ffmpeg tool is a single place to look for licenses and updates, the two original tools are dated and not receiving updates. i did not have both of these installed. (I still dont)

cheers

treblereel commented 1 year ago

@jnorthrup

i did not see any operations which can be attributed to 'clear' in the old code.

Yeap, I think I should add it. So I deleted the war folder and re-run Installer (FFmpeg is installed in my os and is on path env), but no mp3s were presented in the war folder.

jnorthrup commented 1 year ago

not all ffmpeg binaries include all codecs but mp3 and ogg are typical in most.

pay attention to the first line of ffmpeg mine says (among zillions of configs) --enable-libmp3lame --disable-libtwolame

i just cloned my repo from scratch and run Installer in intellij without maven build, this is one of the audios of many.

these are tiny wav files, it's hard to catch them scrolling by. the three configs that should be enabled are mp3,vorbis, and the plugins/filters

if you post your ffmpeg output for the creation i can help loook for the issue.


ffmpeg version 4.4.3 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11.3.0 (Gentoo 11.3.0 p7)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-4.4.3/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --strip=x86_64-pc-linux-gnu-strip --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-O2 -pipe -march=native' --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=oss --disable-indev=sndio --disable-outdev=oss --disable-outdev=sndio --enable-bzlib --enable-runtime-cpudetect --disable-debug --disable-gcrypt --enable-gnutls --disable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --disable-libxml2 --enable-lzma --enable-network --enable-opencl --disable-openssl --en
able-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --enable-vaapi --enable-vdpau --disable-vulkan --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --enable-openal --enable-opengl --disable-libv4l2 --disable-libpulse --enable-libdrm --enable-libjack --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libcodec2 --enable-libdav1d --disable-libfdk-aac --enable-libopenjpeg --disable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --enable-libopus --disable-libilbc --enable-librtmp --disable-libssh --disable-libspeex --disable-libsrt --enable-librsvg --enable-ffnvcodec --enable-libvorbis --disable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --disable-chromaprint --disable-cuda-llvm --disable-libflite --disable-frei0r --disable-libvmaf --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-l
ibass --disable-libtesseract --disable-lv2 --enable-libfreetype --disable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-amf --disable-libvo-amrwbenc --disable-libkvazaar --disable-libaom --enable-libmp3lame --disable-libopenh264 --disable-librav1e --disable-libsnappy --disable-libsvtav1 --disable-libtheora --disable-libtwolame --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-fma4 --disable-xop --cpu=host --disable-doc --disable-htmlpages --enable-manpages
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100

 libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100

Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from '/tmp/q2audio5259369416879691309.wav':
  Duration: 00:00:10.54, bitrate: 352 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 10.538095

  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s

Stream mapping:
  Stream #0:0 (pcm_s16le) -> asplit
  asplit:output0 -> Stream #0:0 (libmp3lame)
  asplit:output1 -> Stream #1:0 (libvorbis)
Press [q] to stop, [?] for help

Output #0, mp3, to '/vol/xfs01/work/quake2-j2cl-port/war/baseq2/sound/world/comp_hum3.wav.mp3':
  Metadata:
    TSSE            : Lavf58.76.100
  Chapters:
    Chapter #0:0: start 0.000000, end 10.538095

  Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p
    Metadata:
      encoder         : Lavc58.134.100 libmp3lame

Output #1, ogg, to '/vol/xfs01/work/quake2-j2cl-port/war/baseq2/sound/world/comp_hum3.wav.ogg':
  Metadata:
    encoder         : Lavf58.76.100
  Chapters:
    Chapter #1:0: start 0.000000, end 10.538095
  Stream #1:0: Audio: vorbis, 22050 Hz, mono, fltp
    Metadata:
      encoder         : Lavc58.134.100 libvorbis

size=       0kB time=00:00:00.01 bitrate= 190.9kbits/s speed=N/A    
size=      79kB time=00:00:10.53 bitrate=  61.6kbits/s speed= 229x    
video:0kB audio:123kB subtitle:0kB other streams:0kB global headers:3kB muxing overhead: unknown
jnorthrup commented 1 year ago

one more thing, the README mentions that adding the media to the war file is a whole seperate step than the war jar. ant-maven-plugin copy task would be good here.

To copy the baseq2 directory from the war directory to server/src/main/resources/META-INF/resources/ as part of the build process, you can use the maven-resources-plugin in your pom.xml file.

Add the following to your pom.xml file:

<build>
  <resources>
    <resource>
      <directory>war</directory>
      <includes>
        <include>baseq2</include>
      </includes>
      <targetPath>${basedir}/server/src/main/resources/META-INF/resources</targetPath>
    </resource>
  </resources>
  ...
</build>

This will cause Maven to include all files and directories in the war/baseq2 directory in the built artifact, and place them in the server/src/main/resources/META-INF/resources directory.

jnorthrup commented 1 year ago

more true


<build>
  <resources>
    <resource>
      <directory>war</directory>
      <includes>
        <include>baseq2</include>
      </includes>
      <targetPath>${basedir}/server/src/main/resources/META-INF/resources</targetPath>
    </resource>
  </resources>
  ...
</build>
treblereel commented 1 year ago

Yeap, thanks, I'll definitely check this. Buy the way, maybe it's possible to convert wave to mp3 (or maybe ogg) with javax.audio ?

treblereel commented 1 year ago

more true

<build>
  <resources>
    <resource>
      <directory>war</directory>
      <includes>
        <include>baseq2</include>
      </includes>
      <targetPath>${basedir}/server/src/main/resources/META-INF/resources</targetPath>
    </resource>
  </resources>
  ...
</build>

hmmm, I use quarkus at server side, I have to check if it can grab resources, defined in section. With commot war files, yes, it works.

Some time ago, niloc312 asked me to write bash script, but I was a a little busy (or lazy) for it :(

jnorthrup commented 1 year ago

no idea. the win is opus. check this crazy format demo

https://opus-codec.org/examples/ "Bitrate scalability" this is mindblowing for any single codec and is also browser-native (ffmpeg baked in to chrome, mozilla, others). [image: image.png] this is endgame, in more ways than one. When the ibm patent on arithmetic compression expired opus was built on it. this is as close to shannon's limit as anything.

On Tue, Jan 10, 2023 at 1:29 PM Dmitrii Tikhomirov @.***> wrote:

Yeap, thanks, I'll definitely check this. Buy the way, maybe it's possible to convert wave to mp3 with java.audio ?

— Reply to this email directly, view it on GitHub https://github.com/treblereel/quake2-j2cl-port/pull/28#issuecomment-1376755343, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAR6KUDJGVVRPDTYYIVTELWRTXSBANCNFSM6AAAAAAS7UUFFM . You are receiving this because you were mentioned.Message ID: @.***>

jnorthrup commented 1 year ago

hmmm, I use quarkus at server side, I have to check if it can grab resources, defined in section. With commot war files, yes, it works.

Some time ago, niloc312 asked me to write bash script, but I was a a little busy (or lazy) for it :(

i asked chatgpt and i expected some plugin like maven-ant-plugin which is perfect but i don't have any simple examples to share they are all masochist efforts. chatgpt gave back something typically lowball, but not very scary