Answers.Body: <p>I record my Shadowplay content with the following settings:</p>
  <ul>
  <li>1440p</li>
  <li>50MBps</li>
  <li>60 FPS</li>
  <li>Microphone and Desktop Audio on seperate channels</li>
  </ul>
  <p>So it's not compatible with the mentioned DNxHD. The audio channels are are also in variable framerates and must be synced.</p>
  <p>The following will re-encode the video and audio in 60 FPS CFR and will not have audio sync issues in Adobe Premier. You save it to a batch file (.bat) and then run it via the command line with the video file as the first argument.</p>
  <pre><code>@echo off
  set inputFile=%1
  set outputFile=%inputFile:.mp4=_cbr.mp4%
  ffmpeg  ^
  -i %inputFile% ^
  -vsync 1 -async 1 ^
  -map 0:v:0 ^
      -c:v libx264 ^
      -preset veryfast ^
      -x264-params &quot;nal-hrd=cbr&quot; ^
      -b:v 50M ^
      -framerate 60 ^
  -map 0:a:0 ^
      -c:a:0 aac ^
      -b:a 384k ^
  -map 0:a:1  ^
      -c:a:1 aac ^
      -b:a 384k ^
  %outputFile%
  </code></pre>
  <p>When comparing individual frames, I did not notice a difference in quality between this and the original recording. You can change some of the options like the framerate to match your content, or increase the bitrate if you think there is some loss.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-24T22:14:16.653Z
Answers.LastActivityDate: 2022-04-24T22:14:16.653Z
Answers.UserDisplayName: Jack Cole
Answers.Body: <p>To start with: your version of Handbrake is old. Version 1.0.3 came out very recently, it's got some improvements over that older version.</p>
  
  <p>Second, CQ0 is not <em>actually</em> "lossless." It's aiming for "lossless" quality, but it's going to bump up against the data rate limitations of the <a href="https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels" rel="nofollow noreferrer">H.264 Level</a>, so while it might need, say, 100MbPS at a given point to achieve "lossless" compression, Level 4.0 might be capping it at 20MbPS or something like that. Note in the Encoding Settings readout on your export file it lists "vbv_maxrate=20000," that's where your bitrate is capped. So to get as close to lossless as possible you'd need something like Level 5.2.</p>
  
  <p>So ratcheting up your H.264 level will improve quality, but Premiere may end up chugging very hard on it. H.264 is really bad for editing. It's very computationally complex, largely because it doesn't store each frame separately (called Intraframe compression) but it takes batches of frames (called a Group of Pictures, or GOP) and compresses them together, in such a way that any one frame within a GOP will depend on the surrounding frames in order to reproduce a complete image. This is called Interframe compression, and the number of frames in a GOP depends on the parameters set at encode time, and may even be variable (not typical), but you can see what those parameters in MediaInfo by noting the line that says "Format settings, GOP" ("N=30" means 30 frames per GOP), or looking at the encoding settings where it notes "keyint" (Keyframe Interval). So needing to decode all 30 frames to show you any one frame is <em>very</em> CPU and RAM intensive.</p>
  
  <p>If you've got the storage I'd recommend considering using DNxHD, which is a "mezzanine" (editing friendly) codec that preserves quality, considered "virtually lossless," but has low CPU/RAM impact. The catch is very high bitrates. So we're talking ~130-200GB/hr at 1080p59.94. The other catch is that <a href="https://en.wikipedia.org/wiki/List_of_Avid_DNxHD_resolutions" rel="nofollow noreferrer">DNxHD has very limited supported resolutions and frame rates</a>. There's also CineForm which is just as high a quality, but far more flexible, and both CineForm and DNxHD are natively supported by Premiere (CineForm in 2015 and later) but last I checked CineForm support in other tools, like ffmpeg, is lacking.</p>
  
  <p>So are more editing-friendly solution would be to use ffmpeg to make DNxHD with a command line the following:</p>
  
  <pre><code>ffmpeg -i (input file).mp4 -c:v dnxhd -b:v 290M -c:a pcm_s16le -r 60 (output).mxf
  </code></pre>
  
  <p>That would make DNxHD with uncompressed audio in an MXF Op1a file. You could also whack .mov on the end there and make a Quicktime file instead just as easily. Note that -r sets the output frame rate. You could try using H.264 in ffmpeg by changing the video codec (-c:v), but you'll run into the same limitations as you would working with Handbrake, so I don't know if it's really worth it to go into that here.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-05T05:03:21.920Z
