Skip to content

Commit

Permalink
Merge pull request #5 from fediachov/hdr-support
Browse files Browse the repository at this point in the history
Hdr support
  • Loading branch information
RadiumByte authored Apr 1, 2020
2 parents ce3a7d2 + a5fd41a commit 29b4916
Show file tree
Hide file tree
Showing 8 changed files with 2,421 additions and 2,285 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
## Video conversion

- Source Video File Formats: `*.avi; *.mov; *.mkv; *.mpg; *.3gp; *.flv; *.vob; *.mp4; *.ts; *.m2ts`.
- Convert to Video Formats: AVI, MOV, MKV, MP4.
- Video Codecs: H.264, MJPEG, XVID, MPEG2.
- Convert to Video Formats: AVI, MOV, MKV, TS, MP4.
- Video Codecs: H.265, H.264, MJPEG, XVID, MPEG2.
- Adaptive video bitrate.
- Ability to manually adjust the video bitrate (to reduce the size of the output file).
- Audio Codecs: MP3, AC3, PCM.
Expand All @@ -31,6 +31,7 @@
- Frame rate change.
- Change the type of scan - progressive / interlaced.
- Selects a specific or all source audio tracks.
- Conversion HDR to SDR.

## Audio conversion

Expand Down
3 changes: 3 additions & 0 deletions SevenConverter/Actions/ConvertAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ private void TurnAudio()
btnAudioSet.Top = cbFormat.Top;
btnVideoSet.Visible = false;

label1.Visible = false;
cbHDR.Visible = false;

TurnOffPanels();
}

Expand Down
40 changes: 31 additions & 9 deletions SevenConverter/Actions/ConvertVideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public partial class Main : Form
" -b:v 5M -minrate 5M -maxrate 5M -bufsize 2M",
" -b:v 8M -minrate 8M -maxrate 8M -bufsize 2M",
" -b:v 10M -minrate 10M -maxrate 10M -bufsize 2M",
" -b:v 10M -minrate 10M -maxrate 20M -bufsize 2M"
" -b:v 10M -minrate 10M -maxrate 20M -bufsize 2M",
" -b:v 20M -minrate 20M -maxrate 40M -bufsize 2M",
" -b:v 40M -minrate 40M -maxrate 80M -bufsize 2M"
};

private readonly string[] interlaced =
Expand All @@ -34,6 +36,7 @@ public partial class Main : Form
"libx264",
"h264_nvenc -global_quality 25",
"h264_qsv -global_quality 25",
"libx265",
"libxvid",
"mpeg2video"
};
Expand All @@ -56,12 +59,12 @@ private bool ConvertVideo(string sourceFile, string destFile, bool quoted = true
if (Directory.Exists(dest_path))
{
StringBuilder command = new StringBuilder();
command.AppendFormat("-hwaccel auto -i {0} -y -v error -vcodec ",
quoted ? String.Concat("\"", sourceFile, "\"") : sourceFile);

// video codec
command.Append(videoCodec[cbVideoCodec.SelectedIndex]);
// input file and video codec
command.AppendFormat("-hwaccel auto -i {0} -y -v error -vcodec {1}",
quoted ? String.Concat("\"", sourceFile, "\"") : sourceFile,
videoCodec[cbVideoCodec.SelectedIndex]);


// TS format
if (cbFormat.SelectedIndex == 3)
{
Expand Down Expand Up @@ -115,10 +118,25 @@ private bool ConvertVideo(string sourceFile, string destFile, bool quoted = true
command.AppendFormat(" -aspect {0}", cbAspect.Text);
}

// scale
if (cbLines.SelectedIndex > 0)
if (cbLines.SelectedIndex > 0 || cbHDR.SelectedIndex > 0)
{
command.AppendFormat(" -vf scale=-1:{0}", cbLines.Text);
string rows = String.Empty;
string delim = String.Empty;

// scale
if (cbLines.SelectedIndex > 0)
{
rows = String.Format("scale=-1:{0}", cbLines.Text);
}

string hdr = String.Empty;
if (cbHDR.SelectedIndex == 1)
{
delim = ",";
hdr = "zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";
}

command.AppendFormat(" -vf {0}{1}{2}", rows, delim, hdr);
}

// bitrate
Expand Down Expand Up @@ -185,6 +203,10 @@ private void TurnVideo()
cbBitrate.Visible = true;
cbBitrate.SelectedIndex = 0;

label1.Visible = true;
cbHDR.Visible = true;
cbHDR.SelectedIndex = 0;

btnVideoSet.Visible = true;

cbAudioCodec.SelectedIndex = settings.outputAudioCodec;
Expand Down
Loading

0 comments on commit 29b4916

Please sign in to comment.