Programming2019. 8. 21. 05:37

몇일동안 FFMPEG option을 찾아봤더니, FFMPEG front end tools들이 많더란.

Github link 가 있는 QWinFF를 소스를 받아 compile해봄. C++, QT4를 사용하는데 아주 간단하면서 아주 빠름. 여기서 조금 고쳐서 쓰면 되겠네. 비디오 붙이기랑 title넣기 몇가지만 더 있으면 그냥 settle하는건데.

 

그런데 FFMPEG은 option이 직관적이지 않아 아주 골치. 그량 transcoding하면 quality가 너무 안좋아짐. 뭐지...

QWinFF에 보면 Copy Audio/Copy Video (Do not re-encode) 라는 옵션을 체크하면 시간만 자르거나 할때 진짜 빠르고 퀄리티가꼭 같은데 그냥 default로 하면 완정 망한 비디오됨

Same Quantizer as Source라는 option이 있는데 FFMPEG option으로 -crf 23 이라고 나오는데, 현재 내 버전에서 인식을 못함. 아 된장.

 

video1          +    video 2 + video 3 = output.mp4  이게 안되나...

overlay. png +

------------------------------------------

QWinFF: http://qwinff.github.io/
AVANTI - FFmpeg/AviSynth GUI: http://avanti.arrozcru.com/
WinFF: http://winff.org/html_new/
FFmpegx (mac): http://www.FFmpegx.com/
Handbrake: http://handbrake.fr/
Mpeg streamclip: http://www.squared5.com/
FFmpegYAG (Windows / Linux): https://sourceforge.net/projects/ffmpegyag/

MAC에서는 FFworks https://www.ffworks.net/

 

https://github.com/amiaopensource/ffmpeg-amia-wiki/wiki/3)-Graphical-User-Interface-Applications-using-FFmpeg

 

amiaopensource/ffmpeg-amia-wiki

AMIA/DLF Hack day FFmpeg documentation, scripts and recipes geared toward archivists. - amiaopensource/ffmpeg-amia-wiki

github.com

------------------------------------------

Video 자르기 (codec copy no transcoding)


ffmpeg -y -i ./20190811_in.mp4 -strict experimental -vcodec copy -acodec copy -ss START -t END ./20190811_OUT.mp4

 

Video re-encoding이 필요할때는 원본화질을 보전하기 위해서 원본파일의 codec과 bitrate를 확인합니다. 아래 경우 video는 AVC, 24000k(23942kbps). Audio는 AAC, 156kbps. 원본보다 약간 roundup하는것이 좋을것 같음.

 


ffprobe ./INPUT.mp4

  Duration: 00:00:24.05, start: 0.000000, bitrate: 24233 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 23942 kb/s, SAR 1:1 DAR 16:9, 60.01 fps, 60 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2019-08-11T18:44:41.000000Z
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 156 kb/s (default)
    Metadata:
      creation_time   : 2019-08-11T18:44:41.000000Z
      handler_name    : SoundHandle

 

Overlay Title


ffmpeg -i ./INPUT.mp4 -i data/watermark.png -c:v nvenc -c:a aac -b:v 24000k -b:a 160k -filter_complex "[0:v][1:v]overlay=main_w-overlay_w:main_h-overlay_h" watermarked.mp4

 

Video 붙이기


ffmpeg -f concat -i mylist.txt -c copy output.mp4

https://orunson.tistory.com/entry/FFMPEG%EC%9C%BC%EB%A1%9C-%EB%B9%84%EB%94%94%EC%98%A4-%EB%B6%99%EC%9D%B4%EA%B8%B0

 

FFMPEG으로 비디오 붙이기

아래 두가지 방법이 가장 간단한듯. 아래글중 10초씩 자르는것과 붙이는 것, 앞에 Title자동으로 넣는것까지 3가지만 있으면 될듯. *concat demuxer $ cat mylist.txt file '/path/to/file1' file '/path/to/file2..

orunson.tistory.com

Posted by 쁘레드
Programming2019. 8. 20. 03:03

아래 두가지 방법이 가장 간단한듯. 아래글중 10초씩 자르는것과 붙이는 것, 앞에 Title자동으로 넣는것까지 3가지만 있으면 될듯.

 

