airsonic-advanced / airsonic-advanced

GNU General Public License v3.0
1.26k stars 134 forks source link

Can't seek FLAC -> OPUS transcodes in the webUI #390

Closed awsms closed 4 years ago

awsms commented 4 years ago

Problem description

the opus transcodes i made witth ffmpeg aren't seekable. instead of having a seekable bar, i've the following text: Live Broadcast

Steps to reproduce

  1. put "ffmpeg -i %s -c:a libopus -b:a 96k -f opus -" in the first transcode step, "flac" in convert from, "convert to" opus
  2. enable the previously created transcoder in the Players menu
  3. play any song

System information

Additional notes

the default FLAC transcode options werks fine and the transcodes are perfectly seekable (ffmpeg -i %s -map 0:0 -b:a %bk -v 0 -f mp3 -)

randomnicode commented 4 years ago

The code checks for the presence of a bitrate variable "%b" in the last stage of the transcode to gauge if it can guess a range.

So try: ffmpeg -i %s -c:a libopus -b:a %bk -f opus - instead of hardcoding a bitrate. Select a bitrate in the client.

Here's the line in the code: https://github.com/airsonic-advanced/airsonic-advanced/blob/d311b152cee54574479f66fcccd98fe9143bcd5b/airsonic-main/src/main/java/org/airsonic/player/service/TranscodingService.java#L539

awsms commented 4 years ago

Thansk! I actually hardcoded this value because I systematically want to transcode @96kbps when I use opus.

randomnicode commented 4 years ago

Thansk! I actually hardcoded this value because I systematically want to transcode @96kbps when I use opus.

Select 96k in the client?

Mind closing the ticket?

awsms commented 4 years ago

I'm now having the exact same issue as https://github.com/airsonic/airsonic/issues/1783#issuecomment-673707549

2020-10-05 15:34:34.873  WARN --- o.a.p.c.StreamController                 : Stream output exceeded expected length of 8075448. It is likely that the transcoder is not adhering to the bitrate limit or the media source is corrupted or has grown larger

While transcoding a 24bit/96kHz FLAC with the following transcode settings:

ffmpeg -i %s -map 0:0 -acodec libvorbis -b:a %bk -f ogg -

So basically, I have the choice between not being able to seek in files, or missing between 5 and 10 seconds on each track?

randomnicode commented 4 years ago

Okay, so we've added some more config options so you can tell the transcoder to get a bigger byte budget when estimating the transcoded file size. Increase your time padding or byte padding in your transcoding settings and you should not have to miss 5 - 10 seconds on each track

awsms commented 4 years ago

Unfortunately, I'm still having the same issue with the latest snapshot, and the playback stops before the last minute of the song. Tried to tweak both bytes and ms values, but still the same.

