[MEncoder-users] MEncoder SVN-r26664 interlaced AVCHD decoding issues, sample PF24 M2TS clip available

Werner Johansson wj at xnk.nu
Sun May 4 22:31:46 CEST 2008


Werner Johansson wrote:
> Hi all,
>
> I understand that AVCHD h.264 container support in MPlayer/MEncoder is a 
> recent addition and there seems to be some odd behavior. What I try to 
> accomplish with this setup is to extract true 24p footage for editing 
> from a Canon Vixia HF10 camcorder writing "PF24" AVCHD files in a 
> 1920x1080i container (hard telecined, no flags present). The first odd 
> thing is that the framerate of the video cannot be automatically 
> detected but needs to be forced. I tried setting it to 30000/1001 which 
> would be the logical value, but the video then runs at half speed. I 
> googled some and found others having the same issue and they solved it 
> by using 60000/1001 and got the correct video length. To extract true 
> 24p the detc or filmdint filters seems like a logical choice. I have 
> spotted two issues so far with this setup though:
>
> 1: For some reason the clips from the camcorder have 4 initial bad 
> frames with "B picture before any references, skipping" errors, must be 
> an issue with the Canon firmware - why would it create a file with 
> B-frames _first_ in a stand-alone clip? In the end I end up with a video 
> stream that is slightly shorter than the audio. Anyone else seen this? 
> Searching for this error didn't turn up anything AVCHD related, only DVB 
> stuff.
>
> 2: There are some blocky artifacts in the decoded video that I can't 
> spot when playing back the original file in Nero8 ShowTime or using the 
> component video terminals on the camcorder itself. Anything that gets 
> lost in demux/decode? Most of the frames look good but some goes 
> slightly bad (not all over the screen, just small portions). In my 
> example clip there's garbage in frame 62 in the resulting 24p file for 
> example. The garbage can be seen when decoding the original file in 
> MPlayer as well, so it's not a result of broken detc or filmdint filtering.
>
> If anyone's interested the source clip (of a side-scrolling Nevada 
> desert) it is available here: http://xnk.nu/pf24/00028.mts . It's a 
> fairly short clip (~10 seconds / ~20MB), but it immediately shows any 
> broken 24p conversion! :)
>
> This is a sample command line of what I try to do, accompanied by the 
> corresponding output (changing the video filter chain to 
> softskip,detc,scale=960:540,harddup will make the resulting file 
> substantially smaller, suitable as a proxy clip for faster editing) :
> [root at rofs ~]#  mencoder 00028.mts -noaspect -noskip -o 28ffvhuff.avi 
> -fps 60000/1001 -ofps 24000/1001 -oac pcm -ovc lavc -vf 
> softskip,detc,harddup -lavcopts vcodec=ffvhuff
>
> MEncoder dev-SVN-r26664-4.1.2 (C) 2000-2008 MPlayer Team
> CPU: AMD Athlon(tm) 64 Processor 4000+ (Family: 15, Model: 39, Stepping: 1)
> CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
> Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2
>
> success: format: 0  data: 0x0 - 0x1434000
> TS file format detected.
> VIDEO H264(pid=4113) AUDIO A52(pid=4352) NO SUBS (yet)!  PROGRAM N. 1
> [V] filefmt:29  fourcc:0x10000005  size:0x0  fps:0.000  ftime:=0.0000
> Input fps will be interpreted as 59.940 instead.
> ==========================================================================
> Opening audio decoder: [liba52] AC3 decoding with liba52
> Using SSE optimized IMDCT transform
> Using MMX optimized resampler
> AUDIO: 48000 Hz, 2 ch, s16le, 256.0 kbit/16.67% (ratio: 32000->192000)
> Selected audio codec: [a52] afm: liba52 (AC3-liba52)
> ==========================================================================
> Opening video filter: [expand osd=1]
> Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
> Opening video filter: [harddup]
> Opening video filter: [detc]
> Opening video filter: [softskip]
> ==========================================================================
> Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
> Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
> ==========================================================================
> VDec: vo config request - 1920 x 1080 (preferred colorspace: Planar YV12)
> VDec: using Planar YV12 as output csp (no 0)
> Movie-Aspect is undefined - no prescaling applied.
> videocodec: libavcodec (1920x1080 fourcc=48564646 [FFVH])
> [h264 @ 0x87bb8b0]B picture before any references, skipping0.002 [0:0]
> [h264 @ 0x87bb8b0]decode_slice_header error
> [h264 @ 0x87bb8b0]no frame!
> Error while decoding frame!
> [h264 @ 0x87bb8b0]B picture before any references, skipping0.003 [0:0]
> [h264 @ 0x87bb8b0]decode_slice_header error
> [h264 @ 0x87bb8b0]no frame!
> Error while decoding frame!
> [h264 @ 0x87bb8b0]B picture before any references, skipping0.005 [0:0]
> [h264 @ 0x87bb8b0]decode_slice_header error
> [h264 @ 0x87bb8b0]no frame!
> Error while decoding frame!
> [h264 @ 0x87bb8b0]B picture before any references, skipping0.007 [0:0]
> [h264 @ 0x87bb8b0]decode_slice_header error
> [h264 @ 0x87bb8b0]no frame!
> Error while decoding frame!
> New_Face failed. Maybe the font path is wrong.n   0mb  A-V:0.007 [0:0]
> Please supply the text font file (~/.mplayer/subfont.ttf).
> subtitle font: load_sub_face failed.
> New_Face failed. Maybe the font path is wrong.
> Please supply the text font file (~/.mplayer/subfont.ttf).
> subtitle font: load_sub_face failed.
> Writing header...
> ODML: Aspect information not (yet?) available or unspecified, not 
> writing vprp header.
> Writing header...
> ODML: Aspect information not (yet?) available or unspecified, not 
> writing vprp header.
> Pos:   9.8s    599f (100%) 10.19fps Trem:   0min 329mb  A-V:0.036 
> [278846:1536]
> Flushing video frames.
> Writing index...
> Writing header...
> ODML: Aspect information not (yet?) available or unspecified, not 
> writing vprp header.
>
> Video stream: 278846.091 kbit/s  (34855761 B/s)  size: 343091068 bytes  
> 9.843 secs  599 frames
>
> Audio stream: 1536.000 kbit/s  (192000 B/s)  size: 1923072 bytes  10.016 
> secs
> [root at rofs ~]#
>
>
> Anyone with any ideas why it behaves this way, it's _almost_ correct but 
> not 100%, slightly annoying.. :)
>
> /Werner
>
> _______________________________________________
> MEncoder-users mailing list
> MEncoder-users at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mencoder-users
>   


