从java中执行的shellcript运行时ffmpeg中的Segfault

时间:2011-11-01 13:30:16

标签: java ubuntu process sh

我知道有一些问题涉及这个问题,但没有一个能帮助我解决我的问题。

目的:

将从队列中获取的视频从.mov转码为h.264(仅限于此)

解决方案:

构建一个获取队列中下一个的java应用程序,对其进行转码然后重复

问题:

我创建了一个脚本来正确执行ffmpeg,我从java运行(使用ProcessBuilder)。

脚本在控制台中运行没有问题,但是在java中运行会在ffmpeg中出现Seg故障..

java中的代码:

ProcessBuilder pb = new ProcessBuilder("./ffmpeg-convert.sh",folder + recID);
pb.redirectErrorStream(true);
Process p = pb.start();

在脚本文件中:

#!/bin/sh

echo Running script with argument: $*;

./ffmpeg/ffmpeg -i $1.mov -vcodec libx264 -fpre /ffmpeg/ffpresets/libx264-slow.ffpreset $1.flv >/tmp/trace.txt 2>&1 </dev/null

并在trace.txt中输出:

FFmpeg version git-d23845f, Copyright (c) 2000-2011 the FFmpeg developers
  built on Feb  9 2011 17:51:49 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvpx --enable-libmp3lame
  libavutil    50. 37. 0 / 50. 37. 0
  libavcore     0. 16. 1 /  0. 16. 1
  libavcodec   52.112. 0 / 52.112. 0
  libavformat  52. 98. 0 / 52. 98. 0
  libavdevice  52.  2. 3 / 52.  2. 3
  libavfilter   1. 75. 0 /  1. 75. 0
  libswscale    0. 12. 0 /  0. 12. 0
  libpostproc  51.  2. 0 / 51.  2. 0

Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 40.00 (40/1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/javarecorder/0896dd9e926a5852e5c7317ff5e91cd1446996dd.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2011-09-26 19:32:24
  Duration: 00:08:32.47, start: 0.000000, bitrate: 7344 kb/s
    Stream #0.0(eng): Video: qtrle, rgb24, 1280x800, 6638 kb/s, 8.08 fps, 40 tbr, 1k tbn, 1k tbc
    Metadata:
      creation_time   : 2011-09-26 19:32:24
    Stream #0.1(eng): Audio: pcm_s16be, 44100 Hz, 1 channels, s16, 705 kb/s
    Metadata:
      creation_time   : 2011-09-26 19:32:24
[buffer @ 0x432e050] w:1280 h:800 pixfmt:rgb24
[ffsink @ 0x4382740] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x4382a40] w:1280 h:800 fmt:rgb24 -> w:1280 h:800 fmt:yuv420p flags:0xa0000004
[libx264 @ 0x4375590] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x4375590] profile High, level 3.2
[libx264 @ 0x4375590] 264 - core 114 r1900 60ef1f8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=abr mbtree=1 bitrate=200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, flv, to '/var/www/javarecorder/0896dd9e926a5852e5c7317ff5e91cd1446996dd.flv':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2011-09-26 19:32:24
    encoder         : Lavf52.98.0
    Stream #0.0(eng): Video: libx264, yuv420p, 1280x800, q=0-69, 200 kb/s, 1k tbn, 40 tbc
    Metadata:
      creation_time   : 2011-09-26 19:32:24
    Stream #0.1(eng): Audio: libmp3lame, 44100 Hz, 1 channels, s16, 64 kb/s
    Metadata:
      creation_time   : 2011-09-26 19:32:24
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
Segmentation fault

1 个答案:

答案 0 :(得分:0)

缺少的是使用“-Xms64m -Xmx64m”运行java。显然我错过了运行应用程序:P