2020-10-08 12:26:14.931  INFO --- o.a.p.s.CacheConfiguration$CacheLogger   : Cache Key: /data/Music/Tekno_Tribe_Hardtek/Labels/MackiTek_Records/[MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016 | EventType: REMOVED | Old value: [MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016 | New value: null
2020-10-08 12:26:14.933  INFO --- o.a.p.io.TranscodeInputStream            : Starting transcoder: [/opt/airsonic/transcode/ffmpeg][-i][/data/Music/Tekno_Tribe_Hardtek/Labels/MackiTek_Records/[MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016/A1 - En Route !.flac][-map][0:0][-acodec][libvorbis][-b:a][192k][-f][ogg][-]
2020-10-08 12:26:15.032  INFO --- o.a.p.s.CacheConfiguration$CacheLogger   : Cache Key: /data/Music/Tekno_Tribe_Hardtek/Labels/MackiTek_Records/[MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016 | EventType: CREATED | Old value: null | New value: [MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016
2020-10-08 12:26:25.082  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) ffmpeg version 4.3-2~18.04.york0 Copyright (c) 2000-2020 the FFmpeg developers
2020-10-08 12:26:25.082  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
2020-10-08 12:26:25.082  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   configuration: --prefix=/usr --extra-version='2~18.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libavutil      56. 51.100 / 56. 51.100
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libavcodec     58. 91.100 / 58. 91.100
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libavformat    58. 45.100 / 58. 45.100
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libavdevice    58. 10.100 / 58. 10.100
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libavfilter     7. 85.100 /  7. 85.100
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libavresample   4.  0.  0 /  4.  0.  0
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libswscale      5.  7.100 /  5.  7.100
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libswresample   3.  7.100 /  3.  7.100
2020-10-08 12:26:25.409  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   libpostproc    55.  7.100 / 55.  7.100
2020-10-08 12:26:26.679  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) Input #0, flac, from '/data/Music/Tekno_Tribe_Hardtek/Labels/MackiTek_Records/[MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016/A1 - En Route !.flac':
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   Metadata:
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     TITLE           : En Route !
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     ARTIST          : Keja
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     ALBUM           : MackiTek Records 31
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     DATE            : 2016
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     GENRE           : Techno
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     track           : 1
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   Duration: 00:12:05.01, start: 0.000000, bitrate: 874 kb/s
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 791x800 [SAR 1:1 DAR 791:800], 90k tbr, 90k tbn, 90k tbc (attached pic)
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     Metadata:
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       comment         : Cover (front)
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) Stream mapping:
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   Stream #0:0 -> #0:0 (flac (native) -> vorbis (libvorbis))
2020-10-08 12:26:28.314  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) Press [q] to stop, [?] for help
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) Output #0, ogg, to 'pipe:':
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)   Metadata:
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     TITLE           : En Route !
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     ARTIST          : Keja
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     ALBUM           : MackiTek Records 31
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     DATE            : 2016
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     GENRE           : Techno
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     track           : 1
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     encoder         : Lavf58.45.100
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     Stream #0:0: Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp (16 bit), 192 kb/s
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)     Metadata:
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       encoder         : Lavc58.91.100 libvorbis
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       TITLE           : En Route !
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       ARTIST          : Keja
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       ALBUM           : MackiTek Records 31
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       DATE            : 2016
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       GENRE           : Techno
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg)       TRACKNUMBER     : 1
2020-10-08 12:26:28.315  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=      25kB time=00:00:02.42 bitrate=  85.1kbits/s speed=4.85x    
2020-10-08 12:26:28.316  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=     585kB time=00:00:29.64 bitrate= 161.5kbits/s speed=18.5x    
2020-10-08 12:26:28.817  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    1230kB time=00:01:00.09 bitrate= 167.7kbits/s speed=28.6x    
2020-10-08 12:26:29.319  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    1881kB time=00:01:28.90 bitrate= 173.4kbits/s speed=34.1x    
2020-10-08 12:26:29.819  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    2525kB time=00:01:56.48 bitrate= 177.6kbits/s speed=37.5x    
2020-10-08 12:26:30.320  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    3243kB time=00:02:25.46 bitrate= 182.6kbits/s speed=40.3x    
2020-10-08 12:26:30.820  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    3956kB time=00:02:53.28 bitrate= 187.0kbits/s speed=42.2x    
2020-10-08 12:26:31.320  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    4635kB time=00:03:20.45 bitrate= 189.4kbits/s speed=43.5x    
2020-10-08 12:26:31.821  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    5315kB time=00:03:47.33 bitrate= 191.5kbits/s speed=44.5x    
2020-10-08 12:26:32.322  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    5999kB time=00:04:15.70 bitrate= 192.2kbits/s speed=45.6x    
2020-10-08 12:26:32.823  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    6696kB time=00:04:44.64 bitrate= 192.7kbits/s speed=46.6x    
2020-10-08 12:26:33.105  INFO --- o.a.p.s.CacheConfiguration$CacheLogger   : Cache Key: /data/Music/Tekno_Tribe_Hardtek/Labels/MackiTek_Records/[MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016 | EventType: REMOVED | Old value: [MACKITEK31] Keja-MackiTek_Records_31-(MACKITEKREC31)-VINYL-FLAC-2016 | New value: null
2020-10-08 12:26:33.192  INFO --- o.a.p.s.s.ListenBrainzScrobbler          : Successfully registered now playing for song 'En Route !' at ListenBrainz (https://api.listenbrainz.org/1/submit-listens): 2020-10-08T10:26:33.107720Z
2020-10-08 12:26:33.323  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    7049kB time=00:04:58.94 bitrate= 193.2kbits/s speed=45.2x    
2020-10-08 12:26:33.824  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    7760kB time=00:05:25.66 bitrate= 195.2kbits/s speed=45.8x    
2020-10-08 12:26:33.852  INFO --- o.a.p.s.s.LastFMScrobbler                : Successfully registered now playing for song 'En Route !' for user me at Last.fm: 2020-10-08T10:26:33.107571Z
2020-10-08 12:26:34.326  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    8455kB time=00:05:53.72 bitrate= 195.8kbits/s speed=46.5x    
2020-10-08 12:26:34.826  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    9173kB time=00:06:20.32 bitrate= 197.6kbits/s speed=46.9x    
2020-10-08 12:26:35.327  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=    9849kB time=00:06:48.37 bitrate= 197.6kbits/s speed=47.4x    
2020-10-08 12:26:35.829  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   10550kB time=00:07:16.10 bitrate= 198.2kbits/s speed=47.8x    
2020-10-08 12:26:36.330  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   11236kB time=00:07:44.50 bitrate= 198.2kbits/s speed=48.3x    
2020-10-08 12:26:36.831  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   11940kB time=00:08:12.74 bitrate= 198.5kbits/s speed=48.7x    
2020-10-08 12:26:37.332  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   12682kB time=00:08:40.81 bitrate= 199.5kbits/s speed=  49x    
2020-10-08 12:26:37.832  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   13406kB time=00:09:09.21 bitrate= 200.0kbits/s speed=49.4x    
2020-10-08 12:26:38.334  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   14146kB time=00:09:38.21 bitrate= 200.4kbits/s speed=49.8x    
2020-10-08 12:26:38.834  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   14844kB time=00:10:05.03 bitrate= 201.0kbits/s speed=49.9x    
2020-10-08 12:26:39.335  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   15598kB time=00:10:33.12 bitrate= 201.8kbits/s speed=50.2x    
2020-10-08 12:26:39.837  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   16316kB time=00:10:59.52 bitrate= 202.7kbits/s speed=50.3x    
2020-10-08 12:26:41.579  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   17030kB time=00:11:27.22 bitrate= 203.0kbits/s speed=46.2x    
2020-10-08 12:26:41.595  WARN --- o.a.p.c.StreamController                 : Stream output exceeded expected length of 17448170. It is likely that the transcoder is not adhering to the bitrate limit or the media source is corrupted or has grown larger
2020-10-08 12:26:42.080  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   17760kB time=00:11:56.57 bitrate= 203.0kbits/s speed=46.6x    
2020-10-08 12:26:42.211  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) size=   17962kB time=00:12:04.99 bitrate= 203.0kbits/s speed=46.8x    
2020-10-08 12:26:42.211  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) video:0kB audio:17839kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 0.690259%
randomnicode commented 4 years ago

Tried to tweak both bytes and ms values, but still the same.

What exactly did you "tweak"? What numbers did you provide?

These two lines are telling you exactly what you need:

2020-10-08 12:26:41.595  WARN --- o.a.p.c.StreamController                 : Stream output exceeded expected length of 17448170. It is likely that the transcoder is not adhering to the bitrate limit or the media source is corrupted or has grown larger
2020-10-08 12:26:42.211  INFO --- o.a.p.io.InputStreamReaderThread         : (/opt/airsonic/transcode/ffmpeg) video:0kB audio:17839kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 0.690259%

Your final transcode (for that file) is around 17839kb, but your byte budget (estimated) is only 17448170 bytes. Obviously it'll cut off: you have a deficit of around 818966 bytes!

You can add either raw byte counts to your budget or a more dynamic time count.

Let's do some preliminary math:

Note: Here is the expected length formula: https://github.com/airsonic-advanced/airsonic-advanced/blob/9d17b322f7e702a348e4eec3de1d098634e7ce6a/airsonic-main/src/main/java/org/airsonic/player/service/TranscodingService.java#L516-L518