从 java 中执行的 shellscript 运行时 ffmpeg 中的段错误
我知道有一些问题涉及这个主题,但没有一个问题可以帮助我解决我的问题。
目的:
将从队列中拍摄的视频从 .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
I know there are some questions touching this subject, but none have helped me solve my issue.
Purpose:
Transcoding a video taken,from a queue, from .mov to h.264 (for now only that)
Solution:
Building a java application that gets the next in the queue, transcodes it then repeat
Problem:
I made a script to execute ffmpeg correctly wich I run from java (using ProcessBuilder).
Script runs without a problem in console, but running with java nets a Seg fault in ffmpeg..
Code in java:
ProcessBuilder pb = new ProcessBuilder("./ffmpeg-convert.sh",folder + recID);
pb.redirectErrorStream(true);
Process p = pb.start();
in the script file:
#!/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
and output in 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
缺少的是使用“-Xms64m -Xmx64m”运行java。显然我错过了用这些来运行应用程序:P
What was missing was running java with "-Xms64m -Xmx64m". Aparently I had missed running the application with those :P