[HOWTO]Use ffmpeg on android - Android General

This is a quick tip about how to use FFmpeg on android.
- Download FFmpeg Android Java.
- Open it and put the commands properly on the text box and hit "Run".
Examples:
Mux two separate audio and video files into a single one
Code:
-y -i /sdcard/video.mp4 -i /sdcard/audio.m4a -map 0 -map 1 -codec copy /sdcard/result.mp4
Mux video and two separate audio streams
Code:
-y -i /sdcard/video.mp4 -i /sdcard/audio1.mp3 -i /sdcard/audio2.ogg -map 0:0 -map 1:0 -map 2:0 -codec copy /sdcard/result.mkv
http://cfc.kizzx2.com/index.php/muxing-audio-and-video-with-ffmpeg/
http://stackoverflow.com/questions/...eo-and-audio-from-another-video-mapping-issue
Much more commands on the original website: http://ffmpeg4android.netcompss.com/
FFmpeg documentation: https://www.ffmpeg.org/ffmpeg.html

Related

[TWRP] Screenshot while in recovery..

Is this what I have to do to take a screenshot in the recovery? Using adb:
adb pull /dev/graphics/fb0
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgba -s 720x1280 -i fb0 -f image2 -vcodec mjpeg fb%d.jpg
EDIT: I tried using ddms.bat while in recovery but it doesn't recognize my phone. I don't know what else to do or why it's not recognizing it. Can someone try with their phone and see if it works?
EDIT 2: ddms.bat works fine to take a screenshot when the device is booted up. Just not in the recovery.
SkizzMcNizz said:
Is this what I have to do to take a screenshot in the recovery? Using adb:
adb pull /dev/graphics/fb0
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgba -s 720x1280 -i fb0 -f image2 -vcodec mjpeg fb%d.jpg
EDIT: I tried using ddms.bat while in recovery but it doesn't recognize my phone. I don't know what else to do or why it's not recognizing it. Can someone try with their phone and see if it works?
EDIT 2: ddms.bat works fine to take a screenshot when the device is booted up. Just not in the recovery.
Click to expand...
Click to collapse
yes that is correct, however its device specific on the fbX most all are 0, some can be a different number, just try until you find the correct one,
also note that the colors my be off, and if they are simple change the
rgba around,
for instance my red was blue and blue was red,
just changed the order from
rgba to bgra and problem solved
Skizzy034 said:
Is this what I have to do to take a screenshot in the recovery? Using adb:
adb pull /dev/graphics/fb0
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgba -s 720x1280 -i fb0 -f image2 -vcodec mjpeg fb%d.jpg
EDIT: I tried using ddms.bat while in recovery but it doesn't recognize my phone. I don't know what else to do or why it's not recognizing it. Can someone try with their phone and see if it works?
EDIT 2: ddms.bat works fine to take a screenshot when the device is booted up. Just not in the recovery.
Click to expand...
Click to collapse
That's great, however -vframes belongs to the output.
adb pull /dev/graphics/fb0
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgba -s 720x1280 -i fb0 -f image2 -vcodec mjpeg -vframes 1 fb%d.jpg
If the device is in landscape mode you have to invert the resolution:
adb pull /dev/graphics/fb0
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgba -s 1280x720 -i fb0 -f image2 -vcodec mjpeg -vframes 1 fb%d.jpg
Hi Friends!
Is it possible with the same method to take screenshot on normal (not TWRP) LineageOS mode?
Code:
adb pull /dev/graphics/fb0
failed to copy '/dev/graphics/fb0' to './fb0': open failed: Permission denied
What is the correct video device for standard LineageOS mode?
Many thanks!
Davide

Google Voice (call someone data only) on ARM with virtual machine wrapper