Answers.Text: CQ0 *is* actually lossless. If you do a SSIM compare with the source, the metric result will be 1.0 i.e. perfect fidelity. H.264 levels are meant for hardware decoders, so they can gracefully decline to decode a stream beyond their capabilities, instead of rendering a stuttering playback. But they don't constrain x264. It will complain if your resolution/bitrate exceeds an explicitly set level but proceed nonetheless.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-05T05:15:11.350Z
Answers.Text: To reduce decoding burden, you can always set a low GOP size and disable B-frames. I don't use Handbrake, but it's easily done with ffmpeg. DNxHD will use more bandwidth than necessary.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-03T00:35:48.770Z
Answers.Text: I'm not sure if h264 cq0 is lossless in terms of bit depth.. i mean.. if you go from 8 bit to 8 bit is ok.. if 10 or 12 to 8 you will have a loss unless a 16 bit version of h264 crf 0 is available.. @Mulvya do a 16 bit per component + alpha option exists ?
Answers.UserDisplayName: user3450548
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-03T04:50:04.253Z
Answers.Text: Alpha is not available, and x264 does 8 and 10 bit only.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-04T20:50:59.347Z
Answers.LastActivityDate: 2017-03-04T20:50:59.347Z
Answers.UserDisplayName: ivkowalenko
Body: <p>I have gameplay footage recorded with ShadowPlay (“GeForce Experience”) at 60 FPS, which as I understand results in variable frame rate, because the game drops frames sometimes. However, trying to use this video in Adobe Premiere results in the game audio severely falling behind the visuals, because Premiere treats it as if every frame was the same length.</p>
  
  <p>I have tried HandBrake with these settings:</p>
  
  <p>Quality: constant, RF 0 (lossless)<br>
  FPS: 60, constant<br>
  Detelecine: Off<br>
  Decomb: Off<br>
  Denoise: Off<br>
  Deblock: Off</p>
  
  <p>But the output video is not only much smaller than the source video, but it's massively worse in terms of visual quality. Why isn't it lossless when I've set it to what it claims is lossless?</p>
  
  <p>Input video info: <a href="http://pastebin.com/7Tss4brj" rel="nofollow noreferrer">http://pastebin.com/7Tss4brj</a><br>
  Output video info: <a href="http://pastebin.com/DKFEzDKk" rel="nofollow noreferrer">http://pastebin.com/DKFEzDKk</a>
  (from Mediainfo)</p>
  
  <p>How can I convert a variable framerate video to a constant framerate video losslessly?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-06T19:25:38.463Z
