public boolean generateVideoBySequenceImages4Jcoder
		(String videoFilename, List<String> filelist,  int FPS) throws Exception {
		boolean result = false;
		SeekableByteChannel out = null;
		
		try {
			out = NIOUtils.writableFileChannel(videoFilename);
		      // for Android use: AndroidSequenceEncoder
            AWTSequenceEncoder encoder = new AWTSequenceEncoder(out, Rational.R(FPS, 1));
            for (String fnpath : filelist) {
            	LOGGER.info(fnpath);
            	
            	File img = new File(fnpath);
            	BufferedImage image = ImageIO.read(img);
            	encoder.encodeImage(image);
            }
            // Finalize the encoding, i.e. clear the buffers, write the header, etc.
            encoder.finish();
            result = true;
			
		} catch (Exception e) {
//			LOGGER.info("generateVideoBySequenceImages Exception: " + e);
			e.printStackTrace();
			
		} finally {
            NIOUtils.closeQuietly(out);
        }
		return result;
	}
    
    ----
    
    ...사용시
    
         String filefullNm = tempPath + fileName + format1.format(time)+ "_jcodec.avi";
        	if ( generateVideoBySequenceImages4Jcoder(filefullNm, filelist, Integer.valueOf(videofps)) ){
        		LOGGER.info("동영상저장 끝:" + filefullNm);
        		result = "true";
        		mv.addObject("filePath", filefullNm);
        	}

참조 : https://stackoverflow.com/questions/55232723/generate-mp4-video-file-by-sequence-png-images-in-java-8

 

Generate MP4 video file by sequence PNG images in Java 8

After testing several tools for Windows 10 found on the network, I had great difficulty in finding one that could carry around 5,000 PNG images in sequence and convert it into a video that was

stackoverflow.com

jcodec 사용하여 순서 이미지들로 동영상 파일 제작 

(sequence images to video)

 

그런데 문제가 발생한다.

계속 발생하는게 아니라 특정 조건에 아래와 같이 발생한다.

Component 1 width should be a multiple of 2 for colorspace: YUV420J

 

찾아 보면 이미지의 넓이와 크기가 짝수여야 한다는 것이다.

 

그래서 원천 이미지를 만들어 내는 곳에 소스를 변경해야 만 처리가 편한다.

사용은 아래와 같이

	
...
  BufferedImage bufImg = ImageIO.read(new ByteArrayInputStream(imageBytes));

  int width          = bufImg.getWidth() ;
  int height         = bufImg.getHeight();
  if ( (width %2) != 0 ) width++;
  if ( (height %2) != 0 ) height++;
  BufferedImage resizedImage = resizeImg(bufImg, width, height);

  ImageIO.write(resizedImage, "png", new File(filefullNm)); 
...
   
   
   	// 크기 재생산
    public BufferedImage resizeImg(BufferedImage inputImage, int width, int height)
            throws IOException {
    	//https://icarus8050.tistory.com/32

        BufferedImage outputImage =
                new BufferedImage(width, height, inputImage.getType());

        Graphics2D graphics2D = outputImage.createGraphics();
        graphics2D.drawImage(inputImage, 0, 0, width, height, null);
        graphics2D.dispose();

        return outputImage;
    }

이와 같이 하면 문제가 없어 질 것이다. 두둥탁~

참 

pom

 

<!--        jcodec   #######################################################################################-->
<dependency>
    <groupId>org.jcodec</groupId>
    <artifactId>jcodec</artifactId>
    <version>0.2.5</version>
</dependency>

<dependency>
    <groupId>org.jcodec</groupId>
    <artifactId>jcodec-javase</artifactId>
    <version>0.2.5</version>
</dependency>

 

메이븐도 필수~

 

 

 

 

1. 상태 

 파이썬을 2.7.5 ( Centos7 기본) 에서 2.7.14 로 업데이트 한 상태에서 python3.X 버전도 추가로 설치

설치 방법은 

https://zladnrms.tistory.com/19

 

 

[CentOS] Python 3.7 설치

기본적으로는 Python 2.7 이 설치되어있으므로, 그와 충돌을 피하기 위한 방법도 필요하다. 2.7 to 3.7 $ sudo yum install gcc openssl-devel  libffi-devel bzip2-devel $ wget https://www.python.org/ftp..

zladnrms.tistory.com

를 이용하여 마지막에

alternatives --install 를 이용한 버전 관리 처리를 추가로 진행

예)

alternatives --install /usr/bin/python python /usr/bin/python2 50

alternatives --install /usr/bin/python python /usr/bin/python3 60

 

여러 버전을 사용하기위한 설치로

설정 변경을 하려면 

alternatives --config python

으로 변경하여 사용한다.

 

까지는 좋았는데 yum 으로 설치 할 일이 생겨 설치 진행을 하니...


#yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.14 (default, Mar 31 2020, 02:52:27)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

If you cannot solve this problem yourself, please go to
the yum faq at: 

     yum.baseurl.org/wiki/Faq

 

----

위링크도 연결 되지 않는다.

 

여러 구글링하며 찾은 글을 봤더니 2.7 버전차이라고 생각하며 복구하는 여러 방법들이

돌아 다닌다.

1. 2.4 버전 변경 --> 이는 6.0 인듯합니다. 패스

2. /usr/bin/yum --> 파일열어 경로 첫줄에 경로 변경. 하지만 이미 버전이 업된 상태에서 처리가 쉽지 않고 기존

                          상태를 원상복구 하기가 어려워 졌다.  rpm 으로 재설치도 해봤다.

                          해보는것도 괜찮음

하지만, 

기본 상태로 원복은 한번 꼬이기 시작해서 인지 잘 되지 않음...

 

찾다가 다른 싸이트에 발견한 방법이 있음

 

 

# python
Python 2.7.14 (default, Mar 31 2020, 02:52:27)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import sys
>>> sys.path
....경로 A

이 경로와

# env -u LD_LIBRARY_PATH python

Python 2.7.5 (default, Nov  6 2016, 00:28:07) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import sys
>>> sys.path
....경로 B

A와 B의 상의 함에 있어 발생하는 문제로 반단이 된다고 함.

B 경로에  

'/usr/lib64/python2.7', '/usr/lib64/python2.7' ...

있다면 아래와 같이 설정을 변경해야 합니다. B 형태의 파이썬 실행 (밑줄)의 힌트로 보면

환경변수에 문제가 있음을 알수 있습니다.

 

alias yum='LD_LIBRARY_PATH=/usr/lib64 yum'

 

yum 실행을 환경변수의 구해 받기 않게 실행하게끔 하면 완료

 

개발과 환경 세팅은 참 언제나 신세계

그럼 즐프

증상 : NET::ERR_CERT_AUTHORITY_INVALID 나면서 거리뷰 이미지 표출 기능 로컬에서 개발시에 오류가 발생

 

서버에서는 자신의 인증 및 처리가 되어 있지만, 로컬에서는 처리가 되지 않아서 오류가 나는것으로 판단됩니다.

 

문의를 했더니 


ERR_CERT_COMMON_NAME_INVALID 해당 에러는 인증서에 올바른 subjectAlternativeName 확장이 없는 경우 연결이 비공개로 설정되지 않았다는 NET::ERR_CERT_COMMON_NAME_INVALID 오류가 사용자에게 표시되는 것으로 알려져있습니다.

 

자세한 사항은 고객센터 아래 URL을 확인을 부탁 드립니다.

https://support.google.com/chrome/a/answer/9813310?hl=ko

 

알려진 문제 - Google Chrome Enterprise 고객센터

도움이 되었나요? 어떻게 하면 개선할 수 있을까요? 예아니요

support.google.com


이렇게 답변이... 머라고 하는 건지 링크를 가봤지만, 모르겠다. 역시 구글링 뿐이구나 싶다.

 

1. 서버에 인증서 처리를 로컬에 반영하는 분들도 있었다. 처리 방법 하나

2. 크롬에서는 그냥 설정으로 처리를 통해 나오게 한다.

 

전 2번으로 했습니다. 

이거 보여줄려고 말이 길었습니다.

 

크롬 설정에서 좌측 개인정보 및 보안 메뉴서 사이트 설정을 들어가서 밑에서 3번째즈음.

안전하지 않은 콘텐츠 설정

안전하지 않은 콘텐츠 설정을 선택합니다.

 

허용에 pvimgl.map.naver.com 사이트를 추가합니다. 그러면 뽕~ 끝입니다.

그럼 즐프 입니다. ^^

 

 

  1. config.ini 만들기 

  2. 실행파일 가져가기

  3. 실행 테스트

변경개발시          : 파이썬 3.x , paramiko , ConfigParser, pyinstaller 설치

ini 수정 수 사용시 : ini 수정만 함, 서버스크립 작성 (1.2), tomcat war root 위치 설정확인

was : tomcat 8.5


1. 소스들

 1.1 ini 파일 생성 ( 예제 )

from configparser import ConfigParser
config = ConfigParser()
config['settings'] = {
'go': 'set -m; /home/tomcat/apache-tomcat-8.5.53/bin/startup.sh',
'stop': '/home/tomcat/apache-tomcat-8.5.53/bin/shutdown.sh',
'waslog': 'tail -f /home/tomcat/apache-tomcat-8.5.53/logs/catalina.out',
'rebilud': '/home/tomcat/bt.sh'
}

config['ssh'] = {
'id': 'root',
'pw': 'pw',
'host': '192.168.0.8',
'port': '22'
}

