Sunday, March 13, 2016

FFmpeg - Transcoding Videos for Pioneer Head Unit AVH-P4450BT


Here are the basic steps to transcode videos for Pioneer Head Unit AVH-P4450BT using FFmpeg. The resulting videos should be playable on similar models such as AVH-P3450DVD, AVH-2450BT, and AVH-1450DVD. 

Pioneer Head Unit AVH-P4450BT


I am using Debian 8.3 and FFmpeg 7:2.8.3-1~bpo8+1 from jessie-backports. To get maximum video quality for the given bitrate, we will use two-pass encoding.

1. Since we have to use the same options for both encoding passes, we declare it first.

$ FFMPEG_OPTS="-c:v libxvid -b:v 1800k \
-vf scale='-2:min(ih,240)',setsar='1/1' -vtag DX50 \
-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -bf 2 \
-c:a libmp3lame -q:a 2 -ac 2 \
-threads $(nproc)"

Explanation:

  • -c:v libxvid -b:v 1800k XVID 1800k.
  • -vf scale='-2:min(ih,240)',setsar='1/1' Scale the video size.
  • -vtag DX50 The resulting video won't be detected by the head unit without this.
  • -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -bf 2 Some mumbo-jumbo to maximize video quality.
  • -c:a libmp3lame -q:a 2 -ac 2  LAME MP3 preset standard (good for music videos).
  • -threads $(nproc) Use all available CPU cores.

2. Run 1st pass.

$ ffmpeg -i "input.mp4" $FFMPEG_OPTS -pass 1 -passlogfile "ffmpeg2pass" -f null "/dev/null"

3. Run 2nd pass.

$ ffmpeg -i "input.mp4" $FFMPEG_OPTS -pass 2 -passlogfile "ffmpeg2pass" -f avi "output.avi"

That's it!

No comments:

Post a Comment