View Full Version : New tool to change SAR in H264 bitstream
sneaker_ger
3rd May 2011, 04:49
That's exactly what I want to do: put in the information so that the decoder crops it away at playback.
roozhou
3rd May 2011, 04:56
Blu-ray 1088 is cropped to 1080 by the decoder.
When x264 adds lines to bring content to mod16 for encoding, the decoder crops that information at playback.
If you want to actually remove (crop) lines of resolution from the source. You will have to re-encode.
You are wrong. mod16 is required for all AVC streams internally. All non-mod16 frames are padded to mod16 before reaching the encoder. The SPS contains the cropping information so the decoder can correctly crop the padded lines after the frame is decoded.
@sneaker_ger
Do not trust MediaInfo. All field names starting with "Original" are invented by MediaInfo's author. They actually mean information stored in the bitstream and are only shown when it differs from those in the container.
sneaker_ger
3rd May 2011, 05:03
@sneaker_ger
Do not trust MediaInfo. All field names starting with "Original" are invented by MediaInfo's author. They actually mean information stored in the bitstream and are only shown when it differs from those in the container.
The problem is that I'm already outputting to ES. The information is still in there and the decoders also detect and output 1088 lines. There must be some value for the height (or another value the decoders use to calculate the height with) that we also need to change.
roozhou
3rd May 2011, 05:08
Can you provide a sample? And the full information from MediaInfo?
I tested a few ES files and I have never seen "Original height" after conversion.
sneaker_ger
3rd May 2011, 05:26
Ok, I made a test with a freshly encoded file and it does work on that one. Don't know why the other one doesn't work (old x264 and mkvmerge).
I've put both here - maybe you can figure it out:
https://rapidshare.com/files/460343247/ffmpeg_crop_sample.7z
sneaker_ger
3rd May 2011, 06:14
Update:
It seems to apply to all ES once muxed and later extracted again with mkvtoolnix. ffmpeg changes something, otherwise the "original height" line wouldn't show up in Media Info, but the decoders and mkvmerge continue to assume 1088 lines.
Audionut
3rd May 2011, 07:57
You are wrong.
Really!
mod16 is required for all AVC streams internally.
Where did I say otherwise?
All non-mod16 frames are padded to mod16 before reaching the encoder. The SPS contains the cropping information so the decoder can correctly crop the padded lines after the frame is decoded.
Which is another way of saying, "adds lines to bring content to mod16 for encoding, the decoder crops that information at playback."
Which leads us directly back to the fact that if you want to crop the source file itself, it has to be re-encoded.
Seriously :eek:
sneaker_ger
3rd May 2011, 08:05
Which leads us directly back to the fact that if you want to crop the source file itself, it has to be re-encoded.
Which by your logic leads back to step one because the encoder will pad the video right away yet again. ;)
Audionut
3rd May 2011, 08:25
Which by your logic leads back to step one because the encoder will pad the video right away yet again. ;)
Yeah, if you are cropping to a non-mod16 resolution and using a AVC based encoder :thanks:
Either way, run a search. There are cases where cropping and having the encoder pad the source for encoding can be beneficial.
I'll try one last time, regardless of what you are doing with the source afterwards, if you want to crop (remove information) from the source, it has to be re-encoded. :search::readfaq:
sneaker_ger
3rd May 2011, 08:48
Yeah, if you are cropping to a non-mod16 resolution and using a AVC based encoder :thanks:
cropping to non-mod16: check (1088 to 1080)
AVC: check
What was your point again?
Either way, run a search. There are cases where cropping and having the encoder pad the source for encoding can be beneficial.
The only reason to use this tool in the first place is to not do any re-encoding at all. If I wanted to re-encode I could set everything correctly in x264.
I'll try one last time, regardless of what you are doing with the source afterwards, if you want to crop (remove information) from the source, it has to be re-encoded. :search::readfaq:
I never said or implied I wanted to remove information in a way that makes it impossible to recover nor is there a mutual agreement on the definition of the word "cropping" meaning exactly that.
roozhou
16th May 2011, 07:01
New build available.
1) Fixed crash in ADTS->MKV muxing
2) Fixed removedupheader in h264_chagnesps filter
@sneaker_ger
Your problem can be solved by adding removedupheader to h264_changesps with the latest build.
sneaker_ger
16th May 2011, 07:25
@sneaker_ger
Your problem can be solved by adding removedupheader to h264_changesps with the latest build.
Great, thank you for all your effort!
It worked in a short test, though XhmikosR's ffdshow 3850 ICL build decided to crash when I used removedupheader. But updating to 3853 fixed it.
b66pak
16th May 2011, 19:50
thanks a lot...
_
b66pak
30th May 2011, 20:35
remuxing mkv to m4v return an error on some files...
[ipod @ 016201b0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 1
[ipod @ 016201b0] pts < dts in stream 0
av_interleaved_write_frame(): Invalid argument
_
roozhou
15th August 2011, 12:33
New version available. Fixed a bug on modifying color matrix information.
b66pak
15th August 2011, 18:41
thanks a lot...
_
XMEN3
19th August 2011, 16:22
ffmpeg.exe -i input.mkv -vcodec copy -an -vbsf h264_changesps=cfr/fps=24000:1001 new.mkv
ffmpeg version N-31792-g51fb933, Copyright (c) 2000-2011 the FFmpeg developers
built on Aug 11 2011 23:13:25 with gcc 4.5.2
configuration:
libavutil 51. 11. 1 / 51. 11. 1
libavcodec 53. 10. 0 / 53. 10. 0
libavformat 53. 6. 0 / 53. 6. 0
libavdevice 53. 2. 0 / 53. 2. 0
libswscale 2. 0. 0 / 2. 0. 0
[matroska,webm @ 003587c0] max_analyze_duration 5000000 reached at 5024000
[matroska,webm @ 003587c0] Estimating duration from bitrate, this may be inaccur
ate
Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (18
0000/1) -> 1000.00 (1000/1)
Input #0, matroska,webm, from x.mkv
':
Metadata:
title : x Duration: 02:50:07.04, start: 0.000000, bitrate: 448 kb/s
Stream #0.0(ita): Video: h264 (High), yuv420p, 1024x432, SAR 1:1 DAR 64:27,
23.98 fps, 1k tbr, 1k tbn, 180k tbc (default)
Metadata:
title : x
Stream #0.1(ita): Audio: [0][0][0][0] / 0x0000, 48000 Hz, 5.1, 448 kb/s (def
ault)
Metadata:
title : x
Stream #0.2(eng): Subtitle: [0][0][0][0] / 0x0000
Metadata:
title : x
File 'D:\x_fix.mkv' already exists.
Overwrite ? [y/N] y
Output #0, matroska, to 'D:\x_fix.mkv':
Stream #0.0(ita): Video: [0][0][0][0] / 0x0000, yuv420p, 1024x432 [SAR 1:1 D
AR 64:27], q=0-0, 90k tbn, 1k tbc (default)
Metadata:
title : x
Stream #0.1(eng): Subtitle: [0][0][0][0] / 0x0000
Metadata:
title : x
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.2 -> #0.1
Encoder (codec id 94212) not found for output stream #0.1
roozhou
20th August 2011, 12:56
@XMEN3
Is srt subtitle supported in official ffmpeg build?
b66pak
20th August 2011, 20:31
@XMEN3 add "-scodec copy" to your line...
_
N.B. when you post a report error you MUST provide the line you use it...
_
XMEN3
20th August 2011, 23:04
@XMEN3 add "-scodec copy" to your line...
_
N.B. when you post a report error you MUST provide the line you use it...
_
adding -scodec copy works
ffmpeg.exe -i input.mkv -vcodec copy -scodec copy -an -vbsf h264_changesps=cfr/fps=24000:1001 new.mkv
Why the audio stream is not copied and doesnt give me error msg.
I mean why it doesn't skeep srt like ac3 stream...
tnx
nm
21st August 2011, 10:24
Why the audio stream is not copied and doesnt give me error msg.
Because you used option -an, which makes ffmpeg skip all audio streams.
I mean why it doesn't skeep srt like ac3 stream...
Because you didn't use option -sn
andre2
21st August 2011, 17:06
Thanks roozhou,
is there any chance to crop pixels from left too in a future update?
vmrsss
4th September 2011, 05:39
Thanks for this.
I think I might have bumped into a bug of the tool. Pls look at the screenshots below, taken on fileIN and fileOUT after just running
wine ffmpeg -i fileIN.mkv -an -vcodec copy -vbsf h264_changesps=fps=24:1 fileOUT.mkv
http://localhostr.com/file/hajG22v/orig-1-48-15.png
http://localhostr.com/file/8AxJQ0X/encoded-1-48-15.png
you will notice a blurry stripe at the bottom from the centre to the right border. I have verified this with VLC, mplayer and ffplay.
Cheers.
b66pak
4th September 2011, 17:09
could you test with this line too?
wine ffmpeg -i fileIN.mkv -an -vcodec copy -vbsf h264_changesps=fps=24000:1000 fileOUT.mkv
vmrsss
4th September 2011, 22:43
could you test with this line too?
Travelling for the week. Will do it as soon as i can.
roozhou
5th September 2011, 16:11
@vmrsss
Did mplayer or ffplay show any error messages?
djesteban
5th September 2011, 17:28
Hey roozhou, thanks for this tool, it's a very practical one ;P
I have a question though, but first let me explain what I'm trying to achieve:
I have a h264 file that's running at 25fps and was tagged as interlaced in order to be blu-ray compliant (but in reality, the file is progressive). At 25fps, the file as a 4% PAL speed-up, so with your tool, I was able to change the fps to 23.976.
ffmpeg -i input.h264 -vcodec copy -an -vbsf h264_changesps=fps=24000:1001 output.h264
Now, if I look at my output file in tsMuxeR and in MediaInfo, it is indeed running at 23.976, but it still displays the interlaced and PAL flag (tsMuxeR says resolution (1920:1080i) and MediaInfo says AVC (PAL)).
Is there a way with your tool to change those two flags? So I can change them to the correct progressive and NTSC value?
Thanks in advance,
Cheers
roozhou
6th September 2011, 03:06
@djesteban
Sorry, you cannot change interlaced to progressive. The decoder may not work correctly if you manually change it. Since there is no native 23.976i content, MediaInfo may recognize it as PAL.
djesteban
6th September 2011, 04:04
@djesteban
Sorry, you cannot change interlaced to progressive. The decoder may not work correctly if you manually change it. Since there is no native 23.976i content, MediaInfo may recognize it as PAL.
You can't modify that flag even if it's faked interlaced? Cause like I said, it was originally flagged as interlaced to be Blu-Ray compliant with a fps of 25.
J_Darnley
6th September 2011, 10:04
x264's --fake-interlaced option encodes every frame as progressive using PAFF so that decoders and displays don't try to deinterlace it.
djesteban
6th September 2011, 20:11
x264's --fake-interlaced option encodes every frame as progressive using PAFF so that decoders and displays don't try to deinterlace it.
So technically, in my case if my h264 file was 25 fps fake interlaced, and I change the fps to 23.976, there should be no problem changing the interlaced flag to progressive? Or am I completely wrong?
b66pak
6th September 2011, 20:19
it can't be changed...mux it to mkv 24000/1001fps and it will play progressive (you can do this with the original h264 - no need to change from 25fps to 24000/1001fps - just mux the 25fps as 24000/1001fps!!!)...
_
vmrsss
12th September 2011, 11:17
could you test with this line too?
Back to this, it looks as though this line works. I couldn't check the entire stream, but certainly the blurred stripe on the frame I posted has gone.
edit: let me know if I can be of more help.
bernd_b
12th September 2011, 12:20
it can't be changed...mux it to mkv 24000/1001fps and it will play progressive
I tried this. Yes, mplayer, vlc & Co will play such a file with 23.976fps.
But my LG stand alone BluRay device, e.g., ignores the frame rate given by the mkv-container and treat it like PAL again (meaning the player uses the frame rate given by the video stream itself).
Mediainfo, applied to such files, shows both frame rates: the one of the container and the one of the video stream itself.
TsMuxerR can change the frame rate flag of the video stream using the demux option (so it can be changed without reencoding).
I would appreciate to be able to change the frame rate of the h264-stream with the tool discussed here too.
nm
12th September 2011, 12:40
I would appreciate to be able to change the frame rate of the h264-stream with the tool discussed here too.
roozhou's tool is quite capable of doing what you ask for. Just do it.
bernd_b
12th September 2011, 12:51
O.K, I'll give it a try. So I must have misunderstood the previous discussions ....
nm
12th September 2011, 12:57
O.K, I'll give it a try. So I must have misunderstood the previous discussions ....
Yep. They were about progressive video encoded as interlaced (or "fake-interlaced") and changing the type of coding used, which is not possible without re-encoding. Anyway, changing the framerate should be enough for most players.
bernd_b
17th September 2011, 20:18
Still don't get it.
I have
mediainfo /media/Trek2GB/Case_Histories_25fps/Case_Histories_01.mkv
General
Unique ID : 149330324381653275972509458345966668574 (0x7057F96DE60647CCF7FCF3CE45C38B1E)
Complete name : /media/Trek2GB/Case_Histories_25fps/Case_Histories_01.mkv
Format : Matroska
Format version : Version 2
File size : 2.58 GiB
Duration : 59mn 4s
Overall bit rate : 6 250 Kbps
Encoded date : UTC 2011-08-21 14:24:20
Writing application : mkvmerge v4.9.1 ('Ich will') built on Jul 17 2011 13:09:54
Writing library : Lavf53.4.0
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Format settings, GOP : M=4, N=12
Codec ID : V_MPEG4/ISO/AVC
Duration : 59mn 4s
Bit rate : 5 742 Kbps
Width : 1 440 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : MBAFF
Bits/(Pixel*Frame) : 0.148
Stream size : 2.37 GiB (92%)
Color primaries : BT.709-5, BT.1361, IEC 61966-2-4, SMPTE RP177
Transfer characteristics : BT.709-5, BT.1361
Matrix coefficients : BT.709-5, BT.1361, IEC 61966-2-4 709, SMPTE RP177
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Codec ID : A_AC3
Duration : 59mn 4s
Bit rate mode : Constant
Bit rate : 384 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Delay relative to video : -1s 360ms
Stream size : 162 MiB (6%)
Language : English
Now I do
wine ffmpeg.exe -i /media/Trek2GB/Case_Histories_25fps/Case_Histories_01.mkv -an -vcodec copy -vbsf h264_changesps=fps=24000:1000 CH_01_23976fps.h264
fixme:ntoskrnl:KeInitializeSpinLock stub: 0x5477a4
fixme:advapi:RegisterTraceGuidsW (0x100778a, 0x100a060, {485e7de8-0a80-11d8-ad15-505054503030}, 1, 0x33fe00, (null), (null), 0x100a068,): stub
fixme:advapi:RegisterTraceGuidsW (0x100778a, 0x100a080, {485e7de9-0a80-11d8-ad15-505054503030}, 1, 0x33fe00, (null), (null), 0x100a088,): stub
fixme:advapi:RegisterTraceGuidsW (0x100778a, 0x100a0a0, {485e7dea-0a80-11d8-ad15-505054503030}, 1, 0x33fe00, (null), (null), 0x100a0a8,): stub
fixme:advapi:RegisterTraceGuidsW (0x100778a, 0x100a0c0, {485e7deb-0a80-11d8-ad15-505054503030}, 1, 0x33fe00, (null), (null), 0x100a0c8,): stub
fixme:advapi:RegisterTraceGuidsW (0x100778a, 0x100a0e0, {485e7dec-0a80-11d8-ad15-505054503030}, 1, 0x33fe00, (null), (null), 0x100a0e8,): stub
fixme:advapi:RegisterTraceGuidsW (0x100778a, 0x100a100, {485e7ded-0a80-11d8-ad15-505054503030}, 1, 0x33fe00, (null), (null), 0x100a108,): stub
fixme:win:RegisterDeviceNotificationW (hwnd=0x12de68, filter=0x54e93c,flags=0x00000001) returns a fake device notification handle!
ffmpeg version N-31792-g51fb933, Copyright (c) 2000-2011 the FFmpeg developers
built on Aug 11 2011 23:13:25 with gcc 4.5.2
configuration:
libavutil 51. 11. 1 / 51. 11. 1
libavcodec 53. 10. 0 / 53. 10. 0
libavformat 53. 6. 0 / 53. 6. 0
libavdevice 53. 2. 0 / 53. 2. 0
libswscale 2. 0. 0 / 2. 0. 0
[matroska,webm @ 0013eed0] max_analyze_duration 5000000 reached at 5024000
[matroska,webm @ 0013eed0] Estimating duration from bitrate, this may be inaccurate
Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 25.00 (50/2)
Input #0, matroska,webm, from '/media/Trek2GB/Case_Histories_25fps/Case_Histories_01.mkv':
Metadata:
ENCODER : Lavf53.4.0
Duration: 00:59:04.92, start: 0.000000, bitrate: 192 kb/s
Stream #0.0: Video: h264 (High), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0.1(eng): Audio: [0][0][0][0] / 0x0000, 48000 Hz, stereo, 192 kb/s (default)
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
Output #0, h264, to 'CH_01_23976fps_2.h264':
Metadata:
ENCODER : Lavf53.4.0
Stream #0.0: Video: [0][0][0][0] / 0x0000, yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=0-0, 90k tbn, 24 tbc (default)
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop, [?] for help
[h264 @ 00141450] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 122400 >= 37260
[h264 @ 00141450] pts < dts in stream 0
[h264 @ 00141450] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 122400 >= 74430
[h264 @ 00141450] pts < dts in stream 0
[h264 @ 00141450] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 122400 >= 111600
[h264 @ 00141450] pts < dts in stream 0
[h264 @ 00141450] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 122400 >= 115200
[h264 @ 00141450] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 122401 >= 118800
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=37560, dts=37621, size=8045
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=37580, dts=37622, size=8597
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=37720, dts=37781, size=15405
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=37740, dts=37782, size=15405
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=37880, dts=37941, size=20556
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=37900, dts=37942, size=20364
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=39480, dts=39541, size=12292
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=39500, dts=39542, size=11908
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=39640, dts=39701, size=22204
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=39660, dts=39702, size=22220
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=41440, dts=41501, size=33253
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=41460, dts=41502, size=29398
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=41600, dts=41661, size=27916
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=41620, dts=41662, size=27732
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=41760, dts=41821, size=20740
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=41780, dts=41822, size=17980
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=42720, dts=42781, size=34172
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=42740, dts=42782, size=34541
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=42880, dts=42921, size=31228
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=42900, dts=42922, size=31228
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=61400, dts=61441, size=62685
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=61560, dts=61621, size=29020
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=61580, dts=61622, size=27916
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=61720, dts=61781, size=29205
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=61740, dts=61782, size=29389
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=88920, dts=88961, size=5837
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=89080, dts=89141, size=9148
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=89100, dts=89142, size=11356
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=89240, dts=89301, size=9702
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=89260, dts=89302, size=11724
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=89400, dts=89441, size=10437
[h264 @ 00141450] pts < dts in stream 0
[matroska,webm @ 0013eed0] Invalid timestamps stream=0, pts=89420, dts=89442, size=12645
[h264 @ 00141450] pts < dts in stream 0
....
and so on.
The resulting file looks like this:
mediainfo CH_01_23976fps.h264
General
Complete name : CH_01_23976fps.h264
File size : 2.50 GiB
and it is not playable by mplayer or xine.
roozhou
18th September 2011, 09:06
@bernd_b
you need h264_mp4toannexb
bernd_b
19th September 2011, 16:30
I guess I'm too stupid for this?!:
Do I have to make two runs then?
At least:
wine ffmpeg.exe -i Case_Histories_01.mkv -vcodec copy -an -vbsf h264_mp4toannexb CH_01.h264
gives some output:
mediainfo CH_01.h264
General
Complete name : CH_01.h264
Format : AVC
Format/Info : Advanced Video Codec
File size : 2.50 GiB
Video
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Format settings, GOP : M=4, N=12
Width : 1 440 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : MBAFF
Color primaries : BT.709-5, BT.1361, IEC 61966-2-4, SMPTE RP177
Transfer characteristics : BT.709-5, BT.1361
Matrix coefficients : BT.709-5, BT.1361, IEC 61966-2-4 709, SMPTE RP177
But the second pass
wine ffmpeg.exe -i CH_01.h264 -vcodec copy -an -vbsf h264_changesps=fps=24000:1000 CH_01_23976.h264
leads to
mediainfo CH_01_23976.h264
General
Complete name : CH_01_23976.h264
File size : 2.50 GiB
again. Or can (and do!) I set two -vbsf option in one run?
b66pak
19th September 2011, 16:51
this is what you need:
ffmpeg -i input.mkv -vbsf h264_changesps=fps=24000:1000 -vcodec copy -an -sn -vbsf h264_mp4toannexb=norepeatheader output.h264
_
bernd_b
19th September 2011, 17:39
Thanks for your reply.
I did
wine /extern08/ffmpeg_sar_x264/ffmpeg.exe -i /media/Trek2GB/Case_Histories_25fps/Case_Histories_01.mkv -vbsf h264_changesps=fps=24000:1000 -vcodec copy -an -sn -vbsf h264_mp4toannexb=norepeatheader Ch_01_23976.h264
But the result is the same.
b66pak
19th September 2011, 18:57
indeed is looks like -vbsf h264_changesps is not working with MBAFF...
_
roozhou
19th September 2011, 19:32
@bernd_b
AFAIK mkv->mkv and then mkv->h264 will work. Of course you can use , to secify filter chain like -vbsf h264_changesps=fps=24000:1000,h264_mp4toannexb, but it will produce broken file as well. I will try to fix this in the following days.
vmrsss
19th September 2011, 20:57
could you test with this line too?
@vmrsss
Did mplayer or ffplay show any error messages?
Sorry to get back to this, but I am not clear about its resolution.
So fps=24:1 does not work, whilst fps=24000:1000 does. What's the general rule? Should I use four digits at the denominator?
bernd_b
10th October 2011, 21:59
@bernd_b
AFAIK mkv->mkv and then mkv->h264 will work.
I did some further tries with other source files. And indeed, basically it works.
E.G. doing
1. ffmpeg.exe -i 25fps.mkv -an -vbsf h264_changesps=fps=24000:1001 -vcodec copy 23976.mkv
2. ffmpeg.exe -i 25fps.mkv -vn -acodec copy 25fps.ac3
3. Converting the audio like discussed here (http://forum.doom9.org/showthread.php?t=155031) to, e.g., 23976.ac3
4. Remuxing: mkvmerge --compression -1:none --default-duration 0:23.976fps 23976.mkv --compression -1:none 23976.ac3 -o 23976fps_ready.mkv
So it seems to me you have to keep the video stream in a mkv-container or do a further run using as proposed here the "-vbsf h264_mp4toannexb=norepeatheader" option.
But with or without this further run: The resulting files will play fine with mplayer, vlc or xine and mediainfo shows the frame rate of the video stream not(!) to be different to the one of the mkv-container.
Still, playing these files with my hardware-players (LG BD350 or xoro 8600CI) I get every few minutes a disturbed picture. I looks like a frame is not loaded completely and then all further frames depending on this one are disturbed too. After some seconds the picture gets clear again and the movie runs fine for some minutes until the next error.
Strangely, demuxing the same source files with TSMuxerR and doing the same steps afterwards leads to error free movies on both - the software players and the hardware players.
SeeMoreDigital
11th October 2011, 21:25
Is there a GUI for this software?
XMEN3
24th October 2011, 17:48
ffmpeg.exe -i input.mkv -vcodec copy -sn -an -vbsf h264_changesps=cfr/fps=24000:1001/sar=1037:1024 output.mkv
I need to revert from square pixel to anamorphic to fix a wrong DAR from 2.37 PAR 1:1 to 2.35
with PAR 1037:1024.
Won't work with sar=1037:1024.
Only custom pixel shape is changed.
Resulting file is still PAR 1:1.
Edit:
Anyway I've tested the resulting stream on Ps3 with ts container and a mark on the display
and works the custom pixel shape even if still square pixel.
The testing video 848x368 (DAR error 2%) with custom pixel shape changed from 1:1
to 1081:1060 appears about 1cm flattened compared to the original with square pixel.
Pixel aspect ratio is still 1:1.
So it works but i don't understand why the pixel aspect ratio is changed to 1:1 starting from anamorphic, when not specified, and is not changed to anamorphic starting from 1:1, when specified.
It changes anamorphic input to square pixel even without specifing sar and keeps only pixel shape.
Why?
D:\>ffmpeg.exe -i input.mkv -vcodec copy -sn -an -vbsf h264_changesps=cfr/fps=24000:1001 out.mkv
ffmpeg version N-31792-g51fb933, Copyright (c) 2000-2011 the FFmpeg developers
...
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/
1001) -> 23.98 (48000/2002)
Input #0, matroska,webm, from 'input.mkv':
Duration: 00:01:00.93, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264 (High), yuv420p, 848x352 [SAR 264:265 DAR 12:5], SAR 254:255 DAR 6731:2805, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Output #0, matroska, to 'out.mkv':
Stream #0.0: Video: H264 / 0x34363248, yuv420p, 848x352 [SAR 254:255 DAR 6731:2805], q=0-0, 1k tbn, 23.98 tbc (default)
input.mkv:
Codec ID V_MPEG4/ISO/AVC
Resolution 848 x 352
Display resolution 848 x 353 (pixels)
Frame aspect ratio 53:22 = 2.409
Pixel aspect ratio 352:353 = 0.997
Display aspect ratio 848:353 = 2.402
Framerate 23.976 fps
Video bitstream
Bitstream type MPEG-4 Part 10
User data x264 | core 116 r2074 2641b9e
...
User data aq=1:1.00
SPS id 0
Aspect ratio Custom pixel shape (264:265 = 0.996)
PPS id 0 (SPS: 0)
out.mkv:
Anamorphic pixel lost?
The output stream is now square pixel but the custom pixel shape is still there...
Codec ID V_MPEG4/ISO/AVC
Resolution 848 x 352
Frame aspect ratio 53:22 = 2.409
Pixel aspect ratio 1:1 = 1
Display aspect ratio 53:22 = 2.409
Framerate 23.976 fps
Video bitstream
Bitstream type MPEG-4 Part 10
User data x264 | core 116 r2074 2641b9e
...
User data aq=1:1.00
SPS id 0
Aspect ratio Custom pixel shape (264:265 = 0.996)
PPS id 0 (SPS: 0)
Pix
31st October 2011, 23:08
what would be the command line if I wanted to keep everything the same except sar value?
I tried using the default template provided in the OP but I got a 1000fps file, with really weird specs...
ffmpeg -i infile.mkv -vcodec copy -acodec copy -vbsf h264_changesps=sar=x:y outfile.mkv
There's audio, video, subtitle stream in the infile.mkv... I just wanted to change the sar on the video :D
roozhou
3rd November 2011, 03:03
@Pix,
There is a bug in the mkv muxer. Add -muxerfps 24000/1001 to your commandline to set the fps in mkv header.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.