<p>we're recently experimenting with FFMPEG (analog) capture too, so we opened this &quot;issue&quot; @ github:</p>
<p><a href="https://github.com/cdgriffith/FastFlix/issues/418" rel="nofollow noreferrer">https://github.com/cdgriffith/FastFlix/issues/418</a></p>
<p>Feel free to join the discussion in order to achieve the best rerults for anyone.</p>
<p>Thanks in advance.</p>

CC BY-SA 4.0
2023-02-28T22:49:03.553Z
This does not provide an answer to the question. Once you have sufficient [reputation](https://video.stackexchange.com/help/whats-reputation) you will be able to [comment on any post](https://video.stackexchange.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/22338)
Michael Liebman
CC BY-SA 4.0
2023-02-28T10:15:20.607Z
2023-02-28T10:15:20.607Z
FORART npo
<p>I'm digitizing a number of VHS tapes into lossless video files using FFmpeg. How can I optimize my FFmpeg command further in order to come closer to the requested specs below, with the best possible quality?</p>
<h2>Target (ideal) lossless specs</h2>
<ul>
<li>File format: MKV/AVI/MOV/MXF</li>
<li>Video Codecs: FFV1/JPG2000 lossless/HuffYUV/Dirac/H.264 lossless</li>
<li>Chroma: 4:2:2</li>
<li>Pixel size: Rec. 601</li>
<li>Aspect ratio: 4:3</li>
<li>Resolution: 720x576</li>
<li>PAL</li>
<li>25 fps</li>
<li>Audio: 48Khz/24-bit PCM 48Khz/16</li>
</ul>
<h2>FFmpeg command</h2>
<p>(OS is Ubuntu Studio, CPU has 8 cores)</p>
<pre><code>sudo \
nice --20 \
ffmpeg \
-hide_banner \
-v verbose \
-report \
-err_detect +crccheck+bitstream+buffer+compliant+aggressive \
-fflags +igndts \
-f video4linux2 -thread_queue_size 1024 -i &quot;/dev/video4&quot; \
-f alsa -thread_queue_size 1024 -channel_layout stereo -ac 2 -i &quot;hw:1&quot; \
-vcodec ffv1 -level 3 -threads 8 -coder 1 -context 1 -g 1 -slices 30 -slicecrc 1 \
-acodec copy \
-aspect 4:3 \
-colorspace bt470bg \
-t 00:00:00 \
&quot;NAME_HERE.mkv&quot;
</code></pre>
<h2>Additional info</h2>
<p>Capture device is <a href="https://www.hauppauge.com/pages/products/data_usblive2.html" rel="nofollow noreferrer">USB-Live2</a> from Hauppauge,
using <a href="https://hauppauge.com/pages/support/support_linux.html" rel="nofollow noreferrer">semi-official drivers</a> for Linux compability.</p>
<p>FFmpeg Input streams from capture device:</p>
<pre><code>Input #0, video4linux2,v4l2, from '/dev/video4':
  Duration: N/A, start: 3909.466392, bitrate: 165888 kb/s
  Stream #0:0: Video: rawvideo, 1 reference frame (YUY2 / 0x32595559), yuyv422, 720x576, 165888 kb/s, 25 fps, 25 tbr, 1000k tbn
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'hw:1':
  Duration: N/A, start: 1673622488.857382, bitrate: 1536 kb/s
  Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -&gt; #0:0 (rawvideo (native) -&gt; ffv1 (native))
  Stream #1:0 -&gt; #0:1 (copy)
</code></pre>
<p>FFprobe streams for sample output video file:</p>
<pre><code> ffprobe -hide_banner sample.mkv
Input #0, matroska,webm, from 'sample.mkv':
  Metadata:
    ENCODER         : Lavf59.27.100
  Duration: 00:00:10.02, start: 0.000000, bitrate: 59168 kb/s
  Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv422p(tv, bt470bg/unknown/unknown, progressive), 720x576, SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 1k tbn
    Metadata:
      ENCODER         : Lavc59.37.100 ffv1
      DURATION        : 00:00:10.000000000
  Stream #0:1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
    Metadata:
      DURATION        : 00:00:10.016000000
</code></pre>
<h2>Current command rationalizations</h2>
<p>sudo nice --20 ensures that the ffmpeg process is maximally prioritized by the CPU. (Afterwards, I use chown to change ownership of the video file from root.)</p>
<p>err_detect is there to catch any and all errors. Should something come up I restart the digitisation session. Dunno if any of the flags are entirely redundant with one another and/or performance-impacting.</p>
<p>As I understand it, because ffv1 is an &quot;<a href="https://en.wikipedia.org/wiki/Intra-frame_coding" rel="nofollow noreferrer">intra-frame</a>&quot; codec and not an <a href="https://en.wikipedia.org/wiki/Inter_frame" rel="nofollow noreferrer">inter-frame</a> one, DTS errors should be safe to ignore trough fflags +igndts. (It's fairly common that they pop up during a session and it seems unnecessary to restart because of them.)</p>
<p>Without the excessive thread_queue_size 1024, ffmpeg has a tendency to warn about &quot;Thread message queue blocking&quot;</p>
<p>ffv1 seems to be the most powerful lossless video codec available, and the parameters seems to be the most powerful possible: <a href="https://trac.ffmpeg.org/wiki/Encode/FFV1" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/Encode/FFV1</a></p>
<p>Input audio is close enough to the target specs (and AFAIK can't be improved anyway) so they're just copied as-is.</p>

<ffmpeg><linux><vhs><digitisation>
FFmpeg: maximum VHS quality?
user1763606
# FFmpeg: maximum VHS quality?

(Asked by: username_0 on 2023-01-13)

I'm digitizing a number of VHS tapes into lossless video files using FFmpeg. How can I optimize my FFmpeg command further in order to come closer to the requested specs below, with the best possible quality?
Target (ideal) lossless specs

File format: MKV/AVI/MOV/MXF
Video Codecs: FFV1/JPG2000 lossless/HuffYUV/Dirac/H.264 lossless
Chroma: 4:2:2
Pixel size: Rec. 601
Aspect ratio: 4:3
Resolution: 720x576
PAL
25 fps
Audio: 48Khz/24-bit PCM 48Khz/16

FFmpeg command
(OS is Ubuntu Studio, CPU has 8 cores)
sudo \
nice --20 \
ffmpeg \
-hide_banner \
-v verbose \
-report \
-err_detect +crccheck+bitstream+buffer+compliant+aggressive \
-fflags +igndts \
-f video4linux2 -thread_queue_size 1024 -i "/dev/video4" \
-f alsa -thread_queue_size 1024 -channel_layout stereo -ac 2 -i "hw:1" \
-vcodec ffv1 -level 3 -threads 8 -coder 1 -context 1 -g 1 -slices 30 -slicecrc 1 \
-acodec copy \
-aspect 4:3 \
-colorspace bt470bg \
-t 00:00:00 \
"NAME_HERE.mkv"

Additional info
Capture device is USB-Live2 from Hauppauge,
using semi-official drivers for Linux compability.
FFmpeg Input streams from capture device:
Input #0, video4linux2,v4l2, from '/dev/video4':
  Duration: N/A, start: 3909.466392, bitrate: 165888 kb/s
  Stream #0:0: Video: rawvideo, 1 reference frame (YUY2 / 0x32595559), yuyv422, 720x576, 165888 kb/s, 25 fps, 25 tbr, 1000k tbn
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'hw:1':
  Duration: N/A, start: 1673622488.857382, bitrate: 1536 kb/s
  Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> ffv1 (native))
  Stream #1:0 -> #0:1 (copy)

FFprobe streams for sample output video file:
 ffprobe -hide_banner sample.mkv
Input #0, matroska,webm, from 'sample.mkv':
  Metadata:
    ENCODER         : Lavf59.27.100
  Duration: 00:00:10.02, start: 0.000000, bitrate: 59168 kb/s
  Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv422p(tv, bt470bg/unknown/unknown, progressive), 720x576, SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 1k tbn
    Metadata:
      ENCODER         : Lavc59.37.100 ffv1
      DURATION        : 00:00:10.000000000
  Stream #0:1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
    Metadata:
      DURATION        : 00:00:10.016000000

Current command rationalizations
sudo nice --20 ensures that the ffmpeg process is maximally prioritized by the CPU. (Afterwards, I use chown to change ownership of the video file from root.)
err_detect is there to catch any and all errors. Should something come up I restart the digitisation session. Dunno if any of the flags are entirely redundant with one another and/or performance-impacting.
As I understand it, because ffv1 is an "intra-frame" codec and not an inter-frame one, DTS errors should be safe to ignore trough fflags +igndts. (It's fairly common that they pop up during a session and it seems unnecessary to restart because of them.)
Without the excessive thread_queue_size 1024, ffmpeg has a tendency to warn about "Thread message queue blocking"
ffv1 seems to be the most powerful lossless video codec available, and the parameters seems to be the most powerful possible: https://trac.ffmpeg.org/wiki/Encode/FFV1
Input audio is close enough to the target specs (and AFAIK can't be improved anyway) so they're just copied as-is.

**Tags:** ffmpeg, linux, vhs, digitisation


---

## 1 answers

### Answer by username_1 on 2023-02-28. Score: 1

we're recently experimenting with FFMPEG (analog) capture too, so we opened this "issue" @ github:

<https://github.com/cdgriffith/FastFlix/issues/418>

Feel free to join the discussion in order to achieve the best rerults for anyone.

Thanks in advance.

> **Comments:**
> **username_2**: This does not provide an answer to the question. Once you have sufficient [reputation](https://video.stackexchange.com/help/whats-reputation) you will be able to [comment on any post](https://video.stackexchange.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/22338)  

---