Further experimentation shows that the detc filter actually works best 
when the video is correctly decoded. I read this forum thread discussing 
the use of ldecod and ffmpeg to get proper video:
http://www.avsforum.com/avs-vb/showthread.php?t=789775

If I combine MEncoder for it's inverse telecine capabilities with the 
workflow described in that thread it produces a really nice artifact 
free (well only AVCHD artifacts left at least) 1920x1080p24 video.. If I 
use filmdint it complains about bottom field first and completely fails 
doing it's job, but detc works just fine (as the video is completely cut 
free).

At the moment I have to use xport, ldecod, ffmpeg and MEncoder to bend 
these files into shape, but at least it's working - but I'm sure 
MEncoder should be able to do this on it's own in the long run? The 
demux_ts may have to be extended in some part to behave more like the 
xport code, and some small portion of the h264 code isn't doing the same 
thing as the reference avc decoder in ldecod.

xport -h ../00028.mts 1 1 1
 -> Outputs bits0001.mpv (h264) & bits0001.mpa (ac3)

rm -f bits0001.ac3
 -> Remove any potential old file

mv bits0001.mpa bits0001.ac3
 -> Rename it

mkfifo fifo.yuv
 -> Create the fifo

ldecod.exe -i ./bits0001.mpv -o fifo.yuv & ffmpeg -r 30000/1001 -s 
1920x1080 -i fifo.yuv -aspect 16:9 -vcodec ffvhuff bits0001-30fps.avi
 -> decodes h264 video into gigantic uncompressed yuv420 video, feed it 
to the pipe for ffvhuff compression (about 50%) into bits0001-30fps.avi 
(30fps ffvhuff nosound)

rm -f fifo.yuv
 -> cleanup

mencoder bits0001-30fps.avi -noaspect -noskip -o bits0001-24fps.avi 
-ofps 24000/1001 -ovc lavc -vf detc,softskip -lavcopts vcodec=ffvhuff
 -> bits0001-24fps.avi (24fps ffvhuff nosound)

ffmpeg -i bits0001-24fps.avi -i bits0001.ac3 -acodec pcm_s16le -vcodec 
copy 00028.avi
 -> 00028.avi (24fps ffvhuff + pcm sound)

Optional extra:

ffmpeg -i bits0001-24fps.avi -i bits0001.ac3 -acodec pcm_s16le -vcodec 
ffvhuff -s 960x540 proxy/00028.avi
 -> proxy/00028.avi (24fps ffvhuff proxy clip 960x540 + pcm sound)

Note that if audio is involved during inverse telecine process MEncoder 
does some frame-skipping even though -noskip is on the command line. The 
solution was to leave audio out of the equation until the very last step.

/Werner



More information about the MEncoder-users mailing list