2

I have 3 versions of the ffmpeg command and none of them are perfect... I am stuck. Below are the examples I have and the issues I face with each version:

ffmpeg -i "%%a" -map 0:v:0 -map 0:a:m:language:eng -c copy -f matroska - | ffmpeg -i - -map 0:v -map 0:a:0 -c copy -c:a eac3 -metadata:s:a:0 title="EAC3 Transcoded" -b:a:0 640k "%%~dpna.EACConverted%%~xa"

This version of the command does transcodes the primary audio track to EAC3, labels it, sets the EAC3 as first/primary track. It also DOES keep only English tracks and removes all others! Removes subtitles, but sadly does NOT keep the original audio track in the original format (i.e DTS converted to EAC3, DTS will be missing.)

ffmpeg -i "%%a" -map 0:v -map 0:a:0 -map 0:a -c:v copy -c:a copy -c:a:0 eac3 -metadata:a:0 title="EAC3 Transcoded" -b:a:0 640k "%%~dpna.EACConverted%%~xa" 

This version of the command does remove the subtitles; transcodes the primary audio track to EAC3, labels it, sets the EAC3 as first/primary track, but it also DOES keep the original track before the transcode! (i.e DTS converted to EAC3, DTS will still be there) But the issue with this is it does NOT keep only English tracks. If I have a Chinese track, it will remain.

ffmpeg -i "%%a" -map 0:v:0 -map 0:a:m:language:eng -c copy -f matroska - | ffmpeg -i - -map 0:v -map 0:a:0 -c copy "%%~dpna.EACConverted%%~xa"

This version of the command extracts the 1st video track, English audio tracks from the file, deletes all other tracks and subtitles.(So it DOES keep only English tracks!) But it does not transcode the audio if DTS to EAC3, label it, etc.

I want something that is a mix of these, that does it all, that would mean it transcodes the primary audio track (lets say, DTS) to EAC3, labels it, sets the EAC3 as first/primary track. It also does keep only English tracks and removes all others, and would keep the original English DTS track after the transcode.

The complete example is:

@echo off
cls
set rootfolder="M:\Movies\"
echo Enumerating all MKVs under %rootfolder%
echo.
for %%a in (*.mkv) do (
    for /f %%b in ('mkvmerge -i "%%a" ^| find /c /i "TrueHD"') do (
        if [%%b]==[0] (
            echo "%%a" has no TrueHD Audio
        ) else (
            echo.
            echo "%%a" has TrueHD Audio
            ffmpeg -i "%%a" -map 0:v:0 -map 0:a:m:language:eng -c copy -f matroska - | ffmpeg -i - -map 0:v -map 0:a:0 -c copy -c:a eac3 -metadata:s:a:0 title="EAC3 Transcoded" -b:a:0 640k "%%~dpna.EACConverted%%~xa"
            if errorlevel 1 (
                echo Warnings/errors generated during remuxing, original file not deleted
            ) else (
                del /f "%%a"
                echo Successfully remuxed to "%%~dpna.EACConverted%%~xa", original file deleted
            )
            echo.
        )
    )
)

1 Answer 1

0

So far I got it working either of the following 2 commands below:

ffmpeg -i "%%a" -map 0:v:0 -c:v:0 copy -map 0:a:m:language:eng -c:a copy -disposition:a:2 0 -map 0:a:0 -c:a:0 eac3 -metadata:s:a:0 title="Transcoded Compatibility Track" "%%~dpna.EACConverted%%~xa"
  1. Transcodes the primary audio track whatever it is to EAC3
  2. Labels/Changes the name of this new EAC3 it created.
  3. Sets the EAC3 as First/Primary track and Default Track
  4. Removes all others tracks that are not English or und.
  5. Removes subtitles if found.
  6. Keep the original audio track in the original codec format as a backup.

Tested on 2 video files.

ffmpeg -i "%%a" -map 0:v:0 -map 0:a:0 -map 0:a:m:language:eng -disposition:a:1 0 -c copy -f matroska - | ffmpeg -i - -map 0:v:0 -c:v:0 copy -map 0:a:0 -c:a:0 eac3 -metadata:s:a:0 title="Transcoded Compatibility Track" -map 0:a:1 -c:a:1 copy "%%~dpna.EACConverted%%~xa"
  1. Transcodes the primary audio track whatever it is to EAC3
  2. Labels/Changes the name of this new EAC3 it created.
  3. Sets the EAC3 as First/Primary track and Default Track
  4. Removes all others tracks that are not English or und.
  5. Removes subtitles if found.
  6. Keep the original audio track in the original codec format as a backup.

Tested on 2 video files.

**Make sure to include: -loglevel error -nostats at the start of the command if you want to suppress the output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .