Simple bash video convertor - Google Chromecast

Hi all, just thought I'd share this simple bash script I've done to make any movie file that ffmpeg can open into ChromeCast Streamable mp4:
Code:
#!/bin/bash
CODECS=$(ffprobe -v quiet "$1" -show_entries stream=codec_name | grep "codec_name" | cut -d= -f2)
V_CODEC=$(echo $CODECS | cut -d' ' -f1)
A_CODEC=$(echo $CODECS | cut -d' ' -f2)
echo "Video codec is" $V_CODEC
if [ $V_CODEC = "h264" ]; then
echo "No video conversion needed"
V_FLAGS="copy"
else
echo "Converting video to h264..."
V_FLAGS="libx264 -profile:v high -level 5 -preset superfast -crf 18 -maxrate 10M -bufsize 16M -pix_fmt yuv420p -movflags faststart"
fi
echo "Audio codec is" $A_CODEC
if [ $A_CODEC = "mp3" ] || [ $A_CODEC = "aac" ]; then
echo "No audio conversion needed"
echo "Copying/transcoding video and creating mp4 file..."
eval ffmpeg -v quiet -i "$1" -c:v "$V_FLAGS" -c:a copy "$2".mp4
else
echo "Converting audio to aac..."
eval ffmpeg -v quiet -i "$1" -c:a pcm_s16le -f wav - | neroAacEnc -if - -ignorelength -of "$2".mpa
echo "Copying/transcoding video and creating mp4 file..."
eval ffmpeg -v quiet -i "$1" -i "$2".mpa -c:v "$V_FLAGS" -c:a copy -map 0:v:0 -map 1:a:0 "$2".mp4
echo "Removing intermediate files"
rm "$2".mpa
fi
echo "$2.mp4 created"
It's certainly nothing fancy and I know improvements could be made, it doesn't check to make sure you'd put an output file for example, but it's fine for me
I've used neroaacenc here as it's the best quality encoder for aac but this could easily be made to use fdk or plain ffmpeg aac, that'd even make the script smaller as it wouldn't need an intermediate audio file, but I wanted nero.
Usage is simple, save the script (I called it CCConv (ChromeCastConvertor)) and make it executable:
Code:
CCConv "inputfile.mkv" "outputfile"
no need to put .mp4 on the end of the output file, it'll automatically add that.
Any questions, just ask.
Thanks

Very nice. What binaries you need to install to make this bash script run on Mac OS X?

paracha3 said:
Very nice. What binaries you need to install to make this bash script run on Mac OS X?
Click to expand...
Click to collapse
Thanks buddy.
No idea if NeroAACEnc works on Mac tho, sorry.
Did you compile ffmpeg to use libfdk-aac at all? I could just rewrite the script to use that too.
What's the output of typing 'ffmpeg' with no parameters?

Oh, and I really wouldn't used the ffmpeg built-in aac encoder, the quality isn't very good and the channels are wrong when using 6 channels...
Nero encodes DTS and AC3 into 6 channel aac fine, receiver says "HDMI Multi-Chan Audio" :good:

Spec-Chum said:
Oh, and I really wouldn't used the ffmpeg built-in aac encoder, the quality isn't very good and the channels are wrong when using 6 channels...
Nero encodes DTS and AC3 into 6 channel aac fine, receiver says "HDMI Multi-Chan Audio" :good:
Click to expand...
Click to collapse
well i guess let me ask, what binaries you need for windows?

paracha3 said:
well i guess let me ask, what binaries you need for windows?
Click to expand...
Click to collapse
If you're using Nero, which I recommend, then any ffmpeg and NeroAacEnc from here: http://www.nero.com/eng/company/about-nero/nero-aac-codec.php

Related

Divx/Xvid, and MKV Oh My

So i have had my nexus one for a while. I have been converting my videos wiht hand brake and what not. And I gotta think there is a better way to get Xvid movies to play on the phone.
anyone have luck with yxplayer?
Mod. edit: Warez link removed. This is a beta, the developer didn't consent it's distribution. Consider this 1st warning!http://forum.xda-developers.com/showthread.php?p=6805512#post6805512http://forum.xda-developers.com/showthread.php?p=6805512#post6805512
yxplayer keeps crashing on 2.2
Its called Rock Player (not free).
Festaman said:
So i have had my nexus one for a while. I have been converting my videos wiht hand brake and what not. And I gotta think there is a better way to get Xvid movies to play on the phone.
anyone have luck with yxplayer?
Click to expand...
Click to collapse
One need not transcode the video to make it compatible. Android simply does not understand the PACKAGE and/or FOURCC. Your "xvid" video contains a fourcc of "xvid" when, in fact, it is simply h263 (and should have a fourcc of "h263").
One can simply use ffmpeg like such:
ffmpeg -vcodec copy -acodec copy -vtag h263 -i inputfile outputfile.mp4
(or outputfile.3gp)
It will be nearly instantaneous.
You can even loop this over an entire directory like so:
mkdir outdir
for FILE in *.videoextension
do
ffmpeg .... -i "$FILE" "outdir/$FILE.mp4"
done
You can even get fancy....
mkdir tmp
for FILE in *.videoextension
do
ffmpeg ...
adb push "tmp/$FILE.mp4" "/sdcard/videos/"
rm -f "tmp/$FILE.mp4"
done
rm -rf tmp
Hmm.. Thats too much work :-D. I installed The Rock Player and it is liek a dream come true. I need to get somethign like this for my ipad! (dont kill me)
For those who want to convert videos with handbrake here's an easy guide: http://thegreencodeblog.com/2010/04/11/how-to-get-movies-on-your-android-device/
Mod. edit: Warez link removed. This is a beta, the developer didn't consent it's distribution. Consider this 1st warning!http://forum.xda-developers.com/showthread.php?p=6805512#post6805512http://forum.xda-developers.com/showthread.php?p=6805512#post6805512http://forum.xda-developers.com/showthread.php?p=6805512#post6805512
Mod. edit: Warez links of RockPlayer removed. As stated this is a beta and the developer didn't consent it's distribution. Publishing it is therefore posting warez and a breach of forum rules! Pls wait until it's official release.

