ffmpeg ile video edit etmek

Ağustos 16, 2011 § Yorum yok § Kalıcı bağlantı

Bir videoyu mpeg4e dönüştürmek

ffmpeg -i 4126_20071228004214.mp4 -f avi -vcodec mpeg4 -b 637k -acodec mp3 -ab 32k ../sonuc/32k_4126_20071228004214.mp4

libx264 ile multithread kullanarak (ffmpeg static build ile: http://dl.dropboxusercontent.com/u/24633983/ffmpeg/index.html ; http://dl.dropbox.com/u/24633983/ffmpeg/builds/ffmpeg-linux64-20130508.tar.bz2)

../ffmpeg -i "shuttle-flip.mp4" -codec:v libx264 -quality good -cpu-used 0 -b:v 4000k -profile:v baseline -level 30 -y -maxrate 4000k -y -bufsize 2000k -vf scale=-1:1080 -threads 2 -codec:a libvo_aacenc -b:a 128k "fullhd.mp4"

webm için

../ffmpeg -i "shuttle-flip.mp4" -codec:v libvpx -quality good -cpu-used 0 -b:v 2000k -qmin 10 -qmax 42 -maxrate 2000k -y -bufsize 2000k -vf scale=-1:720 -threads 2 -codec:a libvorbis -b:a 128k "webm.webm"

Not:-preset değerinin slow olması sıkıştırmanın oldukça iyi yapılacağı anlamına gelmektedir.
Yapılan denemede, slow ile oluşan dosya 570M iken ultrafast ile oluşan dosyanın 1.1G olduğu gözlemlenmiştir. Fakat slowda encoding süresi 59m58.255s iken ultrafastde encoding 9m6.937s zamanda tamamlanmıştır. -preset degeri ultrafast,veryfast,faster,fast,medium, slow,slower,veryslow,placebo olabilir.

Not: Daha detaylı bilhi için “x264 –help” kullanılabilir.

Not: -crf değeri ne kadar kayıp verilebileceğini belirler.
Verilen değer küçüldükçe kayıp azalır. Makul değerler 18-28 arasıdır. 0 değeri kayıpsızdır.

ffmpeg -i input -acodec copy -vcodec libx264 -preset slow -crf 22 output.mp4

Animasyon için tune edilmiş bir örnek:


ffmpeg -i input -acodec copy -vcodec libx264 -preset medium -tune animation 
    -profile baseline -level 3.0 -crf 20 output.mp4

Değişik level kullanımları mümkündür.
Örneğin:

    iPhone, iPod 5.5G
        --level 30 --profile baseline --vbv-bufsize 10000 --vbv-maxrate 10000


    iPod
        --level 1.3 --no-cabac --vbv-bufsize 768 --vbv-maxrate 768


    PSP
        --level 2.1 --vbv-bufsize 4000 --vbv-maxrate 4000


    Zune
        --level 30 --no-cabac --vbv-bufsize 10000 --vbv-maxrate 10000


    AppleTV
        --level 3.1 --no-cabac --vbv-bufsize 14000 --vbv-maxrate 14000


    PS3-Xbox360
        --level 4.1 --vbv-bufsize 62500 --vbv-maxrate 62500

Dosyanın bitrate verilerek belirli bir boyutta sonuçlanmasını sağlamak için 2 fazlı dönüşüm yapılabilir. Örneğin
Not:bitratei sabitlemek yerine crf kullanmak tavsiye edilir. Zira farklı bitratelerde aynı kalitede görüntü elde edilebilir. Kaynak

ffmpeg -i input -pass 1 -vcodec libx264 -preset fast -b 512k -f mp4 -an -y /dev/null \
    && ffmpeg -i input -pass 2 -vcodec libx264 -preset fast -b 512k -acodec libfaac \
    -ab 128k -ac 2 output.mp4

Kayıpsız H264 oluşturmak için:

ffmpeg -i input -vcodec libx264 -preset ultrafast -crf 0 -acodec copy output.mkv

Not: Kayıpsız video oluştururken -preset değeriyle yapılan denemelerde
-preset ultrafast iken
oluşan dosya 8.5G (9108193825) ve gerekli zaman 23m54.441s
-preset medium iken
oluşan dosya 6.6G (7070383360) ve gerekli zaman 99m18.887s
-preset placebo iken
oluşan dosya 6.6G (7036744106) ve gerekli zaman 433m10.011s

ffmpeg hakkına iyi bir kaynak

FFMpeg in static buildi. Herhangi bir bağımlılığı yoktur.
Static build referansı ve yeni versiyonları…

Tekrar eden dosyaların tesbiti

Ağustos 16, 2011 § Yorum yok § Kalıcı bağlantı

Birbirinin aynı olan dosyaları “fdupes” kullanarak tebit eebiliriz.

/var/www klasöründe arama yapmak için

fdupes /var/www

/var/www klasöründe recursive arama yapmak için

fdupes -r /var/www

/var/www klasöründe recursive arama yapıp tekrarları silmek için soru sorması içim

fdupes -rd /var/www

Şifre güvenliği

Ağustos 16, 2011 § Yorum yok § Kalıcı bağlantı

Maaaan, this isn’t my dad. This is cell phone!

Ağustos 11, 2011 § Yorum yok § Kalıcı bağlantı

Maun Suresinin Meali

Ağustos 2, 2011 § Yorum yok § Kalıcı bağlantı

بسم الله الرحمن الرحيم

Bismillāhirahmānirahīm

1.Dini yalanlayanı gördün mü?

2.İşte o, yetimi itip kakar;

3.Yoksulu doyurmaya teşvik etmez;

4.Yazıklar olsun o namaz kılanlara ki,

5.Onlar namazlarını ciddiye almazlar.

6.Onlar gösteriş yapanlardır,

7.Ve hayra da mâni olurlar.

 

Bilim Adamlarına Çağrı

Ağustos 2, 2011 § Yorum yok § Kalıcı bağlantı

Bu çağrı afillifilintalar.com dan alınmıştır.
Gayet yerinde bulunmuştur…

Bir insanın kendi dirseğini yalayamayacağını savunan bilimsel bir makale okudum. Bence bilim adına çok üzücü bir tablo bu. Oysa bugüne kadar bir insanın kendi dirseğini yalayabilmesi sağlanmalıydı. Bu kadar fon nereye harcandı? Vergilerim nereye gitti? Ben kendi dirseğimi yalayamayacaksam, kendi dirseğime hakettiği ilgiyi gösteremeyeceksem nasıl çağdaş bir insan olabilirim? Teknolojik ilerlemeler bir insanın kendi dirseğini yalamasını mümkün kılana kadar herkesi bilim adamlarını protestoya davet ediyorum. Beyaz önlüklü demogoji ustalarının “E sen de arkadaşının dirseğini yala, o da seninkini yalasın, o onun o onun derken toplumsal dayanışma doğsun” dediğini duyar gibiyim. Yok öyle efendim. Sen şişe dibi gözlüklü, ak saçlı biri olarak yan gelip yatacaksın ben de senin açığını bir başkasının dirseğinde kapayacağım? Adama sorarlar. Size köşe ayıran gazetelerin arka sayfalarına yazıktır. Burdan sesleniyorum: Derhal toparlanın. Dirsekleri ve dilleri düşünün. İşiniz ne.

BC’ye user parametresi girmek

Temmuz 25, 2011 § Yorum yok § Kalıcı bağlantı

Bunu başarmak için:

Öncelikle bc_yapilacakis isimli dosyayi olusturalim.
Dosyanın içeriği

d = a / b
print a," divided by ",b," with scale ",scale," is ",d
quit

Şimdi bc_userparametre.sh isimli shell dosyasını oluşturalım.
Dosyanın içeriği


# This is a shell script to request two numbers
# and pass those numbers to the bc interpreter
# for doing a calculation
echo -n "Enter numerator (top number) "
read var1
echo -n "Enter denominator (bottom number) "
read var2
echo -n "Enter scope (number of decimal places) "
read var3
cat <<eee > bc_parametreler
    a = $var1
    b = $var2
    scale = $var3
eee
bc -q bc_parametreler bc_yapilacakis
rm -f bc_parametreler
echo ""

Görüldüğü gibi bc_userparametre.sh dosyasi bc_parametreler isimli dosyayi oluşturuyor.
bc ise quite modda önce bc_parametreler sonra bc_yapilacakis dosyasını okuyarak işini tamamlıyor.

iostat, mpstat ile istatistik toplamak

Temmuz 21, 2011 § Yorum yok § Kalıcı bağlantı

iostat kullanımı:


$ iostat
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.72      1096.66      1598.70 2719068704 3963827344
sda1            178.20       773.45      1329.09 1917686794 3295354888
sda2             16.51       323.19       269.61  801326686  668472456
sdb             371.31       945.97      1073.33 2345452365 2661206408
sdb1            371.31       945.95      1073.33 2345396901 2661206408
sdc             408.03       207.05       972.42  513364213 2411023092
sdc1            408.03       207.03       972.42  513308749 2411023092

Sadece CPU kullanımını görmek

$ iostat -c
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Sadece disk I/O’unu görmek

$ iostat -d
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.71      1096.61      1598.63 2719068720 3963827704
sda1            178.20       773.41      1329.03 1917686810 3295355248
sda2             16.51       323.18       269.60  801326686  668472456
sdb             371.29       945.93      1073.28 2345452365 2661209192
sdb1            371.29       945.91      1073.28 2345396901 2661209192
sdc             408.01       207.04       972.38  513364213 2411024484
sdc1            408.01       207.02       972.38  513308749 2411024484

Network devicelarını ve NFS partitionlarının bilgilerini görmek:

$ iostat -n
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)        07/09/2011

