hooray! found a nice (video lossless, best i can tell) way to convert the video from cameras like my Canon ELPH SD1400
which is already h.264 video + PCM mono audio
to a new mp4 container with aac audio. that part’s easy/cake w/ ffmpeg – but the trick to get the h.264
video part to play in chrome browser and/or with a flash plugin is to get the flagged “yuvj420p” colorspace pixels
to be considered “yuv420p”. it seems like the former is >= 8 bits-per-pixel and has a range wider than the 256 values;
while the later is 8 bit per pixel. ( brief info/notes/background )
at any rate, finally found this nice post:
https://blendervse.wordpress.com/2012/04/02/waiving-the-fullrange-flag/
which refers to this modified MP4Box/gpac tree, to switch the “fullrange” color-related flag off:
https://github.com/golgol7777/gpac
and then, voila! i have a nice little script where i can convert my canon ELPH videos to a html5 video tag and flash plugin compatible mp4:
#!/bin/bash -ex
IN=${1:?"Usage: [input video] [output video]"}
OUT=${2:?"Usage: [input video] [output video]"}
# make hacked version of "mp4box" that can toggle colorspace-related flag in our vid
if [ ! -e $HOME/scripts/mp4box ]; then
(git clone https://github.com/golgol7777/gpac.git && cd gpac) || \
( cd gpac && git reset --hard && git clean -f && git pull && git status )
./configure --enable-pic --static-mp4box --enable-static-bin
make -j4
# bonus points: make *static* binary so if change linux/OS versions, dont hafta worry!
cd applications/mp4box
gcc -o $HOME/scripts/mp4box -static main.o filedump.o fileimport.o live.o \
-L../../bin/gcc -lgpac_static -lm -lpthread -ldl -lz
fi
# demux
ffmpeg -y -i "$IN" -an -vcodec copy video.mp4
ffmpeg -y -i "$IN" -vn -acodec copy audio.wav
# convert yuvj420p to yuv420p the cheater way (for chrome and flash plugin playback!)
rm -fv tmp.mp4
$HOME/scripts/mp4box -add video.mp4#:fullrange=off tmp.mp4
# convert wav audio to aac
ffmpeg -y -i tmp.mp4 -i audio.wav -acodec libfaac -ac 1 -ab 256k -vcodec copy t2.mp4
qt-faststart t2.mp4 "$OUT"
rm -fv video.mp4 audio.wav t2.mp4 tmp.mp4
Comments
mckenz
afconvert -f mp4f -b 256000 audio.wav audio.aac
and then modified the ffmpeg line to use the file generated above rather than convert on the fly
ffmpeg -y -i tmp.mp4 -i audio.aac -acodec copy -vcodec copy "$OUT"
tracey pooh
ah, cool, thanks for mentioning some workarounds and for finding my post helpful, too!
regarding ffmpeg and aac encoding, as well as qt-faststart (that tool is included in the ffmpeg build), in the future you might find this little recipe to make ffmpeg, that I use at home and work helpful:
https://github.com/traceypooh/deriver-archive/blob/master/ffmpeg-README.sh
Heather
This is the second article, of your blog I personally went through.
However , I personally enjoy this particular 1, “convert yuvj420p to yuv420p (chrome playable!
) mp4 video (eg: canon/nikon video) | PoohBot Pictures and more” the most.
All the best ,Micki