[FFmpeg-user] Reencoding video from image sequence doesn't work (sometimes)
DopeLabs
dopelabs at dubstep.fm
Thu Jan 18 23:27:47 EET 2018
just with a quick glance.. -c copy means stream copy.. as in not to re-encode.. you should use -c copy OR -vcodec h264(-c:v h264), not both...i bet ffmpeg can do whatever upconvert that utility is doing without the need to go with a sequence first.
check out the ffmpeg docs for functions, filters, utilities, scalers, etc ,etc
> On Jan 18, 2018, at 12:53 48PM, serialhex at gmail.com wrote:
>
> First of all, I've exhausted all my Google-fu to no avail... so any help is
> greatly appreciated!
>
> I found a cool utility to upconvert anime images
> (if you're interested https://github.com/lltcggie/waifu2x-caffe) and so I'm
> reencoding my low quality
> anime using this. First I rip to an image sequence using a command like:
>
> .\ffmpeg.exe -i full-20s.mkv -f image2 "file\seq-%09d.png"
>
> I also get some metadata, such as framerate and stuff using ffprobe
> Then I do the upconvert of the image sequence, and then I put it back
> together
>
> .\ffmpeg.exe -y -i "full-20s.mkv" -framerate $framerate -f image2 -i
> "file\seq-%09d.png" -map 1:v -c copy -vcodec h264 -pix_fmt yuv420p -map 0
> -map -0:v out.mkv
>
> This works beautifully for most files, but for some files this breaks in a
> weird way. The file will encode
> okay, and I can then play it, but I get no video. If I then seek to a
> random place, pause the video and
> then seek to near the beginning, it works perfectly.
>
> I've uploaded some example files here:
> https://drive.google.com/open?id=1qog43RZ8hPfQIjc6PbGi1Ii_ugeFNrQO
> (oddly, playing the bad "out.mkv" file from google drive works fine, but vlc
> and other media
> players it doesn't -_- )
>
> I've already tried making a keyframe at the beginning with adding
> `-force_key_frames 0.0` to my
> command line, and making a video out of the image sequence (which then plays
> fine!!!) and adding it to
> the audio later. I've done a lot of research, and I'm at a loss.
>
> "full-20s.mkv" was taken using ./ffmpeg -i full-episode.mkv -t 20 -c copy
> -map 0 full-20s.mkv
>
> I then made out.mkv using the following 2 commands:
>
> D:\programmin\Projects\reencode> & .\ffmpeg.exe -i full-20s.mkv -f image2
> ".\inp-full-20s.mkv\seq-%09d.png"
> ffmpeg version N-79690-g78baa45 Copyright (c) 2000-2016 the FFmpeg
> developers
> built with gcc 5.3.0 (GCC)
> configuration: --enable-gpl --enable-version3 --disable-w32threads
> --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
> --enable-gnutls --enable-iconv --enable-libass --enable-libblu
> ray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme
> --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx
> --enable-libmp3lame --enable-libopencore-amrnb --enable-
> libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp
> --enable-libschroedinger --enable-libsnappy --enable-libsoxr
> --enable-libspeex --enable-libtheora --enable-libtwolame --enable-
> libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
> --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxavs --enable-libxvid --enable-libzimg --enable
> -lzma --enable-decklink --enable-zlib
> libavutil 55. 23.100 / 55. 23.100
> libavcodec 57. 38.100 / 57. 38.100
> libavformat 57. 34.103 / 57. 34.103
> libavdevice 57. 0.101 / 57. 0.101
> libavfilter 6. 44.100 / 6. 44.100
> libswscale 4. 1.100 / 4. 1.100
> libswresample 2. 0.101 / 2. 0.101
> libpostproc 54. 0.100 / 54. 0.100
> The tags at index 3 refer to a non-existent track 4.
> The tags at index 7 refer to a non-existent track 4.
> Input #0, matroska,webm, from
> 'D:\programmin\Projects\reencode\full-20s.mkv':
> Metadata:
> ENCODER : Lavf57.34.103
> Duration: 00:00:20.12, start: 0.000000, bitrate: 640 kb/s
> Stream #0:0: Video: h264 (High), yuv420p, 848x480, SAR 1:1 DAR 53:30,
> 19.18 fps, 19.18 tbr, 1k tbn (default)
> Metadata:
> DURATION : 00:00:20.124000000
> Stream #0:1(jpn): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp (default)
> Metadata:
> DURATION : 00:00:20.010000000
> Stream #0:2(eng): Subtitle: ass (default)
> Metadata:
> DURATION : 00:00:00.000000000
> Stream #0:3: Attachment: ttf
> Metadata:
> filename : RotisWTF.ttf
> mimetype : application/x-truetype-font
> [image2 @ 00000000004ef9c0] Using AVStream.codec to pass codec parameters to
> muxers is deprecated, use AVStream.codecpar instead.
> Output #0, image2, to '.\inp-full-20s.mkv\seq-%09d.png':
> Metadata:
> encoder : Lavf57.34.103
> Stream #0:0: Video: png, rgb24, 848x480 [SAR 1:1 DAR 53:30], q=2-31, 200
> kb/s, 19.18 fps, 19.18 tbn (default)
> Metadata:
> DURATION : 00:00:20.124000000
> encoder : Lavc57.38.100 png
> Stream mapping:
> Stream #0:0 -> #0:0 (h264 (native) -> png (native))
> Press [q] to stop, [?] for help
> frame= 386 fps=150 q=-0.0 Lsize=N/A time=00:00:20.12 bitrate=N/A
> speed=7.83x
> video:209581kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: unknown
>
> D:\programmin\Projects\reencode> .\ffmpeg.exe -y -framerate 28752/1499 -f
> image2 -i ".\inp-full-20s.mkv\seq-%09d.png" -i "full-20s.mkv" -map 0:v -map
> 1 -map -1:v -c copy -vcodec h264 -pix_fmt yuv420p out.mkv
> ffmpeg version N-79690-g78baa45 Copyright (c) 2000-2016 the FFmpeg
> developers
> built with gcc 5.3.0 (GCC)
> configuration: --enable-gpl --enable-version3 --disable-w32threads
> --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
> --enable-gnutls --enable-iconv --enable-libass --enable-libblu
> ray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme
> --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx
> --enable-libmp3lame --enable-libopencore-amrnb --enable-
> libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp
> --enable-libschroedinger --enable-libsnappy --enable-libsoxr
> --enable-libspeex --enable-libtheora --enable-libtwolame --enable-
> libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
> --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxavs --enable-libxvid --enable-libzimg --enable
> -lzma --enable-decklink --enable-zlib
> libavutil 55. 23.100 / 55. 23.100
> libavcodec 57. 38.100 / 57. 38.100
> libavformat 57. 34.103 / 57. 34.103
> libavdevice 57. 0.101 / 57. 0.101
> libavfilter 6. 44.100 / 6. 44.100
> libswscale 4. 1.100 / 4. 1.100
> libswresample 2. 0.101 / 2. 0.101
> libpostproc 54. 0.100 / 54. 0.100
> Input #0, image2, from '.\inp-full-20s.mkv\seq-%09d.png':
> Duration: 00:00:20.12, start: 0.000000, bitrate: N/A
> Stream #0:0: Video: png, rgb24(pc), 848x480 [SAR 1:1 DAR 53:30], 19.17
> fps, 19.18 tbr, 19.18 tbn
> The tags at index 3 refer to a non-existent track 4.
> The tags at index 7 refer to a non-existent track 4.
> Input #1, matroska,webm, from 'full-20s.mkv':
> Metadata:
> ENCODER : Lavf57.34.103
> Duration: 00:00:20.12, start: 0.000000, bitrate: 640 kb/s
> Stream #1:0: Video: h264 (High), yuv420p, 848x480, SAR 1:1 DAR 53:30,
> 19.18 fps, 19.18 tbr, 1k tbn (default)
> Metadata:
> DURATION : 00:00:20.124000000
> Stream #1:1(jpn): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp (default)
> Metadata:
> DURATION : 00:00:20.010000000
> Stream #1:2(eng): Subtitle: ass (default)
> Metadata:
> DURATION : 00:00:00.000000000
> Stream #1:3: Attachment: ttf
> Metadata:
> filename : RotisWTF.ttf
> mimetype : application/x-truetype-font
> [libx264 @ 00000000030f0480] using SAR=1/1
> [libx264 @ 00000000030f0480] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
> [libx264 @ 00000000030f0480] profile High, level 3.0
> [libx264 @ 00000000030f0480] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC
> codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options:
> cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=
> hex subme=7 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=12 lookahead_threads=2 sliced_threads=0 nr=0 dec
> imate=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=2
> keyint=250 keyint_min=19 scenecut=40 intra_refresh=0 rc_lookah
> ead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4
> ip_ratio=1.40 aq=1:1.00
> [matroska @ 00000000031daa20] Using AVStream.codec to pass codec parameters
> to muxers is deprecated, use AVStream.codecpar instead.
> Last message repeated 3 times
> Output #0, matroska, to 'out.mkv':
> Metadata:
> encoder : Lavf57.34.103
> Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 848x480 [SAR 1:1
> DAR 53:30], q=2-31, 19.18 fps, 1k tbn
> Metadata:
> encoder : Lavc57.38.100 libx264
> Side data:
> cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
> Stream #0:1(jpn): Audio: aac (HE-AAC) ([255][0][0][0] / 0x00FF), 48000
> Hz, stereo (default)
> Metadata:
> DURATION : 00:00:20.010000000
> Stream #0:2(eng): Subtitle: ass (default)
> Metadata:
> DURATION : 00:00:00.000000000
> Stream #0:3: Attachment: ttf
> Metadata:
> filename : RotisWTF.ttf
> mimetype : application/x-truetype-font
> Stream mapping:
> Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
> Stream #1:1 -> #0:1 (copy)
> Stream #1:2 -> #0:2 (copy)
> Stream #1:3 -> #0:3 (copy)
> Press [q] to stop, [?] for help
> [image2 @ 00000000005b65a0] Thread message queue blocking; consider raising
> the thread_queue_size option (current value: 8)
> frame= 386 fps=143 q=-1.0 Lsize= 1978kB time=00:00:20.01 bitrate=
> 809.6kbits/s speed= 7.4x
> video:1814kB audio:99kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: 3.401193%
> [libx264 @ 00000000030f0480] frame I:10 Avg QP:17.92 size: 11772
> [libx264 @ 00000000030f0480] frame P:173 Avg QP:22.36 size: 8013
> [libx264 @ 00000000030f0480] frame B:203 Avg QP:25.76 size: 1738
> [libx264 @ 00000000030f0480] consecutive B-frames: 20.2% 25.4% 10.9% 43.5%
> [libx264 @ 00000000030f0480] mb I I16..4: 21.9% 60.3% 17.8%
> [libx264 @ 00000000030f0480] mb P I16..4: 3.3% 20.1% 3.5% P16..4: 27.4%
> 8.8% 3.8% 0.0% 0.0% skip:33.1%
> [libx264 @ 00000000030f0480] mb B I16..4: 1.2% 4.5% 0.3% B16..8: 15.3%
> 1.9% 0.5% direct: 5.1% skip:71.3% L0:40.9% L1:49.6% BI: 9.5%
> [libx264 @ 00000000030f0480] 8x8 transform intra:72.8% inter:68.9%
> [libx264 @ 00000000030f0480] coded y,uvDC,uvAC intra: 39.3% 51.0% 21.0%
> inter: 12.4% 16.4% 2.0%
> [libx264 @ 00000000030f0480] i16 v,h,dc,p: 45% 23% 12% 20%
> [libx264 @ 00000000030f0480] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 16% 22% 4%
> 5% 4% 5% 4% 5%
> [libx264 @ 00000000030f0480] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 16% 13% 7%
> 10% 8% 8% 7% 6%
> [libx264 @ 00000000030f0480] i8c dc,h,v,p: 60% 17% 16% 7%
> [libx264 @ 00000000030f0480] Weighted P-Frames: Y:13.9% UV:10.4%
> [libx264 @ 00000000030f0480] ref P L0: 73.0% 16.4% 8.2% 2.3% 0.1%
> [libx264 @ 00000000030f0480] ref B L0: 90.9% 7.6% 1.5%
> [libx264 @ 00000000030f0480] ref B L1: 97.8% 2.2%
> [libx264 @ 00000000030f0480] kb/s:738.12
>
> you can seek to like 4 seconds in out.mkv and then get video, but starting
> from the beginning gets nothing.
>
> I'm not sure what's going on, this works with some mkv files, and not with
> others, also I was able to
> reencode and entire anime in mp4 format without problems like this.
>
> Any help would be appreciated!
>
> By the way, the entire powershell script if anyone is interested:
> https://gist.github.com/serialhex/18ff67b31f05e700d5456aac0e213e7f
>
> Thanks for your help
>
>
>
> --
> Sent from: http://www.ffmpeg-archive.org/
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list