Chromecast and Curl issue

hi,
I'm trying to use curl to play you tube videos with a post command e.g.
curl -v -H "Content-Type: application/json" 192.168.0.XX:8008/apps/YouTube -X POST -d ‘v=XXXXXX′
I've checked my ip address is correct, and that the v='XXX'' is a valid youtube video, but the YouTube app launches on the chromecast, flickers for a moment before refusing to play the video. Curl returns successfully without any errors. Has this been blocked on the chromecast now, or is there something I'm missing to get this working?
any pointers gratefully recieved.
Nevermind
got it working. no matter
offyoutoddle said:
got it working. no matter
Click to expand...
Click to collapse
What was the issue?
bhiga said:
What was the issue?
Click to expand...
Click to collapse
i stopped using curl, and just tried it in my app instead and it works.

Chromecast Unofficial API / Information

I have found random documents going over some of the raw curl commands that can be sent to chromecast, but it is by no means complete and various people saying they've been successful in doing things but not sharing how. Is there anywhere, or can we start a conversation to go over full details on this? I am hoping to build a two-way module for a home automation system that shows what is playing and other information.
Here is what I have so ar of-which not all of them are working for me yet.
get device information xml:
curl http://10.0.1.2:8008/ssdp/device-desc.xml
get detailed device information json:
curl http://10.0.1.2:8008/setup/eureka_info?options=detail
scan for available wifi:
curl http://10.0.1.2:8008/setup/scan_results
get supported time zones:
curl http://10.0.1.2:8008/setup/supported_timezones
get info about current app:
curl -H “Content-Type: application/json” http://10.0.1.2:8008/apps/YouTube -X GET
send youtube video to chromecast:
curl -H “Content-Type: application/json” http://10.0.1.2:8008/apps/YouTube -X POST -d ‘v=oHg5SJYRHA0′
kill current running app:
curl -H “Content-Type: application/json” http://10.0.1.2:8008/apps/YouTube -X DELETE
reboot the chromecast dongle:
curl -H “Content-Type: application/json” http://10.0.1.2:8008/setup/reboot -d ‘{“params”:”now”}’ -X POST
factory default reset the chromecast dongle:
curl -H “Content-Type: application/json” http://10.0.1.2:8008/setup/reboot -d ‘{“params”:”fdr”}’ -X POST
If you're looking for a comprehensive writeup of the Cast protocol take a look here:
https://github.com/jloutsenhizer/CR-Cast/wiki/Chromecast-Implementation-Documentation-WIP
has anyone made any further discoveries than this?
I'm particularly interested in implementing a play/pause capability, and I notice one developer mentioned his android remote app has this capablility, but did not mention exactly how it was achieved.
I'm assuming the use of the Ramp protocol will work on the youtube app still - so in order to play/pause I'd just need to implement that method in my app? Before I go down that route though, i wondered if anyone knows if that method still works, at least with the youtube app as of july 2014?
can anyone confirm if this method still works? I'm wondering if google has changed something here, as the video of a youtube vid sent the chromecast is no longer displayed since the 'guest feature' update. Video's sent to the chromecast this way now will only play audio with a full screen youtube logo on screen. Anyone else see this, and have any way around it yet?
Hi,I have a question about this. Do you know a way to configure the output signal of the chromecast?
I am looking for a way to force 720p instead of 1080p on my tv (got some hdmi EDID problems).
Kind regards,
Vincent
Is it possible somehow to get information about its current status. Mainly if its currently streaming or not?
I need this in order to automatically turn on my multi channel amplifier if any of my chromecast audios connected to it starts streaming.
dhanjel said:
Is it possible somehow to get information about its current status. Mainly if its currently streaming or not?
I need this in order to automatically turn on my multi channel amplifier if any of my chromecast audios connected to it starts streaming.
Click to expand...
Click to collapse
Did you ever find a solution to this?

Audio file as array in Android Studio or Eclipse