avg-cpu:  %user   %nice    %sys %iowait   %idle
           4.33    0.01    1.16    0.31   94.19

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               2.83         0.35         5.39   29817402  457360056
sda1              3.32        50.18         4.57 4259963994  387641400
sda2              0.20         0.76         0.82   64685128   69718576
sdb               6.59        15.53        42.98 1318931178 3649084113
sdb1             11.80        15.53        42.98 1318713382 3649012985

Device:                  rBlk_nor/s   wBlk_nor/s   rBlk_dir/s   wBlk_dir/s   rBlk_svr/s   wBlk_svr/s
192.168.1.4:/home/data      90.67        0.00         0.00         0.00         5.33         0.00
192.168.1.4:/backup         8.74         0.00         0.00         0.00         8.74         0.00
192.168.1.8:/media          0.02         0.00         0.00         0.00         0.01         0.00

MB cinsinden istatistikleri görmek

$ iostat -m
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sda             194.70         0.54         0.78    1327670    1935463
sda1            178.19         0.38         0.65     936370    1609060
sda2             16.51         0.16         0.13     391272     326402
sdb             371.27         0.46         0.52    1145240    1299425
sdb1            371.27         0.46         0.52    1145213    1299425
sdc             407.99         0.10         0.47     250666    1177259
sdc1            407.99         0.10         0.47     250639    1177259

