Answers.Body: <p><a href="https://superuser.com/q/589390/20798">A similar question came up before</a>.  I posted some of the same thing in my answer there.</p>
  
  <blockquote>
    <p>Is it possible to lower the H.264 video quality and bitrate without
    fully decoding and encoding it?</p>
  </blockquote>
  
  <p>H.264 B and P macroblocks reference frames that have already been processed by the deblocking filter.  The deblocking strength is adaptive to the QP.  I'm not sure, but I think this would lead to problems if you just re-quantized the DCT coefficients.  In any case, I think it would just be a speed-hack that gives worse quality than full decoding + encoding.  And I'm not aware of any implementations.</p>
  
  <p>Nobody's even implemented a bitstream filter to losslessly convert h.264 Baseline to CABAC.  :(  <a href="http://forum.doom9.org/showthread.php?t=104619" rel="nofollow noreferrer">It has been talked about, though</a>.</p>
  
  <p>However, <a href="http://www.academia.edu/929361/Real_time_data_hiding_by_exploiting_the_IPCM_macroblocks_in_H._264_AVC_streams" rel="nofollow noreferrer">this paper</a> does have an implementation that partially decodes h.264, modifies it (for data-hiding), and re-encodes it.  IDK what software he started with for the implementation, but his code, if available and appropriately licensed, might be a good starting point for other bitstream filters.</p>
  
  <blockquote>
    <p>What conversions are in general available for H.264 content? Is there
    a tool for lossless conversions like jpegtran for JPEG?</p>
  </blockquote>
  
  <p><code>jpegtran</code> only works because each DCT coefficient block is completely independent of all others.  Even  h.264 I frames predict from other blocks within the same frame.  (Intra prediction, as opposed to inter prediction in P and B macroblocks).  Lossless rotation or flipping probably isn't possible.  </p>
  
  <p>(Although phone cameras for example can just indicate with metadata that the player should rotate the video on playback, if they are held vertically while recording video.)</p>
  
  <p>ffmpeg has a bitstream filter for h.264 that does something about converting how the h.264 stream is stored, or maybe something about the headers?  IDK, I haven't had to use it, or read up.  From the docs:<br>
  <code>ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264</code></p>
  
  <p>This isn't anything like what you're asking, though.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-24T10:12:13.283Z
Answers.Text: `h264_mp4toannexb` is rather simple, it just convert length-prefixed units to `00 00 00 01`-prefixed ones and stores header in-stream.
Answers.UserDisplayName: Vi.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-24T02:55:47.843Z
Answers.LastActivityDate: 2015-02-24T11:52:50.783Z
Answers.LastEditDate: 2017-03-20T10:18:33.487Z
Answers.UserDisplayName: Peter Cordes
Body: <p>Is it possible to lower the H.264 video quality and bitrate without fully decoding and encoding it?</p>
  
  <p>Are there H.264-specific algoritmhs that can create a video with higher QP based on encoded video with lower QP? </p>
  
  <p>What conversions are in general available for H.264 content? Is there a tool for lossless conversions like <code>jpegtran</code> for JPEG?</p>
  
Tags: <transcoding><h.264>
Title: Is it possible to raise H.264's QP without fully re-encoding the video?
UserDisplayName: Vi.
ThreadText: # Is it possible to raise H.264's QP without fully re-encoding the video?
  
  (Asked by: username_0 on 2015-02-23)
  
  Is it possible to lower the H.264 video quality and bitrate without fully decoding and encoding it?
  
  Are there H.264-specific algoritmhs that can create a video with higher QP based on encoded video with lower QP?
  
  What conversions are in general available for H.264 content? Is there a tool for lossless conversions like `jpegtran` for JPEG?
  
  **Tags:** transcoding, h.264
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-24. Score: 1
  
  [A similar question came up before](https://superuser.com/q/589390/20798). I posted some of the same thing in my answer there.
  
  > Is it possible to lower the H.264 video quality and bitrate without
  > fully decoding and encoding it?
  
  H.264 B and P macroblocks reference frames that have already been processed by the deblocking filter. The deblocking strength is adaptive to the QP. I'm not sure, but I think this would lead to problems if you just re-quantized the DCT coefficients. In any case, I think it would just be a speed-hack that gives worse quality than full decoding + encoding. And I'm not aware of any implementations.
  
  Nobody's even implemented a bitstream filter to losslessly convert h.264 Baseline to CABAC. :( [It has been talked about, though](http://forum.doom9.org/showthread.php?t=104619).
  
  However, [this paper](http://www.academia.edu/929361/Real_time_data_hiding_by_exploiting_the_IPCM_macroblocks_in_H._264_AVC_streams) does have an implementation that partially decodes h.264, modifies it (for data-hiding), and re-encodes it. IDK what software he started with for the implementation, but his code, if available and appropriately licensed, might be a good starting point for other bitstream filters.
  
  > What conversions are in general available for H.264 content? Is there
  > a tool for lossless conversions like jpegtran for JPEG?
  
  `jpegtran` only works because each DCT coefficient block is completely independent of all others. Even h.264 I frames predict from other blocks within the same frame. (Intra prediction, as opposed to inter prediction in P and B macroblocks). Lossless rotation or flipping probably isn't possible.
  
  (Although phone cameras for example can just indicate with metadata that the player should rotate the video on playback, if they are held vertically while recording video.)
  
  ffmpeg has a bitstream filter for h.264 that does something about converting how the h.264 stream is stored, or maybe something about the headers? IDK, I haven't had to use it, or read up. From the docs:  
  `ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264`
  
  This isn't anything like what you're asking, though.
  
  > **Comments:**
  > **username_0**: `h264_mp4toannexb` is rather simple, it just convert length-prefixed units to `00 00 00 01`-prefixed ones and stores header in-stream.  
  
  ---
  
  