I don't know if its the right place but I would proceed anyway. In matlab software we can load an audio file in the form of an array and manipulate that values in the array. i have to create an android app which requires a similar kind of thing. Can I load an audio file in the form an array and manipulate the values inside it in an android application. If so please share any tutorial or link that might be of help...
Code:
File[] audioFilesArray = new File[<enter size of array here>];
That will give you an array that holds the object type of "File".
You can then access a specific file by doing
Code:
audioFilesArray[0]
That will return the File object of the first file in the array. Then you can do what you need with that specific file, like play it using the MediaPlayer class.
elesbb said:
Code:
File[] audioFilesArray = new File[<enter size of array here>];
That will give you an array that holds the object type of "File".
You can then access a specific file by doing
Code:
audioFilesArray[0]
That will return the File object of the first file in the array. Then you can do what you need with that specific file, like play it using the MediaPlayer class.
Click to expand...
Click to collapse
How do I assign the values in an audio file to this array? The values that are displayed in matlab when an audio file is loaded. I need to store the samples of audio file in this array. By samples here i meant raw bit of sound which represent the sound intensity in individual channel at an instant of time.
munirshah77 said:
How do I assign the values in an audio file to this array? The values that are displayed in matlab when an audio file is loaded. I need to store the samples of audio file in this array. By samples here i meant raw bit of sound which represent the sound intensity in individual channel at an instant of time.
Click to expand...
Click to collapse
It's really simple. You must convert wav (or another music type) to byte array
Example for one file define like WAY_FILE
Code:
ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedInputStream in = new BufferedInputStream(new FileInputStream(WAV_FILE));
int read;
byte[] buff = new byte[1024];
while ((read = in.read(buff)) > 0)
{
out.write(buff, 0, read);
}
out.flush();
byte[] audioBytes = out.toByteArray();
munirshah77 said:
How do I assign the values in an audio file to this array? The values that are displayed in matlab when an audio file is loaded. I need to store the samples of audio file in this array. By samples here i meant raw bit of sound which represent the sound intensity in individual channel at an instant of time.
Click to expand...
Click to collapse
I'm not exactly sure what you are trying to do here.. An what I posted previously will give you an array of files. Which you can access and assign using
array[0] where the 0 indicates the first file in that array. To assign it, you would just do
array[0] = new File(<some file location string here>);
Your last sentence, "raw bit of sound which represent the sound intensity in individual channel at an instant of time" i do not understand what you mean. By channel I presume you are referring to left and right audio channels?
How are you obtaining this "raw bit of sound"? If you can convert it to a byte array as the other person posted, then you can write it to a file. But you have to have some sort of input to write or read from.

Getting a 3rd party audio player to stop when switching modes.. use MTC Manager ?

Hello all,
I have some questions, that I hope people can help with.
I am running the newest Malaysk 4.4.4 rom on a RK3188 800x600 unit.
I want to use the Musicolet Music Player as the media player.
(Hardware buttons on the head unit are configured via MTC-Keys and work fine)
The problem: This 3rd party media player keeps running when switching to MTC microntek radio.
This occurs even if the app is selected as the media player. (likely due to Musicolet not being directly supported)
Based on what I have read (portion below), @MVG-V70 's MTC Manager module will allow you to customize it to switch between the different modes in a MTCB.
1) The docs, refer to "When the MODE mutton is pressed". I assume this means ANY of the mod buttons on a MTCB ( examples: DVD/NAVI/BAND...) ?
2) The docs show how each mod is configured in the mode.ini file (See portion below) I want to use the Musicolet music player.
How do I determine all the intents info needed ?
The Package manager app I am using shows the following:
SERVICES
in.krosbits.musicolet.MusicService
ACTIVITIES
in.krosbits.musicolet.MusicActivity
How do i determine what intents are needed to send a stop/start to the Musicolet Media Player?
Is there a different app that will list them ?
Thanks for any help !
LRail
NOTE: the mode.ini docs below are not my actual settings
----------------------------------------------------------------
Portion of MTC Manager docs below
Code:
Programs are switched sequentially one after the other.
For correct sound switching, the applications used must be managed (play / pause) programmatically via intents.
If the player does not support the beginning and stopping of playback by external intents, then it is necessary to switch the sound manually.
When the MODE button is pressed, the active application is searched for in the running list. Next, the application is sent a command (configurable in mode.ini) to close or pause the audio stream.
After that, the default activation for the next application is launched and the application is sent a command to start playback (also configured in mode.ini)
#mode.ini
# list of applications to switch, package names must be listed
[apps]
# established radio
com.microntek.radio
# PowerAmp
com.maxmpz.audioplayer
# staff
com.microntek.music
# PCRadio
com.maxxt.pcradio
# staff DVD
com.microntek. dvd
Code:
# disabling playback in PowerAmp
[com.maxmpz.audioplayer: stop]
# service name
service = com.maxmpz.audioplayer.player.PlayerService
#
intent name intent = com.maxmpz.audioplayer .API_COMMAND
# action startService
send = service
# parameter name
extra = cmd
# parameter type
extra_type = int
# value
value = 2

Categories

Resources