Belirli bir device ın istatistiklerini görmek

$ iostat -p sda
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.69      1096.51      1598.48 2719069928 3963829584
sda2            336.38        27.17        54.00   67365064  133905080
sda1            821.89         0.69       243.53    1720833  603892838

Genişletilmiş istatistikler için

$ iostat -x
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda              27.86    63.53 61.77 132.91  1096.46  1598.40    13.84     0.21    1.06   2.28  44.45
sda1              0.69    33.22 48.54 129.63   773.30  1328.84    11.80     1.39    7.82   2.28  40.57
sda2             27.16    30.32 13.23  3.28   323.13   269.56    35.90     0.55   32.96   3.44   5.68
sdb              39.15   215.16 202.20 169.04   945.80  1073.13     5.44     1.05    2.78   1.64  60.91
sdb1             39.15   215.16 202.20 169.04   945.77  1073.13     5.44     1.05    2.78   1.64  60.91
sdc               8.90     3.63 356.56 51.40   207.01   972.24     2.89     1.04    2.56   1.55  63.30
sdc1              8.90     3.63 356.55 51.40   206.99   972.24     2.89     1.04    2.56   1.55  63.30

Belirli bir partition için istatistikler

$ iostat -x sda1
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda1              0.69    33.21 48.54 129.62   773.23  1328.76    11.80     1.39    7.82   2.28  40.56

Belirli aralıklarla (2 saniyede bir) iostat çıktısnı güncellemek

$ iostat 2
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.67      1096.39      1598.33 2719070584 3963891256
sda1            178.16       773.26      1328.79 1917688482 3295418672
sda2             16.51       323.11       269.54  801326878  668472584
sdb             371.22       945.74      1073.08 2345454041 2661251200
sdb1            371.22       945.72      1073.08 2345398577 2661251200
sdc             407.93       207.00       972.19  513366813 2411036564
sdc1            407.93       206.98       972.19  513311349 2411036564
..

2 saniyede birr 3 kere çalıştırmak

iostat 2 3

mpstat kullanmak
mpstat ile CPU kullanım istatistikleri toplanabilir

$ mpstat
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

10:25:32 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
10:25:32 PM  all    5.68    0.00    0.49    2.03    0.01    0.02    0.00   91.77   

Her core için bilgi toplamak

$ mpstat -P ALL
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011      _x86_64_        (4 CPU)

10:28:04 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
10:28:04 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00   99.99
10:28:04 PM    0    0.01    0.00    0.01    0.01    0.00    0.00    0.00    0.00   99.98
10:28:04 PM    1    0.00    0.00    0.01    0.00    0.00    0.00    0.00    0.00   99.98
10:28:04 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
10:28:04 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