Comments.Text: If you have [mediainfo](http://www.mediaarea.net), can you post the readout for your output. Use View->Text mode.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T10:56:11.010Z
Comments.Text: Hope this helps:  
  Input video info: http://pastebin.com/7Tss4brj  
  Output video info: http://pastebin.com/DKFEzDKk
Comments.UserDisplayName: Zdeněk Gromnica
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T11:36:25.003Z
Comments.Text: Technically, not lossless as RF is recorded as 1 not 0. Still, it shouldn't be "*massively worse in terms of visual quality*". How are you testing playback?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T11:55:01.670Z
Comments.Text: Playing it in VLC or previewing in Premiere. It has huge compression artifacts all over the place, especially with rapid movement.
Comments.UserDisplayName: Zdeněk Gromnica
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T12:10:43.977Z
Comments.Text: Hm, just compared screenshots from the two videos in VLC and it seems about equal. The preview in Premiere is far worse. Let me investigate. It might be an issue with Premiere. Still, why is it RF 1 when I've set it as 0 and why is the output file so much smaller?
Comments.UserDisplayName: Zdeněk Gromnica
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T12:22:31.203Z
Comments.Text: Alright, compared a different video in VLC and the quality is definitely worse. Input: http://imgur.com/AKYhyuC http://pastebin.com/4vwJi8Vj Output: http://imgur.com/m5TKr0L http://pastebin.com/49knbRiH
Comments.UserDisplayName: Zdeněk Gromnica
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T12:29:34.090Z
Comments.Text: Try with [ffmpeg](https://ffmpeg.org/download.html). `ffmpeg -i in.mp4 -r 60 -crf 0 -profile:v main -c:a copy out.mp4`
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T15:33:58.160Z
Comments.Text: Says: x264 [error]: main profile doesn't support lossless
  [libx264 @ 00000000031c3280] Error setting profile main.
  The only profile that accepted lossless was high444, which produced a 43.2 GB file from the 7.17 GB, which doesn't seem to be playable in VLC or Premiere (getting weird colours). http://pastebin.com/MwtMPj8Q
Comments.UserDisplayName: Zdeněk Gromnica
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-07T15:55:40.483Z
Comments.Text: Oops. Skip the profile but add `-pix_fmt yuv420p`
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-20T15:14:17.800Z
Comments.Text: That seems to have worked, but the resulting file is so huge, neither VLC nor Premiere can play it correctly. (Extremely low framerate and artifacts in VLC, weird colours in Premiere) Premiere seems to be able to export it, but it's useless for editing. :-( http://pastebin.com/7U60c0GU
  Would it be possible to copy the stream data instead of losslessly copy the pixel data?
Comments.UserDisplayName: Zdeněk Gromnica
Tags: <premiere><conversion><framerate><handbrake><lossless>
Title: Convert variable framerate ~60 FPS to constant 60 FPS losslessly
UserDisplayName: Zdeněk Gromnica
ThreadText: # Convert variable framerate ~60 FPS to constant 60 FPS losslessly
  
  (Asked by: username_0 on 2017-02-06)
  
  I have gameplay footage recorded with ShadowPlay (“GeForce Experience”) at 60 FPS, which as I understand results in variable frame rate, because the game drops frames sometimes. However, trying to use this video in Adobe Premiere results in the game audio severely falling behind the visuals, because Premiere treats it as if every frame was the same length.
  
  I have tried HandBrake with these settings:
  
  Quality: constant, RF 0 (lossless)  
  FPS: 60, constant  
  Detelecine: Off  
  Decomb: Off  
  Denoise: Off  
  Deblock: Off
  
  But the output video is not only much smaller than the source video, but it's massively worse in terms of visual quality. Why isn't it lossless when I've set it to what it claims is lossless?
  
  Input video info: <http://pastebin.com/7Tss4brj>  
  Output video info: <http://pastebin.com/DKFEzDKk>
  (from Mediainfo)
  
  How can I convert a variable framerate video to a constant framerate video losslessly?
  
  **Tags:** premiere, conversion, framerate, handbrake, lossless
  
  > **Comments:**
  > **username_1**: If you have [mediainfo](http://www.mediaarea.net), can you post the readout for your output. Use View->Text mode.  
  > **username_0**: Hope this helps:   Input video info: http://pastebin.com/7Tss4brj   Output video info: http://pastebin.com/DKFEzDKk  
  > **username_1**: Technically, not lossless as RF is recorded as 1 not 0. Still, it shouldn't be "*massively worse in terms of visual quality*". How are you testing playback?  
  > **username_0**: Playing it in VLC or previewing in Premiere. It has huge compression artifacts all over the place, especially with rapid movement.  
  > **username_0**: Hm, just compared screenshots from the two videos in VLC and it seems about equal. The preview in Premiere is far worse. Let me investigate. It might be an issue with Premiere. Still, why is it RF 1 when I've set it as 0 and why is the output file so much smaller?  
  > **username_0**: Alright, compared a different video in VLC and the quality is definitely worse. Input: http://imgur.com/AKYhyuC http://pastebin.com/4vwJi8Vj Output: http://imgur.com/m5TKr0L http://pastebin.com/49knbRiH  
  > **username_1**: Try with [ffmpeg](https://ffmpeg.org/download.html). `ffmpeg -i in.mp4 -r 60 -crf 0 -profile:v main -c:a copy out.mp4`  
  > **username_0**: Says: x264 [error]: main profile doesn't support lossless [libx264 @ 00000000031c3280] Error setting profile main. The only profile that accepted lossless was high444, which produced a 43.2 GB file from the 7.17 GB, which doesn't seem to be playable in VLC or Premiere (getting weird colours). http://pastebin.com/MwtMPj8Q  
  > **username_1**: Oops. Skip the profile but add `-pix_fmt yuv420p`  
  > **username_0**: That seems to have worked, but the resulting file is so huge, neither VLC nor Premiere can play it correctly. (Extremely low framerate and artifacts in VLC, weird colours in Premiere) Premiere seems to be able to export it, but it's useless for editing. :-( http://pastebin.com/7U60c0GU Would it be possible to copy the stream data instead of losslessly copy the pixel data?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-03-04. Score: 3 | Accepted answer
  
  To start with: your version of Handbrake is old. Version 1.0.3 came out very recently, it's got some improvements over that older version.
  
  Second, CQ0 is not *actually* "lossless." It's aiming for "lossless" quality, but it's going to bump up against the data rate limitations of the [H.264 Level](https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels), so while it might need, say, 100MbPS at a given point to achieve "lossless" compression, Level 4.0 might be capping it at 20MbPS or something like that. Note in the Encoding Settings readout on your export file it lists "vbv\_maxrate=20000," that's where your bitrate is capped. So to get as close to lossless as possible you'd need something like Level 5.2.
  
  So ratcheting up your H.264 level will improve quality, but Premiere may end up chugging very hard on it. H.264 is really bad for editing. It's very computationally complex, largely because it doesn't store each frame separately (called Intraframe compression) but it takes batches of frames (called a Group of Pictures, or GOP) and compresses them together, in such a way that any one frame within a GOP will depend on the surrounding frames in order to reproduce a complete image. This is called Interframe compression, and the number of frames in a GOP depends on the parameters set at encode time, and may even be variable (not typical), but you can see what those parameters in MediaInfo by noting the line that says "Format settings, GOP" ("N=30" means 30 frames per GOP), or looking at the encoding settings where it notes "keyint" (Keyframe Interval). So needing to decode all 30 frames to show you any one frame is *very* CPU and RAM intensive.
  
  If you've got the storage I'd recommend considering using DNxHD, which is a "mezzanine" (editing friendly) codec that preserves quality, considered "virtually lossless," but has low CPU/RAM impact. The catch is very high bitrates. So we're talking ~130-200GB/hr at 1080p59.94. The other catch is that [DNxHD has very limited supported resolutions and frame rates](https://en.wikipedia.org/wiki/List_of_Avid_DNxHD_resolutions). There's also CineForm which is just as high a quality, but far more flexible, and both CineForm and DNxHD are natively supported by Premiere (CineForm in 2015 and later) but last I checked CineForm support in other tools, like ffmpeg, is lacking.
  
  So are more editing-friendly solution would be to use ffmpeg to make DNxHD with a command line the following:
  
  ```
  ffmpeg -i (input file).mp4 -c:v dnxhd -b:v 290M -c:a pcm_s16le -r 60 (output).mxf
  
  ```
  
  That would make DNxHD with uncompressed audio in an MXF Op1a file. You could also whack .mov on the end there and make a Quicktime file instead just as easily. Note that -r sets the output frame rate. You could try using H.264 in ffmpeg by changing the video codec (-c:v), but you'll run into the same limitations as you would working with Handbrake, so I don't know if it's really worth it to go into that here.
  
  > **Comments:**
  > **username_1**: CQ0 *is* actually lossless. If you do a SSIM compare with the source, the metric result will be 1.0 i.e. perfect fidelity. H.264 levels are meant for hardware decoders, so they can gracefully decline to decode a stream beyond their capabilities, instead of rendering a stuttering playback. But they don't constrain x264. It will complain if your resolution/bitrate exceeds an explicitly set level but proceed nonetheless.  
  > **username_1**: To reduce decoding burden, you can always set a low GOP size and disable B-frames. I don't use Handbrake, but it's easily done with ffmpeg. DNxHD will use more bandwidth than necessary.  
  > **username_4**: I'm not sure if h264 cq0 is lossless in terms of bit depth.. i mean.. if you go from 8 bit to 8 bit is ok.. if 10 or 12 to 8 you will have a loss unless a 16 bit version of h264 crf 0 is available.. @Mulvya do a 16 bit per component + alpha option exists ?  
  > **username_1**: Alpha is not available, and x264 does 8 and 10 bit only.  
  
  ---
  
  ### Answer by username_2 on 2022-04-24. Score: 0
  
  I record my Shadowplay content with the following settings:
  
  * 1440p
  * 50MBps
  * 60 FPS
  * Microphone and Desktop Audio on seperate channels
  
  So it's not compatible with the mentioned DNxHD. The audio channels are are also in variable framerates and must be synced.
  
  The following will re-encode the video and audio in 60 FPS CFR and will not have audio sync issues in Adobe Premier. You save it to a batch file (.bat) and then run it via the command line with the video file as the first argument.
  
  ```
  @echo off
  set inputFile=%1
  set outputFile=%inputFile:.mp4=_cbr.mp4%
  ffmpeg  ^
  -i %inputFile% ^
  -vsync 1 -async 1 ^
  -map 0:v:0 ^
      -c:v libx264 ^
      -preset veryfast ^
      -x264-params "nal-hrd=cbr" ^
      -b:v 50M ^
      -framerate 60 ^
  -map 0:a:0 ^
      -c:a:0 aac ^
      -b:a 384k ^
  -map 0:a:1  ^
      -c:a:1 aac ^
      -b:a 384k ^
  %outputFile%
  
  ```
  
  When comparing individual frames, I did not notice a difference in quality between this and the original recording. You can change some of the options like the framerate to match your content, or increase the bitrate if you think there is some loss.
  
  
  ---
  
  