Hugo Future Imperfect Slim

Tracey Jaquith · PoohBot Pictures

Technophile · Optimist · Cyclist · Archivist · Design · Video · TV · Nomad · Docker

tracey pooh

2-Minute Read

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:

which refers to this modified MP4Box/gpac tree, to switch the “fullrange” color-related flag off:

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  &&  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
# 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

Say Something


mckenz's Gravatar
thanks for this, a neat solution. for any fellow mac users like me, it works great on a macbook too with a minor modification – commenting out the “make a static binary” and “qt-faststart” lines. I also ran into a problem in that my ffmpeg doesn’t do aac encoding. However there is a command line utility “afconvert” on the mac for qt encoding which does the job. So I added an extra line after the MP4Box line:
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"
Heather's Gravatar

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

Recent Posts



#spottheshuttle 1940s 1st-person 3d accident aids-lifecycle airplane animals appeltart apple-pie apple-watch architecture arkit art ascii-art asia augmented-reality baking bali bay-area biking birthday cafe-racer camaro camera-video camping candy cars cat-pee cat-psychology cats cloud coding college colorspaces computer-vision cornell crictl css dark-mode decaf deinterlace desert design diy docker documentary driving ducting ebgb ebgc emacs endeavour family ffmpeg food games geek gitlab golden-gate-bridge google-cardboard gravel-bike green-magic-man h.264 hack highway-1 home https hugo hyperlapse internet-archive ios iphone javascript k3s kubernetes landscapes linux lisp luke-battling-darth mac macosx markdown mashup metal montclair motion-jpeg motorcycle mountain-bike mountain-biking mplayer mt-tamalpais nasa new-bay-bridge news ninja oakland partioning phoenix php php-htm-mode politics protest rancher recording remaster remix remodel shuttle small-town star-wars swift tahoe technical thirsty-thursday time-lapse time-machine timing-belt-adjustment top-end-rebuild tracey traefik training-ride travel vacation valve-job video virtual-reality vlog vscode weekend-mechanic work x264 xcode yuvj420p zx6


tracey is a nonstop dance party. so you dont have to. dont ask me about containers. thanks for dropping by today. you look nice.