ffmpeg由于pid超多最大数报错(Error initializing threading)

ffmpeg转码转视频时出现以下情况

 

ffmpeg version 2.3.6 Copyright (c) 2000-2014 the FFmpeg developers

  built on Mar 24 2017 11:48:29 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-52)

  configuration: --enable-shared --disable-static --enable-memalign-hack --enable-libx264 --enable-gpl --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-pthreads

  libavutil      52. 92.100 / 52. 92.100

  libavcodec     55. 69.100 / 55. 69.100

  libavformat    55. 48.100 / 55. 48.100

  libavdevice    55. 13.102 / 55. 13.102

  libavfilter     4. 11.100 /  4. 11.100

  libswscale      2.  6.100 /  2.  6.100

  libswresample   0. 19.100 /  0. 19.100

  libpostproc    52.  3.100 / 52.  3.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/nfs/filesRoot/microclassFile/test28.MP4':

  Metadata:

    major_brand     : isom

    minor_version   : 512

    compatible_brands: isomiso2avc1mp41

    encoder         : Lavf56.36.100

  Duration: 00:07:10.32, start: 0.072562, bitrate: 226 kb/s

    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x600 [SAR 30:29 DAR 40:29], 92 kb/s, 25.20 fps, 25.20 tbr, 16128 tbn, 50.40 tbc (default)

    Metadata:

      handler_name    : VideoHandler

    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 127 kb/s (default)

    Metadata:

      handler_name    : SoundHandler

[AVFilterGraph @ 0xbc62a0] Error initializing threading.

[AVFilterGraph @ 0xbc62a0] Error creating filter 'null'

Error opening filters!

 

由于linuxpid超过最大的数导致 ffmpeg无资源可用。

 

解决办法:

首先在转码命令中加入参数 -thread (参考:http://ffmpeg.org/ffmpeg.html)

ffmpeg -i $original -threads:1 4 -ab 56 -ar 22050 -qscale 8 -codec:v libx264 -c:a copy -movflags faststart -r  15  -s 480*320  -y  $tmp  

 

然后修改最大的进程数

1. free 命令查看内存数

2. sysctl kernel.pid_max 查看最大进程数

3. ps -eLf | wc -l查看进程数(确认满了就修改最大值)

临时方法:

修改最大进程数后系统恢复
echo 1000000 > /proc/sys/kernel/pid_max

永久生效方法:
echo "kernel.pid_max=1000000 " >> /etc/sysctl.conf


sysctl -p

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
int _tmain(int argc, _TCHAR* argv[]) { currentAudioClock = 0; currentVideoClock = 0; currentBufferClock = 0; //currentPlayClock=0; CurrentVolume = SDL_MIX_MAXVOLUME; if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); return 1; } SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); SDL_EventState(SDL_USEREVENT, SDL_IGNORE); atexit(SDL_Quit);// 注册SDL_Quit,当退出时调用,使得退出时程序自动清理 //flag=2; //给音视频队列分配空间 videoQueue = (VideoQueue *)av_mallocz(sizeof(VideoQueue)); audioQueue = (AudioQueue *)av_mallocz(sizeof(AudioQueue)); //初始化音视频队列 VideoQueueInit(videoQueue); AudioQueueInit(audioQueue); char* url = "G:/上海滩.mp4"; //char* url = "G:/2014年5月26日17 12 00至2014年5月26日17 14 59.avi"; //char* url = "H:/视频/不当交易.The.Unjust.BD.MiniSD-TLF.mkv"; //char* url = "E:/BaiduMusic/Songs/Love Story - Taylor Swift.mp3"; decodeTid = SDL_CreateThread(DecodePacket, "DecodePacket", (void*)url); PlayVideoTid = SDL_CreateThread(PlayVideo, "PlayVideo", NULL); PlayAudioTid = SDL_CreateThread(PlayAudio, "PlayAudioTid", NULL); int tid; SDL_WaitThread(decodeTid, &tid); printf("decodeTid %d\n", tid); SDL_WaitThread(PlayVideoTid, &tid); printf("PlayVideoTid %d\n", tid); SDL_WaitThread(PlayAudioTid, &tid); printf("PlayAudioTid %d\n", tid); SDL_DestroyMutex(audioQueue->audioMutex); SDL_DestroyCond(audioQueue->audioCond); SDL_DestroyMutex(videoQueue->videoMutex); SDL_DestroyCond(videoQueue->videoCond); av_free(videoQueue); av_free(audioQueue); return 0; }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

翅膀君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值