FORUMS: list search recent posts

Trimmed video is not played by TV player

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Andrey Babintsev
Trimmed video is not played by TV player
on Feb 11, 2013 at 7:31:14 pm

Hi all!

I have 1920x1080 MTS file from Sony Handycam. I converted so that my LG TV would be able to play it:
ffmpeg -i first.MTS -vcodec libx264 -preset fast -vf scale=1280:720 -crf 20 -maxrate 10000k -bufsize 5000k -acodec copy -y first.mp4

Then I decided to trim the video. If to capture only 5 leading seconds, then video is not recognized by LG TV ("unsupported format"):
ffmpeg -i first.mp4 -vcodec copy -acodec copy -t 5 -y trim5.mp4

However it is recognized if to leave 15 leading seconds:
ffmpeg -i first.mp4 -vcodec copy -acodec copy -t 15 -y trim15.mp4

What can be the reason that 5 second video is not recognized by TV player? How to get it recognized?

###############
#MTS -> mp4:
###############

ffmpeg version git-2013-01-30-b926cc7 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 30 2013 22:37:52 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
libavutil 52. 17.100 / 52. 17.100
libavcodec 54. 91.100 / 54. 91.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 34.101 / 3. 34.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mpegts, from 'first.MTS':
Duration: 00:00:40.07, start: 1.000033, bitrate: 10833 kb/s
Program 1
Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
[libx264 @ 0x2da2020] using SAR=1/1
[libx264 @ 0x2da2020] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle Cache64
[libx264 @ 0x2da2020] profile High, level 3.1
[libx264 @ 0x2da2020] 264 - core 129 r2 bc13772 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 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=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=10000 vbv_bufsize=5000 crf_max=0.0 nal_hrd=none ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x2da4080] track 1: codec frame size is not set
Output #0, mp4, to 'first.mp4':
Metadata:
encoder : Lavf54.61.104
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 12800 tbn, 25 tbc
Stream #0:1: Audio: ac3 ([165][0][0][0] / 0x00A5), 48000 Hz, stereo, 256 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1002 fps=6.4 q=32766.0 Lsize= 27432kB time=00:00:40.10 bitrate=5603.4kbits/s dup=1 drop=0
video:26153kB audio:1252kB subtitle:0 global headers:0kB muxing overhead 0.097143%
[libx264 @ 0x2da2020] frame I:5 Avg QP:19.34 size:104456
[libx264 @ 0x2da2020] frame P:413 Avg QP:21.58 size: 42969
[libx264 @ 0x2da2020] frame B:584 Avg QP:23.95 size: 14574
[libx264 @ 0x2da2020] consecutive B-frames: 0.9% 46.9% 51.8% 0.4%
[libx264 @ 0x2da2020] mb I I16..4: 3.1% 79.3% 17.7%
[libx264 @ 0x2da2020] mb P I16..4: 0.7% 9.1% 1.2% P16..4: 45.4% 28.5% 14.1% 0.0% 0.0% skip: 1.0%
[libx264 @ 0x2da2020] mb B I16..4: 2.0% 5.1% 0.3% B16..8: 35.9% 11.9% 0.4% direct:33.9% skip:10.5% L0:25.9% L1:60.2% BI:14.0%
[libx264 @ 0x2da2020] 8x8 transform intra:76.4% inter:53.2%
[libx264 @ 0x2da2020] coded y,uvDC,uvAC intra: 76.6% 97.3% 73.2% inter: 36.9% 74.3% 10.3%
[libx264 @ 0x2da2020] i16 v,h,dc,p: 16% 12% 31% 40%
[libx264 @ 0x2da2020] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 13% 22% 6% 11% 10% 10% 7% 8%
[libx264 @ 0x2da2020] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 15% 12% 7% 13% 11% 11% 7% 7%
[libx264 @ 0x2da2020] i8c dc,h,v,p: 58% 16% 15% 11%
[libx264 @ 0x2da2020] Weighted P-Frames: Y:0.7% UV:0.0%
[libx264 @ 0x2da2020] ref P L0: 72.9% 27.1%
[libx264 @ 0x2da2020] ref B L0: 75.8% 24.2%
[libx264 @ 0x2da2020] ref B L1: 94.9% 5.1%
[libx264 @ 0x2da2020] kb/s:5345.28


###############
# trim 5 seconds:
###############
ffmpeg version git-2013-01-30-b926cc7 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 30 2013 22:37:52 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
libavutil 52. 17.100 / 52. 17.100
libavcodec 54. 91.100 / 54. 91.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 34.101 / 3. 34.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'first.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.61.104
Duration: 00:00:40.08, start: 0.000000, bitrate: 5606 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5345 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 256 kb/s
Metadata:
handler_name : SoundHandler
[mp4 @ 0x24a7540] track 1: codec frame size is not set
Output #0, mp4, to 'trim5.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.61.104
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 5345 kb/s, 25 fps, 12800 tbn, 12800 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 ([165][0][0][0] / 0x00A5), 48000 Hz, stereo, 256 kb/s
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 127 fps=0.0 q=-1.0 Lsize= 3551kB time=00:00:05.03 bitrate=5781.7kbits/s
video:3390kB audio:156kB subtitle:0 global headers:0kB muxing overhead 0.125129%