*concat demuxer

$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

$ ffmpeg -f concat -i mylist.txt -c copy output.mp4
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

Note: -safe 0 is not required if the paths are relative but it seems required.

 

*concat protocol

ffmpeg -i "concat:input1|input2" -codec copy output.mkv

 

https://superuser.com/questions/1059245/ffmpeg-join-two-mp4-files-with-ffmpeg-on-command-line

 

ffmpeg join two mp4 files with ffmpeg on command line

I can successfully join multiple files using the following command: ffmpeg -f concat -i input.txt -codec copy output.mp4 The only problem with this command is that you need to read the filepaths ...

superuser.com

https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg

 

How to concatenate two MP4 files using FFmpeg?

I'm trying to concatenate two mp4 files using ffmpeg. I need this to be an automatic process hence why I chose ffmpeg. I'm converting the two files into .ts files and then concatenating them and ...

stackoverflow.com

 

Posted by 쁘레드
Programming2019. 8. 20. 02:11

lsof - list open files

!{command} ; last command 
vi !$   ; last argument 
!! ; last command 
"CTRL+R" for Repeating the Last Matching Command 
history | grep "keyword" 
egrep "ERROR|Exception" *.xml 
grep Exception logfile.txt | grep -v ERROR 
grep -c "Error" logfile.txt 
grep --context=6 successful logfile.txt 
grep 'Error|Exception' logfile.txt 
grep -i Error logfile.txt 
zgrep -i Error *.gz 
grep -w ERROR logfile.txt ; search whole word 
grep -l ERROR *.log  ; display file name which contains pattern 

Using Alias .bashrc or .profile 
pushd, popd, cd --- and cd ~ command. cd --- is best 

Ctrl+Z to suspend it and fg 1 or fg 2

 

https://dev.to/javinpaul/10-simple-linux-tips-which-save-50-of-my-time-in-the-command-line-4moo

 

10 simple Linux tips which save 50% of my time in the command line

My favorite Linux commands, tips, and tricks to work fast in the UNIX terminal. Every programmer or Linux user should know this to save time and typing.

dev.to

 

 

• finding host/domain name and IP address - hostname
• test network connection – ping
• getting network configuration – ifconfig
• Network connections, routing tables, interface statistics – netstat
• query DNS lookup name – nslookup
• communicate with another hostname – telnet
• outing steps that packets take to get to network host – traceroute
• view user information – finger
• checking status of destination host - telnet

 


hostname with no options displays the machine's hostname
hostname –d displays the domain name the machine belongs to
hostname –f displays the fully qualified host and domain name
hostname –i displays the IP address for the current machine

netstat -nap | grep port  #will display process id of application which is using that port
netstat -a  or netstat –all #will display all connections including TCP  and UDP  
netstat --tcp  or netstat –t #will display only TCP  connection
netstat --udp or netstat –u #will display only UDP  connection
netstat -g #will display all multicast network subscribed by this host.

nslookup blogger.com # find IP address of the SITE

#A handy utility to view the number of hops and response time to get to a remote system or website is traceroute
traceroute

#View user information, displays a user’s login name, real name, terminal name and write status.
#this is pretty old Unix command and rarely used nowadays.
finger

 



Read more: https://javarevisited.blogspot.com/2010/10/basic-networking-commands-in-linuxunix.html#ixzz5x4Ghj3Gd

Posted by 쁘레드
Programming2019. 8. 15. 01:42

18.10 Cosmic Cuttlefish

19.04 Disco Dingo

 

최근에 NVidia 드라이버 문제로 귀찮게 되어 잘 돌아가는 빌드머신을 Ubuntu 18.10 -> Ubuntu 19.04로 upgrade. USB가 있는데, 그거 꼽고 upgrade 쉽게할수 있으면 참 좋을텐데. 19.04 설치로 들어가니 upgrade는 안된다고 나와서 맨붕.


$ sudo apt update 
$ sudo apt upgrade
$ sudo apt dist-upgrade

#Remove all no longer required packages:
$ sudo apt autoremove

