I have some video files that I need to re-encode due to compatibility issues. They are currently mkv files with h.264 video and ac3-a52 audio. I want to keep the h.264 video, convert the container to m4v and create two audio tracks, one with the original ac3-a52 and one copied from that but in aac stereo.
I assume there has to be some sort of audio stream mapping command but I don't know how to map and re-encode at the same time. What command should I enter into ffmpeg to achieve this?
Also, what is the difference between ac3 and ac3-a52? Will an apple TV still be able to pass through ac3-a52 or does that have to be converted to ac3?
-map 0 tells ffmpeg to all streams from input 0 (the first input) in the output file. -c:a copy -c:s copy will copy over any audio and subtitle streams present.
Video codec, copy. This tells FFmpeg to copy the compressed video stream into the new file without re-encoding. Audio codec, copy. This tells FFmpeg to copy the compressed audio stream into the new file without re-encoding.
The Constant Rate Factor or CRF is an option available in the libx264 encoder to set our desired output quality. It enables us to specify a target value that maps to a specific quality by adjusting the bitrates automatically based on the input video.
ffmpeg. FFmpeg is a software, which uses all formats for media you may need – H. 264, H. 265, Apple ProRes, Avid DNxHD etc, even also used for images like PNG and others – support all type of platform you're on. It is a command-line tool, it is quicker than some other tools which are available for transcoding.
this works for me:
ffmpeg -y -i Source.mkv -map 0:v -c:v copy -map 0:a -c:a copy -map 0:a -strict -2 -c:a aac out.mkv
-y
– A global option to overwrite the output file if it already exists.-map 0:v
– Designate the video stream(s) from the first input as a source for the output file.-c:v copy
– Stream copy the video. This just muxes the input to the output. No re-encoding occurs.-map 0:a
– Designate the audio stream(s) from the first input as a source for the output file.-c:a copy
– Stream copy the audio. This just muxes the input to the output. No re-encoding occurs.-strict -2 -c:a aac
– Use the native FFmpeg AAC audio encoder. -strict -2
is required as a way that you acknowledge that the encoder is designated as experimental. It is not a great encoder, but it is not too bad at higher bitrates.According to wikipedia, there is no difference between AC3 and ATSC A/52: the 1st one is the name of the codec, the 2nd is the name of the standard specifying the AC3 codec. Maybe someone have more knowledge about it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With