config['files'] = {
'upfile': 'C:/Users/torrms/Desktop/web.war',
'dwfile': '/home/tomcat/web.war'
}
with open('./config.ini', 'w') as f:
config.write(f)

 예파일  config.ini

[settings]
go = set -m; /home/tomcat/apache-tomcat-8.5.53/bin/startup.sh
stop = /home/tomcat/apache-tomcat-8.5.53/bin/shutdown.sh
waslog = tail -f /home/tomcat/apache-tomcat-8.5.53/logs/catalina.out
rebilud = /home/tomcat/bt.sh

[ssh]
id = root
pw = pw
host = 198.168.0.8
port = 22

[files]
upfile = C:/Users/torrms/Desktop/web.war
dwfile = /home/tomcat/web.war

 

 1.2  rebilud 를 위한 sh 생성 예

 - 직접 서버에서 실행권한 및 스크립트를 작성한다. 

 - war 반영 위치를 tomcat 에 설정한다. 또는 위치 확인

 - 경로는 반드시 full 경로 사용 .. 등의 사용은 안됨.

 -  예)

  > vi bt.sh

rm -rf web
mkdir web
cd web
jar xvf /home/tomcat/web.war
cd /home/tomcat
mv web.war ./bakwar/wab_20$(date +%Y%m%d_%H%M%S).war

 

 2. 실행파일 (첨부 확인) 또는 소스 (접는글 참조, 단 들여쓰기가 날라가네요 ^^)

더보기

#실행용으로 변경시 확인하세요 ^^

import paramiko
import os, sys
from configparser import ConfigParser

# ssh 명령을 수행한다.
# exit status를 리턴한다.
def ssh_execute(ssh, command, is_print=True):
# ssh 명령의 결과로 exit status를 구하는게 쉽지 않다.
# 따라서, 명령의 끝에 "mark=$?"를 출력하여,
# 최종 exit statud를 구할 수 있도록 한다.
exit_status=0
mark="ssh_helper_result_mark!!@@="
command=command+";echo " + mark + "$?"

try:
stdin, stdout, stderr = ssh.exec_command(command, get_pty=True)
except Exception as e:
print(e)
raise e

for line in stdout:
msg=line.strip('\n')
if (msg.startswith(mark)):
exit_status=msg[len(mark):]
else:
if (True == is_print):
print(line.strip('\n'))

return int(exit_status)

# sftp 상에 경로를 생성한다.
# remote 경로가 directory이면, is_dir에 True를 전달한다.
def mkdir_p(sftp, remote, is_dir=False):
dirs_ = []
if is_dir:
dir_ = remote
else:
dir_, basename = os.path.split(remote)
while len(dir_) > 1:
dirs_.append(dir_)
dir_, _ = os.path.split(dir_)

if len(dir_) == 1 and not dir_.startswith("/"):
dirs_.append(dir_) # For a remote path like y/x.txt

while len(dirs_):
dir_ = dirs_.pop()
try:
sftp.stat(dir_)
except:
print("making ... dir", dir_)
sftp.mkdir(dir_)

#https://greenfishblog.tistory.com/258
# sftp 상에 파일을 업로드한다.
# src_path에 dest_path로 업로드한다. 두개 모두 file full path여야 한다.
def file_upload(sftp, src_path, dest_path):
#mkdir_p(sftp, dest_path)
try:
sftp.put(src_path, dest_path)
except Exception as e:
print("fail to upload " + src_path + " ==> " + dest_path)
raise e
print("success to upload " + src_path + " ==> " + dest_path)
return "0"

def get_sftp(ssh):
try:
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
except Exception as e:
print(e)
raise e
return sftp


def get_ssh(host_ip, port, id, pw):
try:
# ssh client 생성
ssh = paramiko.SSHClient()

# ssh 정책 설정
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

# connect
ssh.connect(hostname=host_ip, port=port, username=id, password=pw)
except Exception as e:
print(e)
raise e

return ssh

# 프로세스 시작 ##################################
if __name__ == '__main__':
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

parser = ConfigParser()
parser.read('config.ini')

print(parser.sections())

ip = parser.get('ssh', 'host')
port = parser.get('ssh', 'port')
id = parser.get('ssh', 'id')
pwd = parser.get('ssh', 'pw')

ssh.connect(ip,port=port, username=id, password=pwd)

# 웹서버 명령
#exitcode = ssh_execute(ssh, "cat /project/EDIP/edip.sh")
#print("result : %d" % exitcode)
go = parser.get('settings', 'go')
stop = parser.get('settings', 'stop')
waslog = parser.get('settings', 'waslog')
rebilud = parser.get('settings', 'rebilud')

#자신의 반영 파일 로컬위치
upfile = parser.get('files', 'upfile')
dwfile = parser.get('files', 'dwfile')

