通過單反wifi同步照片到Android手機——使用Airnef Python腳本

前言

本人使用的是尼康D750,自帶wifi功能,奈何配套的Android App太難用了,至於怎麼難用,我這裏就不細說了,用過的都懂。總不能白瞎了wifi功能吧。找了一陣子發現了兩個第三方通過逆向工程製作的工具。一個是qDslrDashboard這個app,功能很強大,可以通過手機控制相機,也可以瀏覽下載相機的照片,還可以協助拍攝延時攝影。另一個就是Airnef,一個python腳本。對PC端有封裝GUI。可以實現照片拷貝下載,將指定時間點之後的照片下載下來,不會重複下載已刪除的照片,可以實時同步拍攝的照片。完全可以替代原廠渣渣的配套App。所以我就通過Termux搭建Python環境來運行Airnef

上面介紹的兩個工具索尼和佳能帶有wifi功能的相機也能使用

這樣我在手機上就非常輕鬆的實現了同步單反中jpeg照片功能。這裏簡單的做一下使用介紹

1. 使用Termux搭建Python運行環境

建議安裝oh-my-zsh,不想安裝的可以跳過

sh -c "$(curl -fsSL https://github.com/Cabbagec/termux-ohmyzsh/raw/master/install.sh)"
pkg update
pkg install python

2. 下載解壓Airnef到Android手機中

下載地址:http://www.testcams.com/airnef/Version_1.1/airnef_v1.1_Source.zip
我將腳本放在 /sdcard/scripts/airnef/airnefcmd.py

cd /sdcard
mkdir scripts
cd scripts
wget http://www.testcams.com/airnef/Version_1.1/airnef_v1.1_Source.zip
unzip airnef_v1.1_Source.zip
rm airnef_v1.1_Source.zip

3. 幫助說明

$ python /sdcard/scripts/airnef/airnefcmd.py -h 
airnef v1.1 - Wireless transfer of images/movies for Nikon cameras [GPL v3]
Copyright (c) TestCams.com, Time: 01/18/19 22:55:06, Py: 3.7.2, OS: Linux

usage: airnefcmd.py [-h] [--ipaddress addr]
                    [--action {getfiles,getsmallthumbs,getlargethumbs,listfiles}]
                    [--realtimedownload {disabled,afternormal,only}]
                    [--extlist extension [extension ...]] [--startdate date]
                    [--enddate date] [--outputdir path]
                    [--ifexists {uniquename,skip,overwrite,prompt,exit}]
                    [--downloadhistory {skipfiles,ignore,clear}]
                    [--onlyfolders camera_folder [camera_folder ...]]
                    [--excludefolders camera_folder [camera_folder ...]]
                    [--filenamespec spec] [--dirnamespec spec]
                    [--transferorder {oldestfirst,newestfirst}]
                    [--slot {firstfound,first,second,both}]
                    [--cameratransferlist {useifavail,exitifnotavail,ignore}]
                    [--downloadexec executable [arguments ...]]
                    [--downloadexec_extlist extension [extension ...]]
                    [--downloadexec_options option [option ...]]
                    [--realtimepollsecs seconds]
                    [--logginglevel {normal,verbose,debug}]

Wifi image transfer utility for Nikon cameras ([email protected])