###############
# trim 15 seconds:
###############
ffmpeg version git-2013-01-30-b926cc7 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 30 2013 22:37:52 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
libavutil 52. 17.100 / 52. 17.100
libavcodec 54. 91.100 / 54. 91.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 34.101 / 3. 34.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'first.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.61.104
Duration: 00:00:40.08, start: 0.000000, bitrate: 5606 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5345 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 256 kb/s
Metadata:
handler_name : SoundHandler
[mp4 @ 0x22ef540] track 1: codec frame size is not set
Output #0, mp4, to 'trim5.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.61.104
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 5345 kb/s, 25 fps, 12800 tbn, 12800 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 ([165][0][0][0] / 0x00A5), 48000 Hz, stereo, 256 kb/s
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 377 fps=0.0 q=-1.0 Lsize= 10219kB time=00:00:15.01 bitrate=5575.6kbits/s
video:9741kB audio:468kB subtitle:0 global headers:0kB muxing overhead 0.105686%


Return to posts index

Jim Sustacek
Re: Trimmed video is not played by TV player
on Feb 12, 2013 at 1:48:55 pm

That's curious. My first thought is maybe it's a key frame issue? Or maybe your LG TV doesn't support files under a certain time/size, as it might assume them to be corrupt?

First, I would try trimming to 6, 7, 8, 9 seconds etc., up to 15, to see when exactly the trimmed video becomes compatible.

Then, I would try trimming to 5 seconds (or however many seconds as determined by the test above) within your original export command:
ffmpeg -i first.MTS -vcodec libx264 -preset fast -vf scale=1280:720 -crf 20 -maxrate 10000k -bufsize 5000k -acodec copy -t 5 -y firsttrim5.mp4
Let us know how that works. I would be curious to see if this LG TV would play ANY file of 5 seconds in length, if you have any other compatible files you could try trimming and/or re-exporting.


Return to posts index

Andrey Babintsev
Re: Trimmed video is not played by TV player
on Feb 12, 2013 at 8:14:45 pm

Thank you for response!

1. Trimmed video becomes compatible at 10s.
9s - still incompatible.
10s - compatible.
11, 12, 13.. - compatible

2. Trimming with my original export command:
to 5s - incompatible
to 10s - incompatible
to 20s - compatible

3. I tried the same steps for .MOV video from Panasonic Photo Camera:
exported and then trimmed.
Exported video is played, trimmed video isn't.

4. I downloaded .avi movie ( I believe that quite experienced person exported it from DVD source) and trimmed it to 5 seconds.
It is compatible! So, LG TV can play 5sec video.

I am newbie in video/audio encoding. Perhaps my initial exports command lacks some keys, may be some metadata should be rebuilt. You said about key frame issue. Is there any way to control it?


Return to posts index


Reuben Martin
Re: Trimmed video is not played by TV player
on Feb 13, 2013 at 12:06:08 am

You can't just trim h264 video at arbitrary points in the stream without re-encoding it. The exception is if you trim it on a keyframe. Or if the video is Intra-frame only in which case every frame is a key-frame.


Return to posts index

Andrey Babintsev
Re: Trimmed video is not played by TV player
on Feb 13, 2013 at 5:33:35 am

I think it is the reason why my 5 seconds trimmed video is of 5.68 sec duration. However it is easily played by mplayer and windows media player, but it is incompatible with LG TV.
I tried to trim it while re-encoding, with the same result.


Return to posts index

Jim Sustacek
Re: Trimmed video is not played by TV player
on Feb 13, 2013 at 8:49:06 pm

What happens if you trim first, then re-encode?

You could also try forcing some keyframes in your re-encoding, for example
-force_key_frames 0:00:00,0:00:05
would force two key frames: one at the beginning of the file and one at 5 seconds. Or:
-force_key_frames expr:gte(t,n_forced*5)
should do the same. Although admittedly I haven't played around with forcing keyframes... I was just guessing that maybe the LG TV is seeing too few keyframes in the shortened file.


Return to posts index


Andrey Babintsev
Re: Trimmed video is not played by TV player
on Feb 14, 2013 at 8:13:13 am

If I trim first, then re-encode, nothing changes.

I will try forcing keyframes. Thank you for the example.

In fact LG TV seems to be very capricious to re-encoded video. It didn't recognize .mp4 created with -slow, slower, veryslow presets for 1280x720 scale. For 1920x1080 situation got even worse.


Return to posts index

Jim Sustacek
Re: Trimmed video is not played by TV player
on Feb 13, 2013 at 8:39:17 pm

You should be able to trim at the end without impacting compatibility, right? I know trimming at the beginning of files (-ss) can be problematic, but I trim the end of files to arbitrary points all the time without any issues, although admittedly I'm not trimming them down to 5-10 seconds or trying to play them on a TV...


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]