This might be a little whack, but I am pretty tired that Google hasn't released an ARM version of google voice and video chat that allows dialing out and making telephone calls over a data-only connection.
What I have done so far, is using a micro instance on Amazon AWS, is to set up a virtual machine that has a virtual sound card.
Right now I am using a VLC session to dial out.. I think with a greasemonkey script or something this could be improved.
There are 4 things that need to work.
1: User A (android) --Audio--> [VM]
2: User A (android) <--Audio-- [VM]
3: [VM] --Audio--> User B
4: [VM] <--Audio-- User B
Progress:
1. This is the big one right now, I'm not great with android dev but what I want to do is encode the audio out from the mic to SIP and transfer it to the VM using RDP and then reroute that audio to the virtual microphone. Will utilize some combination of ffmpeg/vlc/arecord/aplay
2: This works (sorta), the VM is generating a VLC stream that I can access on android through RTP
3: This works, Using the virtual sound card (aloop module) "arecord -D hw:0,1,0 -f cd -t raw | aplay -D hw:0,1,0 -f cd &" creates a loop back
4: This works, with the command above, the audio in from User B(4) is heard by User B(3)
Here are my notes (sorry they are a mess). I hope to turn this into a step-by-step walkthrough once I get it going a bit more. It would be great if someone could look it over. I know a ton can be optimized (lower latency, less bandwidth for codecs, etc)
PHP:
sudo add-apt-repository ppa:chromium-daily/ppa && sudo apt-get update
sudo add-apt-repository ppa:chromium-daily
sudo apt-get install build-essential alsa xorg chromium-browser tightvncserver pulseaudio
sudo apt-get install libmp3lame0(?) lame gnome-term(not sure if this is still needed, installed for rygel attempt at config)
# FROM
apt-get install libncursesw5-dev gettext xmlto
adduser phone
login vnc: install voice and video chat
# FROM
wget ht[xdanolikelinks]tps://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb
dpkg -i --force-depends google-talkplugin_current_amd64.deb
apt-get -f install
cd /usr/src/modules
wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.25.tar.bz2
tar xjvf alsa-driver-1.0.25.tar.bz2
cd alsa-driver-1.0.25
./configure --with-cards=aloop --with-sequencer=yes ; make ; make install
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.26.tar.bz2
tar xjvf alsa-lib-1.0.25.tar.bz2
cd alsa-lib-1.0.25
./configure ; make ; make install
wget ftp://ftp.alsa-project.org/pub/firmware/alsa-firmware-1.0.25.tar.bz2
tar xjvf alsa-firmware-1.0.25.tar.bz
./configure ; make ; make install
wget ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.0.26.tar.bz2
tar xjvf alsa-utils-1.0.26.tar.bz2
./configure ; make ; make install
modprobe snd-aloop ; modprobe snd-pcm-oss ; modprobe snd-mixer-oss ; modprobe snd-seq-oss
/etc/modprobe
# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-aloop
# module options should go here
# OSS/Free portion
alias char-major-14 soundcore
# OSS/Free portion - card #1
alias sound-slot-0 snd-card-0
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
# OSS/Free portion - card #2 (cmipci)
alias sound-slot-1 snd-card-1
alias sound-service-1-0 snd-mixer-oss
alias sound-service-1-3 snd-pcm-oss
alias sound-service-1-12 snd-pcm-oss
update-initramfs -u
#loopback audio
arecord -D hw:0,1,0 -f cd -t raw | aplay -D hw:0,1,0 -f cd &
-
Add pulseaudio headless to system startup
/etc/rc.local
su phone -c "vncserver :1 -geometry 800x600 -depth 8"
Configure xstartup for vnc server to start pulseaudio
nano /home/phone/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
pulseaudio -D
/etc/X11/Xsession
bashrc
pulseaudio -D
apt-get install vlc
edit vlc hosts file
nano /etc/vlc/lua/http/.hosts
Script: Screen server for cvlc audio routing
#!/bin/bash
screen -A -m -d -S cvlcserver cvlc -vvv pulse://alsa_output.0.analog-stereo.monitor --sout \
'#transcode{acodec=mpga,ab=32,channels:1}:rtp{sdp=rtsp://0.0.0.0:8080/test.sdp}'
echo 'Started, type screen -x to monitor'

FFMPEG

