Ampache flac transcoding problem

Issue #62 new
Former user created an issue

Hi, Something goes wrong when Ampache is set up to transcode flac (downsample) to mp3. The same stream will be requested (and sent) 4 times and stream is corrupted. It looks like a handshake problem. It is not a delay problem, since I modified Ampache to send mp3 only when transcoding was complete. That does not solve the problem. Just Player 3.37. Android 4.0.2

Comments (3)

  1. Rémi Alvergnat

    Ampache can be configured to transcode files on demand (ie. FLAC to MP3). JUSTPLAYER can't read those files properly.

    In Ampache logs, it seems that JUSTPLAYER closes the connection too early.

    JUSTPLAYER sends a Range header in Http Request to Ampache server. (Related to the position of the progressbar in the UI, we wan't to get the media file at the position of the progressbar).

    But, when transcoding is enabled, Ampache has no other choice than replying with a full response (HTTP/200). Content-Length and Content-Range header won't be set.

    JUSTPLAYER seems to have trouble with this situation, requesting a partial content and reading a full HTTP response.

    Here is Ampache LOG when starting a FLAC file with MP3 transcoding configured. The same song is working on Ampache official client.

    2013-05-06 18:19:52 [ampache] (i18n) -> Setting locale to fr_FR.UTF-8 
    2013-05-06 18:19:52 [ampache] (i18n) -> gettext is native 
    2013-05-06 18:19:52 [admin] (session) -> 9b23ce4e2a92bacc004bafbcb78ce01a has been extended to Mon, 06 May 2013 20:19:52 +0200 extension length 7200 
    2013-05-06 18:19:52 [admin] (play) -> Transcoding because native streaming is unavailable 
    2013-05-06 18:19:52 [admin] (session) -> Session created:3742456f137267d1c0fbf37e0951da7a 
    2013-05-06 18:19:52 [admin] (transcode) -> Using default target format 
    2013-05-06 18:19:52 [admin] (transcode) -> Transcoding from flac to mp3 
    2013-05-06 18:19:52 [admin] (transcode) -> Command: avconv -i %FILE% Arguments: -vn -b:a %SAMPLE%K -c:a libmp3lame -f mp3 pipe:1 
    2013-05-06 18:19:52 [admin] (stream) -> Active transcoding streams: 0 
    2013-05-06 18:19:52 [admin] (stream) -> Configured bitrate is 320 
    2013-05-06 18:19:52 [admin] (stream) -> Final transcode bitrate is 320 
    2013-05-06 18:19:52 [admin] (downsample) -> Downsample command: avconv -i '/media/raid/medias/music/lossless/Amy Winehouse/Back to Black/10-He Can Only Hold Her.flac' -vn -b:a 320K -c:a libmp3lame -f mp3 pipe:1 
    2013-05-06 18:19:52 [admin] (play) -> Bad client behaviour. Content-Range header received, which we cannot fulfill due to transcoding 
    2013-05-06 18:19:55 [admin] (play) -> Content-Range was more than 131072 into the file, not collecting stats 
    2013-05-06 18:19:58 [admin] (transcode_cmd) -> avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->   built on Mar 30 2013 22:20:06 with gcc 4.7.2 
    2013-05-06 18:19:58 [admin] (transcode_cmd) -> [flac @ 0xc8ab40] max_analyze_duration reached 
    2013-05-06 18:19:58 [admin] (transcode_cmd) -> Input #0, flac, from '/media/raid/medias/music/lossless/Amy Winehouse/Back to Black/10-He Can Only Hold Her.flac': 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->   Metadata: 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_REFERENCE_LOUDNESS: 89.0 dB 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_TRACK_GAIN: -9.77 dB 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_TRACK_PEAK: 1.00000000 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_ALBUM_GAIN: -10.29 dB 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_ALBUM_PEAK: 1.00000000 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     TITLE           : He Can Only Hold Her 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     ARTIST          : Amy Winehouse 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     ALBUM           : Back To Black 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     track           : 10 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     DATE            : 2006 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     COMMENT         : Encoded by FLAC v1.1.3a with FLAC Frontend v1.7.1 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->   Duration: 00:02:48.58, bitrate: 889 kb/s 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     Stream #0.0: Audio: flac, 44100 Hz, 2 channels, s16 
    2013-05-06 18:19:58 [admin] (transcode_cmd) -> Output #0, mp3, to 'pipe:1': 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->   Metadata: 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_REFERENCE_LOUDNESS: 89.0 dB 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_TRACK_GAIN: -9.77 dB 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_TRACK_PEAK: 1.00000000 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_ALBUM_GAIN: -10.29 dB 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     REPLAYGAIN_ALBUM_PEAK: 1.00000000 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     TIT2            : He Can Only Hold Her 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     TPE1            : Amy Winehouse 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     TALB            : Back To Black 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     TRCK            : 10 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     TDRL            : 2006 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     COMMENT         : Encoded by FLAC v1.1.3a with FLAC Frontend v1.7.1 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     TSSE            : Lavf53.21.1 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->     Stream #0.0: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 320 kb/s 
    2013-05-06 18:19:58 [admin] (transcode_cmd) -> Stream mapping: 
    2013-05-06 18:19:58 [admin] (transcode_cmd) ->   Stream #0:0 -> #0:0 (flac -> libmp3lame) 
    2013-05-06 18:19:58 [admin] (transcode_cmd) -> Press ctrl-c to stop encoding 
    2013-05-06 18:19:58 [admin] (transcode_cmd) -> size=     141kB time=3.60 bitrate= 321.0kbits/s    
    size=     211kB time=5.38 bitrate= 320.6kbits/s    
    size=     276kB time=7.05 bitrate= 320.5kbits/s    
    
    2013-05-06 18:19:58 [admin] (play) -> Stream ended at 279131 (279131) bytes out of  
    

    See Stream ended at 279131, representing only a few seconds of music.

  2. masafumi terazono repo owner

    えーと、この問題としてまずAndroid2.3以前のMediaPlayerではURLの拡張子にmp3がついていないので再生をキャンセルするという仕様に問題がありました。 これは別の言い方をすると、たとえデータがMP3であっても拡張子がMP3でなければ再生してくれないということです。だからAmpacheのようにFlacをMP3に変換するような仕組みの場合URLがMP3のままなので再生されません。 そこで、今年の頭に暫定的な対応として、Flacの拡張子の部分をMP3に置き換えるように修正をしました。これによって再生ができるようになったことを確認しています。 しかし、そもそもURLに拡張子がついていないものを生成する場合はこれはできません。たとえば、OwnCloudなんかはURLに拡張子がついていません、Ampacheのバージョンによってはつけないものもあるかもしれないです。 あと、Andorid2.3以外の端末でも再生をキャンセルする仕様で実装しているものもあるかもしれないです。

    あと、考えられるケースとして、ContentLengthの違いです、AmpacheはTranscodeする前のサイズをContentLengthにいれているようです、Lenghtが違うと再生をしてくれないデバイスもありえます。

    --- translate in english

    On this issue To occur will AndroidOS2.3 below. Extension is because not play MediaPlayer the URL is not a ". mp3" in AndoidOS2.3 following reason.

    Once again, it will be canceled and not play. In other words, MediaPlayer is to determine whether or not to play in extension.

    Ampache will be able to be converted to MP3 Transcode by the Flac, but the path of the URL remains. Flac. So it does not play.

    The head of this year, it will be a temporary fix, but it has implemented a process to replace the MP3 when compulsory extension is not MP3. It has been confirmed that I was able to play by this.

    However, this would not fix enough. Maybe there is a case that does not play in devices other than 2.3, and you can not avoid this in Ampache to generate the URL in the first place have no extension.

    Then as in other cases, there will be problems in the ContentLength Ampache generated. It does not seem to correctly calculate the size of the file when you Transcode. There is also a device that this is not an issue in particular, but there might be some device also be a problem.

  3. m4rkus

    I have the same issue using the ampache transcoding to downsample an mp3. I'm using the latest ampache from github master. The problem seems to be the content-range header in the http-request. Ampache debug output:

    (play) -> Bad client behaviour. Content-Range header received, which we cannot fulfill due to transcoding
    

    Switching to http-client in the advanced settings of JustPlayer solved the problem for me.

  4. Log in to comment