#Make sure release upgrade is normal
#this can be normal, lts, never. GUI setting is Software Updater
$vi /etc/update-manager/release-upgrades

$ sudo do-release-upgrade

역시나 NVidia! 430.40 버전이 계속 문제를 일으킴.

 


sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update
ubuntu-drivers devices
ubuntu-drivers autoinstall

 

하니 418.56 버전이 설치되었음. 그리고 정상으로. 헐~

Posted by 쁘레드
Programming2019. 8. 14. 06:31

가끔씩 핸드폰 비디오가 90도 돌아가 있는 상태로 저장된것을 봅니다. MP4 header에 orientation이 있어서 새로 transcoding하는 것은 안좋은 상황. 비손실과 속도까지 고려하면 헤더만 change하는것이 좋음

 

1. FFMPEG으로 transcoding

# rotate video 1=90 cw, 2=90 ccw
# -filter:v transpose=1

ffmpeg -n -i 20190811_000.mp4 -filter:v transpose=2 20190811_000_r.mp4

 

ffmpeg -i in.mov -vf "transpose=1" out.mov

0 = 90CounterCLockwise and Vertical Flip (default)

1 = 90Clockwise

2 = 90CounterClockwise

3 = 90Clockwise and Vertical Flip

 

2. VLCPlayer로

Tools >> Preferences, Show settings->check "All"

Video >> Filters >> check Rotate video filter

Tools > Effects and Filters > Video Effects > Geometry

TODO:저장되나?

 

3. MP4 Header만 손수 update

https://superuser.com/questions/1307158/change-rotation-flag-in-mp4-video-without-losing-metadata

 

Change rotation flag in MP4 video (without losing metadata)

I just want to change the rotation flag in a .mp4 video file. Many similar questions exist, most answers suggest using ffmpeg -i input.mp4 -map_metadata 0 -metadata:s:v rotate=90 -codec copy outpu...

superuser.com

open mp4 with hex editor and search for vide to find the metadata of the video track
some rows above (for my files mostly 9, sometimes 12) you should see trak...\tkhd

  • no rotation:

    00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40
  • 180°:

    FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40
  • 90° cw:

    00 00 00 00 00 01 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40
  • 90° ccw:

    00 00 00 00 FF FF 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40

 

4. EXIF 정보만 update

program이 EXIF을 읽는다면

http://owl.phy.queensu.ca/~phil/exiftool/

 

ExifTool by Phil Harvey

0 (Information Type) AFCP, AIFF, APE, APP0, APP1, APP11, APP12, APP13, APP14, APP15, APP4, APP5, APP6, APP8, ASF, Audible, CanonVRD, Composite, DICOM, DNG, DV, DjVu, Ducky, EXE, EXIF, ExifTool, FITS, FLAC, FLIR, File, Flash, FlashPix, Font, FotoStation, GI

owl.phy.queensu.ca

exiftool -Orientation='Rotate 90 CW' INPUT_FILE

exiftool -Orientation='Rotate 270 CW' INPUT_FILE

 

---------------

핸드폰으로 찍은 비디오가 참 화질이 좋은데, mediainfo로 보면 진자 기가맥히게 설정이 잘 되어있네요. transcoding/다시encoding해서 퀄리티를 유지하기가 진짜 어려울 정도


Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.2
Format settings                          : CABAC / 1 Ref Frames

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2

'Programming' 카테고리의 다른 글

10 simple Linux tips in the command line  (0) 2019.08.20
Ubuntu upgrade 18.10 -> 19.04  (0) 2019.08.15
FFMPEG으로 비디오 파일에서 10초만 짤라서 만들기  (0) 2019.08.13
linux kernel build on ubuntu  (0) 2019.03.07
MinGW-w64 install  (0) 2017.01.22
Posted by 쁘레드
Programming2019. 8. 13. 07:06

핸드폰으로 비디오 찍어서 후딱 편집해서 공유할때 좋은 tip1,

FFMPEG으로 자동으로 10초씩 짤라놓는 방법

ffmpeg -loglevel quiet -n -r 60 -ss 2 -t 10 -i 0613/20190613_000.mp4 test_10_sec.mp4
ffmpeg -loglevel quiet -n -r 60 -ss 2 -t 10 -c:v h264 -i 0613/20190613_000.mp4 test_10_sec2.mp4

