Jamie Hutber
Jamie Hutber

Reputation: 28076

How to replace AAC in 265 MP4s with PCM with ffmpeg

I am trying to re encode my h265 files from AAC to PCM audio for the ability to edit them in Davinci Resolve.

I originally used this for h264 files and replaced the codec with hevc_mp4toannexb out.h265 but with no luck!

## .sh script

#!/bin/bash
for f in *.mp4; \
  do ffmpeg -i "$f" "${f/%mp4/wav}"; \
  ffmpeg -i "$f" -vcodec copy -an -bsf:v hevc_mp4toannexb "${f/%mp4/m4v}"; \
  ffmpeg -i "${f/%mp4/m4v}" -i "${f/%mp4/wav}" \
         -acodec copy -vcodec copy "${f/%mp4/mov}"; \
  rm "${f/%mp4/m4v}"; \
  rm "${f/%mp4/wav}"; \
done

enter image description here

Upvotes: 0

Views: 1188

Answers (1)

kesh
kesh

Reputation: 5463

You just need to re-encode the audio stream (I picked signed 16-bit, pcm_16le, but use an PCM codec of your choice). A single FFmpeg call should suffice. Something like this (I'm not familiar with sh script):

## .sh script

#!/bin/bash
for f in *.mp4; \
  do ffmpeg -i "$f" -acodec pcm_16le -vcodec copy "${f/%mp4/mov}"; \
done

Upvotes: 1

Related Questions