optional arguments:
  -h, --help            show this help message and exit
  --ipaddress addr      IP address of camera. Default is "192.168.1.1"
  --action {getfiles,getsmallthumbs,getlargethumbs,listfiles}
                        Program action. Default is "getfiles"
  --realtimedownload {disabled,afternormal,only}
                        Download images from camera in realtime as they're
                        taken. 'afternormal' means realtime capture starts
                        after regular image download. 'only' skips normal
                        download and only captures realtime images. Default is
                        "disabled"
  --extlist extension [extension ...]
                        Type of image/file(s) to download. Ex: "--extlist
                        NEF". Multiple extensions can be specified. Use
                        "<NOEXT>" to include files that don't have extensions.
                        Default is to download all file types
  --startdate date      Only include image/file(s) captured on or later than
                        date. Date-only Ex: --startdate 12/05/14. Date+Time
                        Example: --startdate "12/05/14 15:30:00"
  --enddate date        Only include image/file(s) captured on or earlier than
                        date or date+time. Date without a specified time is
                        inclusive, so for example --enddate 06/12/14 is
                        interpreted as 06/12/14 23:59:59
  --outputdir path      Directory to store image/file(s) to. Default is
                        current directory. No ending backslash is necessary.
                        If path contains any spaces enclose it in double
                        quotes. Example: --outputdir "c:\My Documents"
  --ifexists {uniquename,skip,overwrite,prompt,exit}
                        Action to take if file with same name already exists.
                        Default is "uniquename"
  --downloadhistory {skipfiles,ignore,clear}
                        'skipfiles' means that files in history (ie,
                        previously downloaded) will be skipped and not
                        downloaded. Default is "skipfiles"
  --onlyfolders camera_folder [camera_folder ...]
                        Only include image/file(s) existing in specified
                        camera folders.. Ex: "--onlyfolders 100D7200
                        101D7200". Default is to include all folders
  --excludefolders camera_folder [camera_folder ...]
                        Exclude image/file(s) existing in specified camera
                        folders.. Ex: "--excludefolders 103D7200". Default is
                        no exclusions.
  --filenamespec spec   Optionally rename files using dynamic renaming engine.
                        See online help for documentation on 'spec'
  --dirnamespec spec    Optionally name directories using dynamic renaming
                        engine. See online help for documentation on 'spec'
  --transferorder {oldestfirst,newestfirst}
                        Transfer oldest or newest files first. Default is
                        "oldestfirst"
  --slot {firstfound,first,second,both}
                        Card slot on camera to read from. Default is
                        "firstfound", which means first populated slot
  --cameratransferlist {useifavail,exitifnotavail,ignore}
                        Decide how to handle images selected on camera.
                        Default is "useifavail"
  --downloadexec executable [arguments ...]
                        Launch application for each file downloaded
  --downloadexec_extlist extension [extension ...]
                        Type of files(s) by extension on wich to perform
                        --downloadexec on. Default is all file types
  --downloadexec_options option [option ...]
                        Options for launcing application. For example 'wait'
                        waits for launched app to exit before proceeding to
                        next download. See online help for more options
  --realtimepollsecs seconds
                        How often camera is polled for new images in realtime
                        mode, in seconds. Default is every 3 seconds
  --logginglevel {normal,verbose,debug}
                        Sets how much information is saved to the result log.
                        Default is "normal"

Options can also be specified from a file. Use !<filename>. Each word in the
file must be on its own line.

You can abbreviate any argument name provided you use enough characters to
uniquely distinguish it from other argument names.

Command-Line Examples:
  airnefcmd.py --extlist NEF MOV (download only raw images and MOV files)
  airnefcmd.py --downloadhistory ignore (dont skip files previously downloaded)

4. 使用別名簡化腳本使用

~/.zshrc 文件中加入(如果不是使用zsh作爲默認shell的話,則在~/.bashrc中加入)

#獲取今天的日期,這裏只拷貝今天的
date=`date +'%m/%d/%y'`
#實時拷貝拍攝的照片到手機
alias airnef_realtime="python /sdcard/scripts/airnef/airnefcmd.py --action getfiles --ipaddress 192.168.1.1 --realtimedownload only --logginglevel normal --extlist NEF JPG --outputdir /sdcard/DCIM/NIKON --ifexists skip --slot second --transferorder oldestfirst --cameratransferlist ignore --downloadexec sh /sdcard/scripts/airnef/previewImage.sh \"@pf@\""
#拷貝今天拍攝的照片到手機
alias airnef_copy_today="python /sdcard/scripts/airnef/airnefcmd.py --action getfiles --ipaddress 192.168.1.1 --realtimedownload disabled --logginglevel normal --extlist NEF JPG --outputdir /sdcard/DCIM/NIKON --ifexists skip --slot second --transferorder oldestfirst --startdate ${date} --cameratransferlist ignore --downloadexec sh /sdcard/scripts/airnef/scanner.sh \"@pf@\""
#拷貝所有新照片
alias airnef_copy="python /sdcard/scripts/airnef/airnefcmd.py --action getfiles --ipaddress 192.168.1.1 --realtimedownload disabled --logginglevel normal --extlist NEF JPG --outputdir /sdcard/DCIM/NIKON --ifexists skip --slot second --transferorder oldestfirst --cameratransferlist ignore --downloadexec sh /sdcard/scripts/airnef/scanner.sh \"@pf@\""
#拷貝所有新照片,並將監聽實時拍攝的照片
alias airnef_copy_realtime="airnef_copy && airnef_realtime"

實現圖片預覽的腳本
/sdcard/scripts/airnef/previewImage.sh

#!/system/bin/sh
echo "Preview Image"
#媒體掃描
am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://$1 > /dev/null 2>&1 &
am start -a android.intent.action.VIEW -t image/jpeg -d file://$1 > /dev/null 2>&1 &

媒體掃描腳本
/sdcard/scripts/airnef/scanner.sh

#!/system/bin/sh
am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://$1 > /dev/null 2>&1 &

5. 使用

連接相機wifi,然後打開termux,運行命令
在這裏插入圖片描述

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章