ffmpeg -loglevel quiet -n -ss 2 -t 10 -i 0613/20190613_000.mp4 -c:v h264 test_10_sec3.mp4

 

h264 codec이 NVidia Card를 이용하지 않으면 최신 드라이버로 update하고 FFMPEG을 다시 빌드하면 저절로 nvenc_h264 codec을 선택하게 됨. 엄청 빠름.

 

----------------

-loglevel 
-n : never overwrite output file
-i : input file
-r : frame rate
-vcodec : video codec
-s : frame size WxH
-ss : start offset 00:00:30
-t : time duration 00:00:05

 

----------------

$ ffmpeg -hwaccels
ffmpeg version N-94455-g01994c93db Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1~18.10.1)
  configuration: 
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.100 / 58. 55.100
  libavformat    58. 30.100 / 58. 30.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.100 /  7. 58.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
Hardware acceleration methods:
vdpau
cuda
vaapi
cuvid

.....

-----------------

$ ffmpeg -codecs
ffmpeg version N-94455-g01994c93db Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1~18.10.1)
  configuration: 
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.100 / 58. 55.100
  libavformat    58. 30.100 / 58. 30.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.100 /  7. 58.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
Codecs:
 D..... = Decoding supported
 .E.... = Encoding supported
 ..V... = Video codec
 ..A... = Audio codec
 ..S... = Subtitle codec
 ...I.. = Intra frame-only codec
 ....L. = Lossy compression
 .....S = Lossless compression
 -------

 D.V.L. h263i                Intel H.263
 DEV.L. h263p                H.263+ / H.263-1998 / H.263 version 2
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_cuvid ) (encoders: h264_nvenc h264_v4l2m2m h264_vaapi nvenc nvenc_h264 )
 D.VIL. hap                  Vidvox Hap
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_v4l2m2m hevc_cuvid ) (encoders: nvenc_hevc hevc_nvenc hevc_v4l2m2m hevc_vaapi )

 D.V.L. msmpeg4v1            MPEG-4 part 2 Microsoft variant version 1
 DEV.L. msmpeg4v2            MPEG-4 part 2 Microsoft variant version 2
 DEV.L. msmpeg4v3            MPEG-4 part 2 Microsoft variant version 3 (decoders: msmpeg4 ) (encoders: msmpeg4 )

.....

-----------------

$ ffmpeg -encoders
ffmpeg version N-94455-g01994c93db Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1~18.10.1)
  configuration: 
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.100 / 58. 55.100
  libavformat    58. 30.100 / 58. 30.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.100 /  7. 58.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
Encoders:
 V..... = Video
 A..... = Audio
 S..... = Subtitle
 .F.... = Frame-level multithreading
 ..S... = Slice-level multithreading
 ...X.. = Codec is experimental
 ....B. = Supports draw_horiz_band
 .....D = Supports direct rendering method 1

....

 V..... h263                 H.263 / H.263-1996
 V..... h263_v4l2m2m         V4L2 mem2mem H.263 encoder wrapper (codec h263)
 V.S... h263p                H.263+ / H.263-1998 / H.263 version 2
 V..... h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder wrapper (codec h264)
 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V..... nvenc                NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_h264           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_hevc           NVIDIA NVENC hevc encoder (codec hevc)
 V..... hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)
 V..... hevc_v4l2m2m         V4L2 mem2mem HEVC encoder wrapper (codec hevc)
 V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)

.....

.....

FFMPEG으로 Rotate하기

# rotate video -filter:v transpose=1 or 2. 1=90 cw, 2=90 ccw
# -filter:v transpose=1

'Programming' 카테고리의 다른 글

Ubuntu upgrade 18.10 -> 19.04  (0) 2019.08.15
핸드폰 비디오 rotate하기  (0) 2019.08.14
linux kernel build on ubuntu  (0) 2019.03.07
MinGW-w64 install  (0) 2017.01.22
github에서 배우는 machine learning, deep learning  (0) 2017.01.07
Posted by 쁘레드
Programming2019. 3. 7. 03:06