Bash exit status

Temmuz 21, 2011 § Yorum yok § Kalıcı bağlantı


cat exitstatus.sh
#! /bin/bash
 
echo -e "Successful execution"
echo -e "====================="
echo "hello world"
# Exit status returns 0, because the above command is a success.
echo "Exit status" $? 
 
echo -e "Incorrect usage"
echo -e "====================="
ls --option
# Incorrect usage, so exit status will be 2.
echo "Exit status" $? 
 
echo -e "Command Not found"
echo -e "====================="
bashscript
# Exit status returns 127, because bashscript command not found
echo "Exit status" $? 
 
echo -e "Command is not an executable"
echo -e "============================="
ls -l execution.sh
./execution.sh
# Exit status returns 126, because its not an executable.
echo "Exit status" $?

ethtool kullanımı

Temmuz 21, 2011 § Yorum yok § Kalıcı bağlantı

Nic’in özelliklerinin elde edilmesi

ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: d
        Wake-on: d
        Link detected: yes

Duplex değeri için 3 olasılık vardır

  • Full duplex : Enables sending and receiving of packets at the same time. This mode is used when the ethernet device is connected to a switch.
  • Half duplex : Enables either sending or receiving of packets at a single point of time. This mode is used when the ethernet device is connected to a hub.
  • Auto-negotiation : If enabled, the ethernet device itself decides whether to use either full duplex or half duplex based on the network the ethernet device attached to.

ethtool -s ile nic özellikleri değiştirilebilir.
autoneg özelliğini değiştirelim.

ifdown eth0
    eth0      device: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
    eth0      configuration: eth-bus-pci-0000:0b:00.0
 
ethtool  -s eth0 autoneg off
 
ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  Not reported
        Advertised auto-negotiation: No
        Speed: Unknown! (65535)
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: g
        Wake-on: g
        Link detected: no
# ifup eth0

Nic’in speed değerini sabitlemek için:

ethtool -s eth0 speed 100 autoneg off
 
ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  Not reported
        Advertised auto-negotiation: No
        Speed: Unknown! (65535)
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: g
        Wake-on: g
        Link detected: no

ethtool -i ile firmware ve driver özellikleri öğrenilebilir.

# ethtool -i eth0
driver: bnx2
version: 2.0.1-suse
firmware-version: 1.9.3
bus-info: 0000:04:00.0

Nic’in ağ istatistiklerini öğrenmek için ethtool -S kullanılabilir

# ethtool -S eth0
NIC statistics:
     rx_bytes: 74356477841
     rx_error_bytes: 0
     tx_bytes: 110725861146
     tx_error_bytes: 0
     rx_ucast_packets: 104169941
     rx_mcast_packets: 138831
     rx_bcast_packets: 59543904
     tx_ucast_packets: 118118510
     tx_mcast_packets: 10137453
     tx_bcast_packets: 2221841
     tx_mac_errors: 0
     tx_carrier_errors: 0
     rx_crc_errors: 0
     rx_align_errors: 0
     tx_single_collisions: 0
     tx_multi_collisions: 0
     tx_deferred: 0
     tx_excess_collisions: 0
     tx_late_collisions: 0
     tx_total_collisions: 0
     rx_fragments: 0
     rx_jabbers: 0
     rx_undersize_packets: 0
     rx_oversize_packets: 0
     rx_64_byte_packets: 61154057
     rx_65_to_127_byte_packets: 55038726
     rx_128_to_255_byte_packets: 426962
     rx_256_to_511_byte_packets: 3573763
     rx_512_to_1023_byte_packets: 893173
     rx_1024_to_1522_byte_packets: 42765995
     rx_1523_to_9022_byte_packets: 0
     tx_64_byte_packets: 3633165
     tx_65_to_127_byte_packets: 51169838
     tx_128_to_255_byte_packets: 3812067
     tx_256_to_511_byte_packets: 113766
     tx_512_to_1023_byte_packets: 104081
     tx_1024_to_1522_byte_packets: 71644887
     tx_1523_to_9022_byte_packets: 0
     rx_xon_frames: 0
     rx_xoff_frames: 0
     tx_xon_frames: 0
     tx_xoff_frames: 0
     rx_mac_ctrl_frames: 0
     rx_filtered_packets: 14596600
     rx_discards: 0
     rx_fw_discards: 0

Network düzgün çalışmıyorsa

  • Speed ve Duplex değerlerinin “Unknown” olmasına
  • Link detection değerinin No olmasına

bakılabilir.

Nic’in ledini yakmak için -p kullanılabilir

ethtool -p eth0