print(go , stop, waslog, rebilud, upfile, dwfile)

print(os.path.exists(upfile))
if os.path.exists(upfile):
print(str(os.path.getsize(upfile)/1024/1024) + " MB")
else:
print("파일이 " + upfile + "존재 하지 않습니다.")
sys.exit()

#
#https://greenfishblog.tistory.com/258

# 정지
a = ssh_execute(ssh, stop)
while True:
if a == 0:
print("정지 : %d" % a)
break

#파일 업로드

sftp = get_sftp(ssh)
res = file_upload(sftp, upfile, dwfile)
while True:
if res == "0":
print("파일업로드 : %s" % res)
break



#반영
a = ssh_execute(ssh, rebilud)
while True:
if a == 0:
print("반영 : %d" % a)
break

#재시작
a = ssh_execute(ssh, go)
while True:
if a == 0:
print("재시작 : %d" % a)
break

#로그확인
a = ssh_execute(ssh, waslog)
while True:
if a == 0:
print("result : %d" % a)
break

ssh.close()
sftp.close()

 

autorebuild.zip
8.61MB

 

3. 실행 테스트

dos 창이 뜨면서 실행 및 등등의 작업이 진행됨을 알수 있다.

 

rabbitMQ server 설치 및 플러그인 화면 확인

 

CentsOS 7.x

* 서버는 무조건 알랭을 설치 (erlang)

 

참고

https://marshallslee.tistory.com/entry/CentOS-7%EC%97%90-RabbitMQ-%EC%84%A4%EC%B9%98%ED%95%98%EA%B8%B0

https://babtingdev.tistory.com/340

 

1. 패키지 업데이트

yum install epel-release

yum update

reboot

 

2. erlang 설치

wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm

rpm -Uvh erlang-solutions-1.0-1.noarch.rpm

yum install erlang

 

 

3. 설치 패키지 확인

https://packagecloud.io/rabbitmq/rabbitmq-server/

rpm -Uvh https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.12/rabbitmq-server-3.7.12-1.el7.noarch.rpm

 

rpm -Uvh https://packagecloud.io/rabbitmq/rabbitmq-server/packages/el/7/rabbitmq-server-3.7.23-1.el7.noarch.rpm

  • 최신

rpm -Uvh https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.2/rabbitmq-server-3.8.2-1.el7.noarch.rpm

 

  • 경고 잡기

[root@localhost ~]# rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey

[root@localhost ~]# rpm --import https://packagecloud.io/gpg.key

[root@localhost ~]# rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc

[root@localhost ~]# rpm -Uvh https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.2/rabbitmq-server-3.8.2-1.el7.noarch.rpm

 

  • 설치 에러 확인

Failed dependencies:

        socat is needed by rabbitmq-server-3.8.2-1.el7.noarch

    rabbitMq를 설치하는데 socat이 필요하다고 에러가 나는 경우 socat 설치

yum install socat

 

4. 모니터링 플러그인

rabbitmq-plugins enable rabbitmq_management

chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/

 

5. 방화벽

firewall-cmd --permanent --zone=public --add-port=4369/tcp

firewall-cmd --permanent --zone=public --add-port=5671/tcp

firewall-cmd --permanent --zone=public --add-port=5672/tcp

firewall-cmd --permanent --zone=public --add-port=15672/tcp

firewall-cmd --permanent --zone=public --add-port=25672/tcp

firewall-cmd --permanent --zone=public --add-port=61613/tcp

firewall-cmd --permanent --zone=public --add-port=61614/tcp

firewall-cmd --permanent --zone=public --add-port=1883/tcp

firewall-cmd --permanent --zone=public --add-port=8883/tcp

 

firewall-cmd --reload

 

6-1. 서비스 등록

systemctl enable rabbitmq-server

 

6-2. 서비스 시작

systemctl start rabbitmq-server

 

7. 사용자 등록

 

계정 추가 (admin 계정 test/test 계정

rabbitmqctl add_user 계정 패스워드

rabbitmqctl add_user admin 1234

 

계정을 관리자로 등록

rabbitmqctl set_user_tags 계정 administrator

rabbitmqctl set_user_tags admin administrator

 

권한 설정

rabbitmqctl set_permissions -p / 계정".*" ".*" ".*"

rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

 

8. 상태확인

rabbitmqctl status

 

systemctl restart rabbitmq-server

 

- 화면확인

http://192.168.5.114:15672/

 

 

9. 운영

 

  •  설정

https://www.rabbitmq.com/configure.html 

https://www.rabbitmq.com/configure.html#config-file-formats

 

중요 설정

RabbitMQ가 데이터를 저장하는 파티션의 디스크 여유 공간 제한.

heartbeat = 60

 

 

+ Recent posts