Short note

---------

# 1. Clone the kernel to your local machine

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

$ cd linux-stable


# 1.1 optional Github mirror link, i prefer github over kernel.org

$ git clone https://github.com/torvalds/linux.git

$ cd linux


# 2. check kernel version

$ make kernelversion

$ uname -ra


# 3. Find the tag for the version you want

$ git tag -l | grep 4.20

v4.20

v4.20.rc...


# 4. Create a new branch with that tag

$ git checkout -b my4.20 v4.20


# 5. use Ubuntu proper config

# 5.1 use default defconfig for the system

$ make defconfig


# 5.2 use current ubuntu config, /boot/config-*

$ cp /boot/config-`uname -r` .config


# if same version or very close to current version

$ make oldconfig


# otherwise, choose default one, very safe

$ yes '' | make oldconfig


# 5.2.1 optional, change kernel options

$ make menuconfig


#make debian packages, *.deb will be copied in ../ (outside of linux build root)

$ make deb-pkg -j 16


# copied *.deb to target machine. Generally 3 files

# then install debian package. No particular order is required

$ sudo dpkg -i *.deb

Posted by 쁘레드
Programming2017. 1. 22. 07:54

공식 웹사이트는 여기지만 download받기 쉽지 않고.

http://mingw-w64.org/


SourceForge에서 다운받는것이 가장 간단함. 헐~

MinGW-w64 - for 32 and 64 bit Windows download | SourceForge.net

https://sourceforge.net/projects/mingw-w64/

-----------------

재밌는것은 윈도우에서 install할때 옵션이 재밌는데, 다른것은 친절하고 좋은것 같은데, thread를 win32를 지원한다는 것은 뭘까 궁금. WINE으로 win32 thread API를 지원할수 있다는 얘긴가? 그런다면 왜 option으로 뒀지? default로 둘다 다 지원하지. 이거 아닐것 같은데 뭘까.

Architecture i686=32bit, x86_x64=64bit

Thread posix or win32

Exception dwarf/sjlj, seh/sjlj


-----------------

Eclipse에다 추가할때는

Preference에다 MinGW bin PATH를 넣어줘야 toolset으로 인식합니다. default로 인식못할수도. default install path는.

C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin


Then, add the PATH variable to eclipse:
1) you need to go "windows\preferences\c/c++\build\environment"
2) then just click Add...
3) Set fields with the next values:
Name: PATH
Value: C:\MinGW\bin
where "C:\MinGW\bin" is your real path where mingw binaries are stored. (to make sure that you set the right path just go to this directory and find gcc.exe or g++.exe. if you find it it's ok.)
4) Choose "Append variables to native environment"
5) Press "Apply" and then "OK"

Posted by 쁘레드
Programming2017. 1. 7. 08:33


-----------------------

https://github.com/songrotek/Deep-Learning-Papers-Reading-Roadmap

-----------------------

https://github.com/ZuzooVn/machine-learning-for-software-engineers

http://sdtimes.com/sd-times-github-project-week-machine-learning-software-engineers/

'Programming' 카테고리의 다른 글

linux kernel build on ubuntu  (0) 2019.03.07
MinGW-w64 install  (0) 2017.01.22
github - awesomo  (0) 2017.01.07
GitHub projects of 2016 - to be updated  (0) 2017.01.07
github - 공짜책, Free Programming Books  (0) 2017.01.07
Posted by 쁘레드
Programming2017. 1. 7. 08:20

여러 언어로된 open source project를 모아놓고 소개시켜 줍니다.

C/C++는 아래 링크

https://github.com/lk-geimfari/awesomo/blob/master/languages/C_C%2B%2B.md

------------------

-----------------

https://github.com/lk-geimfari/awesomo

'Programming' 카테고리의 다른 글

MinGW-w64 install  (0) 2017.01.22
github에서 배우는 machine learning, deep learning  (0) 2017.01.07
GitHub projects of 2016 - to be updated  (0) 2017.01.07
github - 공짜책, Free Programming Books  (0) 2017.01.07
Python IDE - PyCharm  (0) 2016.07.07
Posted by 쁘레드