Tech
Tech

Reputation: 935

Trying to resize m3u8 videos with ffmpeg

I have a m3u8 vod video on my server. It's working correctly. Now I want to create a smaller size for mobile devices.

Need to create a 480p m3u8 file.

I've tried this code but it's not worked.

ffmpeg -i HD.m3u8 -vf scale=842:-1 -c:a copy -start_number 0 -hls_time 8 -hls_list_size 0 -f hls  ./SM.m3u8

And here is my error code:

  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[hls,applehttp @ 0x55a16f22a880] Opening 'HD0.ts' for reading
Input #0, hls,applehttp, from 'HD.m3u8':
  Duration: 02:05:08.29, start: 1.460111, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 24 fps, 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 0
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0x55a16f267880] height not divisible by 2 (842x351)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

Is it possible to convert it from a m3u8 file or do I need the original mp4 file for this?

Upvotes: 0

Views: 1654

Answers (1)

Gyan
Gyan

Reputation: 93058

H.264 4:2:0 sampled video has to have even dimensions, so it should be -vf scale=842:-2.

Also, for -hls_time 8, you have to ensure keyframes exist every 8 seconds. Add -force_key_frames expr:gte(t,n_forced*8)

Upvotes: 2

Related Questions