zn
15th October 2018, 12:13
Is it possible to join 2 videos (2 parts), they are from the same hdtv 50 fps source, second part is untouched 50 fps, first part was re-encoded from 50 to 25 fps.
I'd like to keep second part untouched after merging, can you help me to find setting to encode 25 fps to 50 fps so I can join them with (mkvmerge, ffmpeg)
Input #0, h264, from '1.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1200k tbn, 50 tbc
Input #0, h264, from '2.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 1200k tbn, 100 tbc
When trying to mkvmerge without re-encoding it didn't work:
mkvmerge -o test.mkv -A 1.mkv -A +2.ts ↑
mkvmerge v27.0.0 ('Metropolis') 64-bit
'1.mkv': Using the demultiplexer for the format 'Matroska'.
'2.ts': Using the demultiplexer for the format 'MPEG transport stream'.
'1.mkv' track 0: Using the output module for the format 'AVC/h.264'.
'2.ts' track 0: Using the output module for the format 'AVC/h.264 (unframed)'.
No append mapping was given for the file no. 1 ('2.ts'). A default mapping of 1:0:0:0 will be used instead.
Please keep that in mind if mkvmerge aborts with an error message regardin
g invalid '--append-to' options.
Error: The track number 0 from the file '2.ts' cannot be appended to the track number 0 from the file '1.mkv'. The formats do not match.
So, I want to re-encode:
25 fps / Main@L3.1 / cabac=0 / ref=5 (mediainfo) / 'AVC/h.264'
to
50 fps / High@L3.2 / cabac=1 / ref=2 (mediainfo) / 'AVC/h.264 (unframed)' / “Format settings, GOP : M=3, N=50”,
-- To get ref=2 and cabac=1 (mediainfo):
ffmpeg -i 25fps.mkv -r 50 -refs 1 -x264opts b-pyramid=0 -crf 20 -acodec copy 50fps.mkv
-- To get GOP size(M=3) and GOP length(N=50), not sure if this correct:
-x264opts keyint=50:min-keyint=3:no-scenecut
-- To double fps:
ffmpeg -i 25.mkv -r 50 -vsync 0 -vf setpts=N/50/TB -refs 1 -x264opts b-pyramid=0:keyint=50:min-keyint=3:no-scenecut -acodec copy -crf 22 50fps.mkv
After encoding this file can be merged with untouched 50fps file, it can be played, but seeking back to first part of the video do not work, I am getting this error in mpv:
Error while decoding frame!
[ffmpeg/video] h264: illegal modification_of_pic_nums_idc 7
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
Error while decoding frame!
Other error messagewhen trying to seek back file encoded with less settings:
ffmpeg -i 25.mkv -r 50 -vsync 0 -vf setpts=N/50/TB -crf 22 50fps.mkv
Error while decoding frame!
[ffmpeg/video] h264: deblocking_filter_idc 5 out of range
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
[ffmpeg/video] h264: co located POCs unavailable
I'd like to keep second part untouched after merging, can you help me to find setting to encode 25 fps to 50 fps so I can join them with (mkvmerge, ffmpeg)
Input #0, h264, from '1.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1200k tbn, 50 tbc
Input #0, h264, from '2.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 1200k tbn, 100 tbc
When trying to mkvmerge without re-encoding it didn't work:
mkvmerge -o test.mkv -A 1.mkv -A +2.ts ↑
mkvmerge v27.0.0 ('Metropolis') 64-bit
'1.mkv': Using the demultiplexer for the format 'Matroska'.
'2.ts': Using the demultiplexer for the format 'MPEG transport stream'.
'1.mkv' track 0: Using the output module for the format 'AVC/h.264'.
'2.ts' track 0: Using the output module for the format 'AVC/h.264 (unframed)'.
No append mapping was given for the file no. 1 ('2.ts'). A default mapping of 1:0:0:0 will be used instead.
Please keep that in mind if mkvmerge aborts with an error message regardin
g invalid '--append-to' options.
Error: The track number 0 from the file '2.ts' cannot be appended to the track number 0 from the file '1.mkv'. The formats do not match.
So, I want to re-encode:
25 fps / Main@L3.1 / cabac=0 / ref=5 (mediainfo) / 'AVC/h.264'
to
50 fps / High@L3.2 / cabac=1 / ref=2 (mediainfo) / 'AVC/h.264 (unframed)' / “Format settings, GOP : M=3, N=50”,
-- To get ref=2 and cabac=1 (mediainfo):
ffmpeg -i 25fps.mkv -r 50 -refs 1 -x264opts b-pyramid=0 -crf 20 -acodec copy 50fps.mkv
-- To get GOP size(M=3) and GOP length(N=50), not sure if this correct:
-x264opts keyint=50:min-keyint=3:no-scenecut
-- To double fps:
ffmpeg -i 25.mkv -r 50 -vsync 0 -vf setpts=N/50/TB -refs 1 -x264opts b-pyramid=0:keyint=50:min-keyint=3:no-scenecut -acodec copy -crf 22 50fps.mkv
After encoding this file can be merged with untouched 50fps file, it can be played, but seeking back to first part of the video do not work, I am getting this error in mpv:
Error while decoding frame!
[ffmpeg/video] h264: illegal modification_of_pic_nums_idc 7
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
Error while decoding frame!
Other error messagewhen trying to seek back file encoded with less settings:
ffmpeg -i 25.mkv -r 50 -vsync 0 -vf setpts=N/50/TB -crf 22 50fps.mkv
Error while decoding frame!
[ffmpeg/video] h264: deblocking_filter_idc 5 out of range
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
[ffmpeg/video] h264: co located POCs unavailable