[FFmpeg-user] Proper way to reverse PAL Speed up?

Bernd Butscheidt bbutscheidt at yahoo.de
Sat Feb 2 23:00:17 CET 2013


Hello,

I tried to find a way to reverse the PAL Speed up used by television broadcasts back to ntsc film using recent ffmpeg. The HD-Television stream like the one used in the example given below are actually broadcast with 50fps.


The following command shows what I sorted out so far. The results were pretty convincing if I wouldn't need to add an offset of about 300ms to have the resulting video in sync with audio. The offset seems to be the same regardless of the source (different television stations or even DVD material) or the audio codec used (I tested with ac3 and libmp3).

So I'd like to know if anyone has an opinion if what I am doing should have a chance of being successful at all and why this offset (+0.300/TB e.g.) is needed with using the audio filters asetpts and aresample. What, if needed at all, would be the right value?

Here as already announced, a complete, uncut output:


/extern07/ffmpeg_neu/ffmpeg/ffmpeg -y -i Sport_HD.ts -vsync 1 -map 0:0 -vcodec libx264 -preset veryfast -x264opts crf=12:videoformat=undef:force-cfr -map 0:4,0:0 -acodec ac3 -ab 448k -filter:v setpts=25025/24000*PTS,hqdn3d,delogo=60:48:126:46:5 -filter:a asetpts=25025/24000*PTS+0.300/TB,aresample=48000:async=1:min_comp=0.01:comp_duration=1:max_soft_comp=100000000:min_hard_comp=0.3 -f matroska -r 24000/1001 Sport_HD_ntsc.mkv

ffmpeg version 1.1.git Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 26 2013 19:21:36 with gcc 4.6.3 (Gentoo Hardened 4.6.3 p1.3, pie-0.5.2)
  configuration: --enable-avresample --enable-gpl --enable-libx264 --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-frei0r --enable-libsoxr --cpu=amd64 --arch=x86_64
  libavutil      52. 16.100 / 52. 16.100
  libavcodec     54. 91.100 / 54. 91.100
  libavformat    54. 61.104 / 54. 61.104
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 33.101 /  3. 33.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0x23be420] Stream #5: not enough frames to estimate rate; consider increasing probesize
[NULL @ 0x23c5460] start time is not set in estimate_timings_from_pts                                                                                                                                                                       
[mpegts @ 0x23be420] PES packet size mismatch                                                                                                                                                                                               
    Last message repeated 3 times
Input #0, mpegts, from 'Sport_HD.ts':
  Duration: 00:01:54.01, start: 14959.428778, bitrate: 14382 kb/s
  Program 132 
    Stream #0:0[0x17de]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0:1[0x17e8](deu): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 256 kb/s
    Stream #0:2[0x17e9](mis): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0:3[0x17eb](mul): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0:4[0x17ea](deu): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 448 kb/s
    Stream #0:5[0x17f3](deu): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
[libx264 @ 0x2ca4060] using SAR=1/1
[libx264 @ 0x2ca4060] using cpu capabilities: MMX2 SSE2Slow SlowCTZ
[libx264 @ 0x2ca4060] profile High, level 3.1
[libx264 @ 0x2ca4060] 264 - core 125 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=12.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'Sport_HD_ntsc.mkv':
  Metadata:
    encoder         : Lavf54.61.104
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1k tbn, 23.98 tbc
    Stream #0:1(deu): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 448 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:4 -> #0:1 (ac3 -> ac3)
Press [q] to stop, [?] for help
PES packet size mismatch.0 size=  137059kB time=00:01:58.36 bitrate=9486.0kbits/s dup=12 drop=2827    
[ac3 @ 0x23c4a80] incomplete frame
frame= 2850 fps= 13 q=-1.0 Lsize=  138583kB time=00:01:58.78 bitrate=9557.3kbits/s dup=12 drop=2831    
video:132054kB audio:6480kB subtitle:0 global headers:0kB muxing overhead 0.034916%
[libx264 @ 0x2ca4060] frame I:15    Avg QP: 9.57  size:251800
[libx264 @ 0x2ca4060] frame P:1024  Avg QP:12.64  size: 90507
[libx264 @ 0x2ca4060] frame B:1811  Avg QP:16.87  size: 21406
[libx264 @ 0x2ca4060] consecutive B-frames:  6.5% 14.7% 35.2% 43.6%
[libx264 @ 0x2ca4060] mb I  I16..4:  5.3%  8.7% 85.9%
[libx264 @ 0x2ca4060] mb P  I16..4:  2.6%  1.2%  1.7%  P16..4: 46.3% 20.6% 23.9%  0.0%  0.0%    skip: 3.8%
[libx264 @ 0x2ca4060] mb B  I16..4:  0.2%  0.1%  0.1%  B16..8: 21.9% 11.5%  4.5%  direct:20.4%  skip:41.1%  L0:22.9% L1:35.3% BI:41.7%
[libx264 @ 0x2ca4060] 8x8 transform intra:19.5% inter:21.7%
[libx264 @ 0x2ca4060] coded y,uvDC,uvAC intra: 76.0% 76.3% 63.6% inter: 39.5% 28.8% 11.1%
[libx264 @ 0x2ca4060] i16 v,h,dc,p: 41% 32% 21%  6%
[libx264 @ 0x2ca4060] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 29% 28%  2%  5%  4%  5%  3%  5%
[libx264 @ 0x2ca4060] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 26% 19%  2%  8%  6%  6%  4%  7%
[libx264 @ 0x2ca4060] i8c dc,h,v,p: 47% 28% 17%  7%
[libx264 @ 0x2ca4060] Weighted P-Frames: Y:1.1% UV:1.1%
[libx264 @ 0x2ca4060] kb/s:9100.66


More information about the ffmpeg-user mailing list