Page 1 of 1

[SOLVED] mediabrowser accessing Linux: seg fault in ffmpeg

PostPosted: Sat Dec 22, 2012 1:37 am
by sailorickm
I just upgraded serviio on both Windows and Linux from 1.0.1 to 1.1, and took advantage of the 14 day trial of "Pro" to try out the mediabrowser.

Windows serves up video fine, but it fails on Linux. I assume it has to do with converting to FLV. I turned on DEBUG and found this:

  Code:
2012-12-21 15:58:21,862 DEBUG [ProcessExecutor] Starting ffmpeg -threads auto -i /home/rickm/Desktop/Video/House.S01E17.Role Model.avi -y -copyts -c:v flv -qscale:v 1 -r 24000/1001 -g 15 -c:a libmp3lame -b:a 96k -ar 44100 -ac 2 -map 0:0 -map 0:1 -sn -f flv /tmp/Serviio/transcoding-temp-2-flv_player-ORIGINAL.stf
2012-12-21 15:58:22,178 WARN  [ProcessExecutor] Process ffmpeg has a return code of 139! This is a possible error.


When I run ffmpeg from the command line, I get this:

  Code:
$ ffmpeg -threads auto -i /home/rickm/Desktop/Video/House.S01E17.Role\ Model.avi -y -copyts -c:v flv -qscale:v 1 -r 24000/1001 -g 15 -c:a libmp3lame -b:a 96k -ar 44100 -ac 2 -map 0:0 -map 0:1 -sn -f flv ./transcoding-temp-2-flv_player-ORIGINAL.stf
ffmpeg version N-42368-gbf53863 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 20 2012 22:25:38 with gcc 4.4.5
  configuration: --enable-static --disable-shared --bindir=/tmp/ffmpeg --disable-ffplay --disable-ffserver --enable-pthreads --disable-mmx --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3 --enable-librtmp --pkg-config=pkg-config
  libavutil      51. 64.100 / 51. 64.100
  libavcodec     54. 33.100 / 54. 33.100
  libavformat    54. 15.102 / 54. 15.102
  libavdevice    54.  1.100 / 54.  1.100
  libavfilter     3.  1.100 /  3.  1.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[mpeg4 @ 0x9757780] Invalid and inefficient vfw-avi packed B frames detected
Input #0, avi, from '/home/rickm/Desktop/Video/House.S01E17.Role Model.avi':
  Metadata:
    encoder         : Nandub v1.0rc2
  Duration: 00:44:08.81, start: 0.000000, bitrate: 1108 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16, 96 kb/s
[graph 0 input from stream 0:0 @ 0x9777610] w:624 h:352 pixfmt:yuv420p tb:125/2997 fr:2997/125 sar:1/1 sws_param:flags=2
[output stream 0:0 @ 0x9775630] No opaque field provided
[graph 1 input from stream 0:1 @ 0x97766d0] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
[auto-inserted resampler 0 @ 0x974fc00] chl:stereo fmt:s16 r:48000Hz -> chl:stereo fmt:s16 r:44100Hz
Output #0, flv, to './transcoding-temp-2-flv_player-ORIGINAL.stf':
  Metadata:
    encoder         : Lavf54.15.102
    Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 624x352 [SAR 1:1 DAR 39:22], q=2-31, 200 kb/s, 1k tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16, 96 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 -> flv)
  Stream #0:1 -> #0:1 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
Segmentation fault


I ran it with "strace -f" but it doesn't give me any clues:

  Code:
[pid 32176] write(2, "\33[0;39m", 7)    = 7
[pid 32176] write(2, "\33[0m", 4)       = 4
[pid 32176] write(2, "\33[0;39m", 7)    = 7
[pid 32176] write(2, "Press [q] to stop, [?] for help\n", 32Press [q] to stop, [] for help) = 32
[pid 32176] write(2, "\33[0m", 4)       = 4
[pid 32176] gettimeofday({1356139862, 379973}, NULL) = 0
[pid 32176] gettimeofday({1356139862, 380088}, NULL) = 0
[pid 32176] select(1, [0], NULL, NULL, {0, 0}) = 0 (Timeout)
[pid 32176] brk(0x9119000)              = 0x9119000
[pid 32176] gettimeofday({1356139862, 380906}, NULL) = 0
[pid 32178] set_robust_list(0xb5d44be0, 0xc) = 0
[pid 32178] futex(0x90e0a48, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>
[pid 32176] gettimeofday( <unfinished ...>
[pid 32179] set_robust_list(0xb5543be0, 0xc <unfinished ...>
[pid 32177] set_robust_list(0xb6545be0, 0xc <unfinished ...>
[pid 32179] <... set_robust_list resumed> ) = 0
[pid 32177] <... set_robust_list resumed> ) = 0
[pid 32179] futex(0x90e3d80, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>
[pid 32177] futex(0x90dd710, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>
[pid 32176] <... gettimeofday resumed> {1356139862, 383818}, NULL) = 0
[pid 32176] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 32179] +++ killed by SIGSEGV +++
[pid 32178] +++ killed by SIGSEGV +++
[pid 32177] +++ killed by SIGSEGV +++


mediabrowser on Windows serves up the file OK. My Sony TV and BD players can get the video from serviio on both Linux and Windows, but of course in these cases serviio is not transcoding to FLV.

Any ideas or suggestions?

Re: mediabrowser accessing Linux: seg fault in ffmpeg

PostPosted: Sat Dec 22, 2012 5:10 pm
by zip
Try a different version of ffmpeg, possibly download and compile the one from the serviio download page.

Re: mediabrowser accessing Linux: seg fault in ffmpeg

PostPosted: Sat Dec 22, 2012 6:30 pm
by sailorickm
zip, thanks for the reply!

The ffmpeg that was installed on my Debian squeeze system wasn't working (command-line args not recognized), so I already am running from the source downloaded from the serviio download page ( ffmpeg-N-42368-gbf53863.tar.gz ).

I didn't run the install though, I just copied ffmpeg into /usr/bin to replace the one that was there. I figured that should be OK since it's statically linked.

I thought of a test to try. I put an FLV file into my directory. Even though it's already FLV, mediabrowser still runs it through ffmpeg and it runs fine. That at least shows something?

Here's what the flv-to-flv transcoding looks like:

  Code:
2012-12-21 21:26:49,224 DEBUG [ProcessExecutor] Starting ffmpeg -i /home/rickm/Desktop/Video/Sultans_of_Swing_solo_Mark_Knopfler_Guitar_More_Knowledge_ab.flv -frames:v 1 -c:v copy -f h264 -bsf:v h264_mp4toannexb -an pipe:
2012-12-21 21:26:49,325 DEBUG [FFmpegMetadataRetriever] File '/home/rickm/Desktop/Video/Sultans_of_Swing_solo_Mark_Knopfler_Guitar_More_Knowledge_ab.flv' has H264 profile MAIN, levels [{H=3, RF=2.1}] and 3 ref frames
2012-12-21 21:26:49,326 DEBUG [LibraryManager] Metadata found via extractor EMBEDDED: VideoMetadata [title=Sultans_of_Swing_solo_Mark_Knopfler_Guitar_More_Knowledge_ab, filePath=/home/rickm/Desktop/Video/Sultans_of_Swing_solo_Mark_Knopfler_Guitar_More_Knowledge_ab.flv, fileSize=14060882, audioBitrate=53, audioCodec=AAC, audioStreamIndex=1, bitrate=861, channels=2, container=FLV, contentType=UNKNOWN, duration=130, episodeNumber=null, fps=30, frequency=44100, h264Levels={H=3, RF=2.1}, h264Profile=MAIN, ftyp=null, height=360, seasonNumber=null, seriesName=null, timestampType=null, videoBitrate=819, videoCodec=H264, videoFourCC=null, videoStreamIndex=0, width=640]
2012-12-21 21:26:49,326 DEBUG [VideoService] Adding video into database: Sultans_of_Swing_solo_Mark_Knopfler_Guitar_More_Knowledge_ab

Re: mediabrowser accessing Linux: seg fault in ffmpeg

PostPosted: Tue Dec 25, 2012 12:29 am
by sailorickm
I have some more info, but it's still failing.

Even though libmp3lame is linked into ffmpeg, the sahred library is also accessed:

  Code:
$ ldd /usr/bin/ffmpeg
...etc...
        libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0xb7170000)
...etc...


I see that my installed version of libmp3lame is 3.99, whereas serviio is built using 3.98. I grabbed the source for 3.98 and built the shared library. It still fails, but I compiled it debug to see where it's failing.

  Code:
Program received signal SIGFPE, Arithmetic exception.
0xb7a0e00b in lame_encode_buffer_interleaved (gfp=0x8e6cb28, buffer=0x9218340,
    nsamples=1152, mp3buf=0x8e7c4fc "", mp3buf_size=10792) at lame.c:1850
1850            in_buffer[0][i] = buffer[2 * i];
(gdb) where
#0  0xb7a0e00b in lame_encode_buffer_interleaved (gfp=0x8e6cb28,
    buffer=0x9218340, nsamples=1152, mp3buf=0x8e7c4fc "", mp3buf_size=10792)
    at lame.c:1850
#1  0x08468893 in ?? ()
#2  0x0809ad76 in ?? ()
(gdb) print i
$1 = 0
(gdb)


It fails the first time through this for loop:

  Code:
int
lame_encode_buffer_interleaved(lame_global_flags * gfp,
                               short int buffer[],
                               int nsamples, unsigned char *mp3buf, int mp3buf_size)
{
    lame_internal_flags *const gfc = gfp->internal_flags;
    int     i;
    sample_t *in_buffer[2];

    if (update_inbuffer_size(gfc, nsamples) != 0) {
        return -2;
    }

    in_buffer[0] = gfc->in_buffer_0;
    in_buffer[1] = gfc->in_buffer_1;

    for (i = 0; i < nsamples; i++) {
        in_buffer[0][i] = buffer[2 * i];
        in_buffer[1][i] = buffer[2 * i + 1];
    }
    return lame_encode_buffer_sample_t(gfp, in_buffer[0], in_buffer[1], nsamples, mp3buf,
                                       mp3buf_size);
}


That's as far as I got. Does this help any?

Re: mediabrowser accessing Linux: seg fault in ffmpeg

PostPosted: Tue Dec 25, 2012 10:45 am
by zip
Maybe you should ask the FFmpeg guys, I have no idea.

Re: mediabrowser accessing Linux: seg fault in ffmpeg **SOLV

PostPosted: Wed Dec 26, 2012 5:57 am
by sailorickm
I finally got it working.

The ffmpeg version on this site is "ffmpeg-N-42368-gbf53863", which appears to be v0.11. The ffmpeg website has one newer release: 1.0.1. I built and installed that, and it works now, even with my originally-installed lame 3.99 package (this site points to 3.98).