Is anyone familiar with ffmpeg? Im trying to get a screenshot of my htc one x in recovery and ddms wont work. So I tried to pull the dev/graphic/fb0 file and I have successfully pulled it but i'm unable to get ffmpeg to convert it to a picture format like png or jpeg. I'm running these commands
adb pull /dev/graphics/fb0
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgba -s 720x1280 -i fb0 -f image2 -vcodec mjpeg fb%d.jpg
When I run it it says option vframes (set the number of video frames to record) cannot be applied to i
nput file fb0 -- you are trying to apply an input option to an output file or vi
ce versa. Move this option before the file it belongs to.
Error parsing options for input file fb0.
Error opening input files: Error number -22 occurred.
What am I doing wrong?

[UBUNTU][DEBIAN]Common Commands used in Linux

Common Commands used in Linux.
Since, Android is based on Linux, there is much possibility that there is a need to use a Linux based OS. For such use, UBUNTU
is favoured, for its easy and more user friendly.
Today, I am going to Post a few commands that are very useful to the newbies to development
I myself am new, and have faced many problems with this, so I am posting a this thread, to help all the noobs/newbies find what they need in a single place
Okay so, lets start with some basic commands, which can be classified as general commands, and each Linux user MUST KNOW ALL OF THEM !!
Code:
sudo
It simply means "Superuser do". It requires password.
Code:
sudo apt-get install APPLICATION_name
This installs the application finding it on the internet, and gives you the suitable output(If the app exists or not).
Code:
sudo apt-get remove APPLICATION_name
It Removes the application
Code:
sudo apt-get update
it updates the repositories
Code:
sudo apt-get upgrade
upgrades your installed application with their latest versions from Ubuntu repositories
Code:
killall APPLICATION_NAME
kills (terminates) an application
Code:
ps -e
displays currently running processes
Code:
kill APPLICATION_PID
kills an application; where APPLICATION_PID.
NOTE: YOU CAN FIND "PID" USING EARLIER CODE.
Code:
wget http://path_to_file.com
downloads a file from the web to current directory
Code:
cd /PATH/TO/DIR
changes current directory to DIR. Use cd to change the current directory into any dir
Code:
cd ..
Like ms-dos, goes up one directory
Code:
dir
OR
Code:
ls
lists directory content
Code:
man COMMAND
Displays manual for command.
eg: man sudo
Code:
cp ORIGINALFILE NEWFILE
Copy a file
Code:
mv SOURCE DESTINATION
Moves a file
NOTE: YOU CAN ALSO RENAME A FILE WITH THIS.
EG: mv old_filename new_filename
Code:
mkdir FOLDERNAME
Make a directory/folder
Miscellaneous: Level 2
Code:
du -sh folder name
This calculates the size of the folder
Code:
ps -aux
This shows all the running processes
Code:
chown -R User:User dir
Change owner of files and directories
Code:
chmod 777 yourScript
This makes a shell script ".sh" extension
Code:
netstat -anltp | grep "LISTEN"
See all open ports on your machine
Code:
sudo apt-get install ufw
sudo ufw allow 80/tcp
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw allow 21/tcp
sudo ufw enable
Ubuntu provides a uncomplicated firewall (ufw). To install it and only allow SSH, FTP, and webtraffic use the following command.
Network Commands
Code:
ifconfig
Shows the network connections
WILL UPDATE REGULARLY AS MUCH I COULD.
Code:
passwd
Run after installing Linux when you see "[email protected]:~$" to set your root pass word
Code:
adduser
Replace and run to add a new user
Code:
adduser sudo
Replace and run to add that user to sudo
Code:
sudo apt-get purge
Replace and run to purge your system of that package
Code:
apt-cache search
Replace and run to search for new packages to install
Note: "wild cards" eg "*" are acceptable
Code:
find -type f -iname 'some-compressed-file*' -print0 | xargs -0 sudo tar -vxpzf
Replace with at least the "root" directory you want to search through and Replace " some-compressed-file " (leave the single quotes ' ' and the wild card *) and run to find every file under the given directory that has that name and the pipe " | " it out to tar so that'll extract to your current directory
Note: "find" does the finding, the "-type -f" tells find to only look for files, the "-iname" tells find to search parts of file names, the ' ' around "some-compressed-file" keeps the * from doing bad things, the "print0" tells find to "scrub" for spaces and such before outputting a result, the " | " pipes the results of find to xargs, the "-0" is because of "print0" in the find side of the pipe, and "sudo tar - vxpzf" is where tar extracts the findings of find.
Code:
find $HOME -type f -iname '*zip' -print0 | xargs -0 ls
Run to find and list every zip file under the home folder
Say you want to make a file to contain some notes wile in the command line
Code:
sudo cat > $HOME/someNotes.txt <<EOF
# place a command here
echo "hello world, I update aptget"
sudo apt-get update -q
EOF
Try editing the part after $HOME; type it in or write a file that contains the combo of " cat > $HOME/someNotes.txt <<EOF " some text or commands " EOF " and you'll find making custom scripts of varying complexity to be easy.
.......
Hope some of these are also found to be useful for others.
Thanks for starting this here thread.
Hit the link in my signature for more help with Linux for new and seasoned users
Edit 08082013- added another useful tip and reformatted commands to better fit the OP's formatting.
Sent from either my SPH-D700 or myTouch3Gs
Debian Kit/QEMU Linux Install guide for all android devices that I'm writing:
http://forum.xda-developers.com/showthread.php?t=2240397
Now have working Installers for ARM Java 7 JDK + Maptools + jMonkey
Yo ! Nice Share
To delete contents of a large text file ..
Code:
cat /dev/null > NameOfTheFile
Useful variations of ls command :
Show dir content in a list
Code:
ls -l
Show dir content in a list sorted by modification time (newer first)
Code:
ls -lt
Show dir content in a list sorted by modification time (older first)
Code:
ls -lrt
Show subdirectories recursively
Code:
ls -R
If you want to show files starting with . (hidden file), you can add -a option.
More options with command :
Code:
man ls
Useful variations of grep command :
grep is used to print lines matching a pattern.
Find the entry for current user in file /etc/passwd :
Code:
cat /etc/passwd | grep $USER
Find all the entry except current user entry in file /etc/passwd :
Code:
cat /etc/passwd | grep -v $USER
Find all the numbers in file /etc/passwd :
Code:
cat /etc/passwd|grep '[0-9]*'
Add color to grep command :
Code:
cat /etc/passwd | grep --color $USER
(You can add
Code:
alias grep='grep --color=auto'
in ~/.bashrc to always have colored grep)
Useful variations of tar command :
Create archive_name.tar from dirname :
Code:
tar cvf archive_name.tar dirname/
Create archive_name.tar.gz (compressed) from dirname :
Code:
tar zcvf archive_name.tar.gz dirname/
Extract archive_name.tar.gz :
Code:
tar zxvf archive_name.tar.gz
Useful variations of mkdir command :
Create directory and subdirectories if not existing :
Code:
mkdir -p /tmp/a/b/c
(mkdir /tmp/a/b/c will fail if /tmp/a and /tmp/a/b don't exist)
Useful tip :
Use bash variable "!$" to get the value of the last argument of the last command interpreted.
For example :
Code:
mkdir /tmp/test_a
cd !$ (equivalent cd /tmp/test_a)
or,
Code:
mv /tmp/a /tmp/b
ls !$ (equivalent ls /tmp/b)

[Google Fi][HOW-TO] Uploading an MP3 as your Voicemail

1. On your computer, convert the mp3 file to a 3gp file with a particular file name:
Code:
laptop $ ffmpeg -i path/to/some/music.mp3 -ar 8000 /tmp/pending_voicemail_greeting.3gp
2. Push that file to your phone and cleanup:
Code:
laptop $ adb push /tmp/pending_voicemail_greeting.3gp /sdcard && rm /tmp/pending_voicemail_greeting.3gp
3. Open the Google Fi app and record a new voicemail containing whatever garbage you want. (It won't be used.) It will show you the screen to preview it before committing to it. DO NOT COMMIT TO IT. Instead, just leave that screen open.
4. Overwrite the preview file with your file:
Code:
laptop $ adb shell
phone $ su
phone # cat /sdcard/pending_voicemail_greeting.3gp > /data/data/com.google.android.apps.tycho/files/pending_voicemail_greeting.3gp && rm /sdcard/pending_voicemail_greeting.3gp
5. Press "keep" in the Fi app to upload the preview as your new voicemail.

Categories

Resources